Results 1 to 8 of 8

Thread: Adding a QProgressbar makes my app cpu consumption pass from 0% to 80-100% of a core

  1. #1
    Join Date
    Aug 2012
    Posts
    10
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default 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?

    Qt Code:
    1. int main(int argc, char *argv[])
    2. {
    3. QApplication a(argc, argv);
    4. pruebasqt w;
    5.  
    6. QGraphicsDropShadowEffect* wndShadow = new QGraphicsDropShadowEffect;
    7. wndShadow->setBlurRadius(9.0);
    8. wndShadow->setColor(QColor(0, 0, 0, 90));
    9. wndShadow->setOffset(5);
    10. w.setGraphicsEffect(wndShadow);
    11.  
    12. w.setWindowFlags( Qt::FramelessWindowHint | Qt::WindowMinimizeButtonHint);
    13. w.setAttribute(Qt::WA_TranslucentBackground);
    14.  
    15. w.setStyleSheet("QWidget{ background: red;}");
    16.  
    17. w.show();
    18. return a.exec();
    To copy to clipboard, switch view to plain text mode 
    }

    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

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default 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)?

  3. #3
    Join Date
    Aug 2012
    Posts
    10
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default 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?
    Last edited by cgahete; 17th January 2014 at 15:05.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default 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,
    _

  5. #5
    Join Date
    Aug 2012
    Posts
    10
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default 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.

  6. #6
    Join Date
    Aug 2012
    Posts
    10
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Adding a QProgressbar makes my app cpu consumption pass from 0% to 80-100% of a c

    Full compilable version:

    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include <QGraphicsDropShadowEffect>
    3. #include <QProgressbar>
    4.  
    5.  
    6.  
    7. int main(int argc, char *argv[])
    8. {
    9. QApplication a(argc, argv);
    10.  
    11. QWidget* w = new QWidget();
    12. w->setGeometry(40,40,1600,1000);
    13. QProgressBar* qp = new QProgressBar(w);
    14. qp->setValue(99);
    15.  
    16. QGraphicsDropShadowEffect* wndShadow = new QGraphicsDropShadowEffect;
    17. w->setGraphicsEffect(wndShadow);
    18.  
    19. w->show();
    20. return a.exec();
    21. }
    To copy to clipboard, switch view to plain text mode 

  7. #7
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default 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,
    _

  8. #8
    Join Date
    Aug 2012
    Posts
    10
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default 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.

Similar Threads

  1. CPU consumption
    By valgaba in forum Qt Programming
    Replies: 1
    Last Post: 1st April 2013, 22:19
  2. QGraphicsScene - memory consumption
    By mateuszzz88 in forum Qt for Embedded and Mobile
    Replies: 3
    Last Post: 29th November 2010, 20:39
  3. QTreeView memory consumption
    By eyeofhell in forum Qt Programming
    Replies: 6
    Last Post: 19th November 2010, 01:04
  4. Replies: 1
    Last Post: 19th April 2010, 11:27
  5. Replies: 5
    Last Post: 18th April 2010, 23:31

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.