Adding a QProgressbar makes my app cpu consumption pass from 0% to 80-100% of a core
Hi,
I’m adding a small QProgressbar to my app, but now I’m realizing that it is taking almost a core. I’ve read about some bugs related but I cant fix or workaround this issue. Any chances?
Code:
int main(int argc, char *argv[])
{
pruebasqt w;
QGraphicsDropShadowEffect* wndShadow = new QGraphicsDropShadowEffect;
wndShadow->setBlurRadius(9.0);
wndShadow
->setColor
(QColor(0,
0,
0,
90));
wndShadow->setOffset(5);
w.setGraphicsEffect(wndShadow);
w.setWindowFlags( Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint);
w.setAttribute(Qt::WA_TranslucentBackground);
w.setStyleSheet("QWidget{ background: red;}");
w.show();
return a.exec();
}
Being “pruebasqt†a default QMainWindow with one QProgressBar. This makes 100% of one core in my computer (An Intel Xeon with 8 cores and 26 Gb RAM)
-QT 4.8.4
-Windows 7
Re: Adding a QProgressbar makes my app cpu consumption pass from 0% to 80-100% of a c
Odd that you choose not to show the code that actually deals with the progress bar.
Is it just sitting doing nothing, or is the progress bar being updated? How is it being updated?
Does the program behave differently if you omit the graphical effect (lines 6-15)?
Re: Adding a QProgressbar makes my app cpu consumption pass from 0% to 80-100% of a c
Hi,
The window is the default one that QT designer creates for me: I create QMainWindow and add one QProgressbar. In fact, the problem appears when combining a QProgressbar and a QGraphicsDropShadowEffect. The QProgressbar is not being updated, the GUI is in idle. Can someone reproduce this?
Re: Adding a QProgressbar makes my app cpu consumption pass from 0% to 80-100% of a c
One possible cause could be the Windows 7 style progressbar animation, i.e. it somehow triggering recalculation of the graphics effect.
Does it also happen if you do not set the transparency widget attribute?
Cheers,
_
Re: Adding a QProgressbar makes my app cpu consumption pass from 0% to 80-100% of a c
Yes, its the same behaviour. The problem comes when combining the graphics effect with a QProgressbar.
Re: Adding a QProgressbar makes my app cpu consumption pass from 0% to 80-100% of a c
Full compilable version:
Code:
#include <QtGui/QApplication>
#include <QGraphicsDropShadowEffect>
#include <QProgressbar>
int main(int argc, char *argv[])
{
w->setGeometry(40,40,1600,1000);
qp->setValue(99);
QGraphicsDropShadowEffect* wndShadow = new QGraphicsDropShadowEffect;
w->setGraphicsEffect(wndShadow);
w->show();
return a.exec();
}
Re: Adding a QProgressbar makes my app cpu consumption pass from 0% to 80-100% of a c
Aside from the typo (should be #include <QProgressBar>) this works fine with Qt 4.8.6 on Linux.
Try with a different style, e.g. running the program with -style plastique
Cheers,
_
Re: Adding a QProgressbar makes my app cpu consumption pass from 0% to 80-100% of a c
Yes, I've tested other styles (that have no animation on QProgressbar) and no cpu compumption there.