[PyQt] processEvents on QlistWidget operations does nothing
P. Mathé
pmathe at neuf.fr
Tue Jan 29 10:48:40 GMT 2008
Le lundi 28 janvier 2008, Andreas Pakulat a écrit :
> On 28.01.08 12:40:36, Scott Aron Bloom wrote:
> > > Le lundi 28 janvier 2008, Scott Aron Bloom a écrit :
> > > > BTW... your issue is NOT a bug in QT... it's a bug in your understanding
> > > of how the model/view system works and refreshes the gui..
> > > You are right, it is a misunderstanding.
> > > Is is also a bug to understand that executing a QWidget.repaint()
> > > statement will immediately display the modified widget ? (I am referring
> > > to the doc that says :
> > > "Repaints the widget directly by calling paintEvent() immediately, unless
> > > updates are disabled or the widget is hidden."
> > >
> > In my view... it should be followed with. The painting occurs on the next execution of the event loop...
>
> No it doesn't. The painting is done immediately, see
> src/gui/painting/qbackingstore.cpp.
>
> However I guess addItem does something that only happens in the next run
> of the event loop.
>
> Andreas
>
I must admit that I start to be lost. So to try to clarify the situation I have simplified my test :
I discarded the web access, no tmer, no threading. I kept only the updating of the progressBar : the loop is as follow :
def extraire(self):
jours=(1, 2, 3, 4)
self.progressBar.setValue(0)
self.progressBar.setMaximum(4)
for jour in jours:
time.sleep(1)
self.progressBar.setValue(self.progressBar.value() + 1)
#self.log.update()
#self.log.repaint()
#QCoreApplication.processEvents(QEventLoop.AllEvents)
print 'fini'
Seems to be straightforward, just for beginners ?
Now the tests :
Case1. As is with, the three lines commented out :
the progress bar is updated once : i.e 25% is displayed, then it jumps to 100% (probably 50%,75% and 100% displayed at once)
Case2. only "QCoreApplication.processEvents(QEventLoop.AllEvents)" uncommented :
the progress bar is updated normally : i.e 25%, 50%, 75% and 100% are displayed in turn.
Case3. only "self.log.repaint()" uncommented :
the progress bar is updated twice : i.e. 25% and 50% are displayed , then it jumps to 100% (probably 75% and 100% displayed at once)
Case4. only "self.log.update()" uncommented : same as Case 3.
Pierre
More information about the PyQt
mailing list