[Qt-interest] QGraphicsItem and Threads
Ole Streicher
ole-usenet-spam at gmx.net
Fri Oct 23 09:36:38 CEST 2009
Hi Brad,
Brad Howes <howes at ll.mit.edu> writes:
> item.setBrush( item.brush().setColor( color ) );
At the end, this solution may be "faster", but less responsive.
What I did at the end is:
------------------------8<----------------------------------------------
def update_async(self):
brushes = [ QtGui.QBrush(QtGui.QColor(c[0], c[1], c[2]))
for color, item in zip(self.colors, self.items) ]
self.emit(QtCore.SIGNAL('newbrushes(PyQt_PyObject, PyQt_PyObject)'),
brushes, self.items)
def update_items(self, brushes, items):
for brush, item in zip(brushes, items):
item.setBrush(brush)
------------------------8<----------------------------------------------
and then connect the newbrushes() signal with the update_items slot.
This allows most of the computing to be done in an extra thread. Also
I divides the update_items calls into chunks of 1000 items so that in
between other gui actions can occur.
The total load of this is higher, but the program gui feels much better
now.
Ciao
Ole
More information about the Qt-interest-old
mailing list