Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to let the QLabel display the differenet QPixmap in a for loop?



  • How to let the QLabel display the differenet QPixmap in a for loop?

    in my case,the QLabel will not display the QPixmap real time....How to make it?

    PS:The loop is in one slot function.

    Should it use the double buffer?



  • As your application is trapped in the for loop, the QLabel has no chance to execute its paint code to repaint itself with the new pixmap. You will have to use a QTimer, which repeatedly calls the slot, which no longer contains a loop, but instead just sets the next pixmap on the label.



  • Or you call pLabel->repaint (which leads to a direct repaint).



  • ... which renders your application quite unusable as well, because there is still no event processing.


Log in to reply