[Qt-interest] QGraphicsItem and Threads
Ole Streicher
ole-usenet-spam at gmx.net
Mon Oct 19 15:14:14 CEST 2009
Hi,
I am trying to change lots of QGraphicsItems at once:
for item in self.items:
item.setBrush(QtGui.QBrush(QtGui.QColor(c[0], c[1], c[2]))
When I do this in the main loop, everything is OK (but the gui behaves
not responsive during the loop). When I try to do this in an extra
thread, the program crashes on
/usr/lib/libQtGui.so.4(_ZN6QBrush4initERK6QColorN2Qt10BrushStyleE+0x7d)[0x7f49b1f4424d]
(is this the mangled QBrush constructor call?)
which I dont understand: At first, the Q[Abstract]GraphicsItems are not
QObjects, so their creation should be possible not only in the thread
where they are created. They also dont have a "moveToThread()" method so
that I could transfer them to another thread. They also have no parent
(which means that I should be able to transfer them without hassle) --
even the scene they belong to is not a "parent".
At second, the crash seems to occur not in the setBrush() method, but in
the constructor of QBrush -- that should not happen at all since the
QBrush creation should be possible in any thread.
What is wron here? And how can I make huge graphical changes (100.000
items) without getting my GUI unresponsive?
Regards
Ole
More information about the Qt-interest-old
mailing list