[PyQt] QTreeWidget qnd QPaintEngine error

Hans-Peter Jansen hpj at urpla.net
Wed Nov 18 16:47:51 GMT 2009


On Wednesday 18 November 2009, 17:02:43 NARCISO, Rui wrote:
> First of all, sorry for the disclaimer.
>
> I'm not responsible for it and it is IMPOSSIBLE to remove it or to send
> any mail to any admin ...

Hmm postmaster@ should be wired in any domain. Anyway..

> Getting back to the issue at hand, thanks for the reply first of all.
>
> Secondly, what I do is that from the worker thread I send a SIGNAL
> whenever the task is done, which is received by the MainWindow and
> handled by the mainwindow instance (add a node, change the
> properties/color of the node).
>
> First quesiton: does this mean that it's the worker thread that is adding
> the node or is it the main thread that takes care of that ? If it's the
> thread who's doing it, how to make sure that all GUI modifications are
> handled only by the main thread ?

You're contradicting yourself here. Do you add items in the worker thread or 
do you emit a signal add_node from your worker thread, which is processed 
in the main thread (node added)? The latter is the only sane way to handle 
the task in question. 

IOW, and as a rule of thumb: put your threads code in extra modules, and do 
not import QtGui, neither directly, nor indirectly, and do not derive 
classes nor call methods or functions of other modules, that do so. 

> Second question: why do you mention the clipboard? No thread is fiddling
> with it at any time. I mean, I do have a connection between a double
> click on a QTreeWidgetItem and copying the data to a QClipboard but that
> never gets called during any of the worker threads.

Because of:

> > 	QPaintEngine::setSystemClip: Should not be changed while engine is
		      ^^^^^^^^^^^^^
> > active QWidgetPrivate::beginSharedPainter: Painter is already active
> > 	QPainter::begin: A paint device can only be painted by one painter at
> > a time.

but this could be just a side effect of violating law #1 in threaded Qt 
programming: see above.

Good luck,
Pete


More information about the PyQt mailing list