[PyQt] setText from threading

Andreas Pakulat apaku at gmx.de
Thu Feb 21 22:17:45 GMT 2008


On 21.02.08 22:58:00, Aaron Digulla wrote:
> Reinaldo de Carvalho schrieb:
> 
> > The objective of this thread is only dont freeze window. No concurrent
> > acccess will happen to GUI components. A have a hundred of methods
> > called by pushButtons or SIGNALs from Qlistview like itemChanged, that
> > manipulate the GUI mainly to populate many QListViews or setting text
> > on textLabel as status bar.
> > 
> > I am search examples like optimaze my code to use postEvent. But the
> > program is running normally with non-main-thread accessing to GUI.
> 
> As long as you can guarantee that only one threat at a time runs UI
> code, you're safe. It *might* fail when the user moves the mouse while
> you update the UI, for example. It might fail when you upgrade to the
> next version of Qt.
> 
> Why don't you emit() signals with the updates in the worker thread and
> connect to that signal in the main code?

There are no queued connections in Qt3 (which the OP is using) and hence
the only option is QCustomEvent and QApplication::postEvent or whatever
the "native python" alternative is.

Andreas

-- 
Communicate!  It can't make things any worse.


More information about the PyQt mailing list