Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
4.6.3, 4.7.3
-
Intel Core 2 Duo, 4GB RAM, Windows XP 32bit
Intel Core 2 Quad, 4GB - 6GB RAM, Windows XP 32bit, Windows 7 32bit
-
ecd78168271cfe71715e074a50752712f4aa3229
Description
If one from parent widget of QProgressBar widget have not empty style sheet property (ex., "QWidget{}") repeating calls setStyleSheet("") method of the QProgressBar widget leads to a gradual increasing of CPU usage until capture one core.
Process Explorer show that main thread of process captures CPU time exactly.
============ Code for reproduction ===========
//-------------------- File main.cpp -----------------------------
#include <QtGui/QApplication>
#include <QWidget>
#include <QProgressBar>
#include "stylesheettimer.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget main;
main.setStyleSheet("QWidget{}");
QProgressBar* pb = new QProgressBar(&main);
main.show();
TStyleSheetTimer ssTimer(*pb); //for repeating calls pb->setSyleSheet
return a.exec();
}
//---------------------- File stylesheettimer.h --------------
#define STYLESHEETTIMER_H
#include <QTimer>
#include <QWidget>
class TStyleSheetTimer : public QTimer
{
Q_OBJECT
public:
TStyleSheetTimer(QWidget& stylewidget)
: QTimer()
, m_stylewidget(stylewidget)
private slots:
void onTimer()
private:
QWidget& m_stylewidget;
};
#endif // STYLESHEETTIMER_H
============ Code for reproduction finish ===========
Note 1: Passing "main" object (that have non-empty SS) to ssTimer constructor do not lead to increasing of CPU usage.
Note 2: Replacing empty argument value "" by valid CSS string (ex., "QProgressBar{}"
Same effect observed for applying empty CSS string to one from ProgressBar-widget's intermediate parents if the parent have empty style sheet property.
Code below creates few parents and leads to the increasing of CPU usage.
===========
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget main;
QWidget* child = new QWidget(&main);
child->setStyleSheet("QWidget{}");
QWidget* child2 = new QWidget(child);
QProgressBar* pb = new QProgressBar(child2);
main.show();
TStyleSheetTimer ssTimer(*child2);
return a.exec();
}
==============
Note 1: Passing "child" object (that have non-empty SS) to ssTimer constructor do not lead to increasing of CPU usage.