I've written my own implementation of QGraphicsView.drawItems()
, to fit the needs of my application. The method as such works fine, however, it is called repeatedly, even if it does not need to be redrawn. This causes the application to max out processor utilization.
Do I need to somehow signal that the drawing is finished? I read the source in the git tree, and I couldn't see any such thing being done.
The app is in Python/PyQt, and my draw-method looks like this:
def drawItems(self, painter, items, options):
markupColors={'manual':QColor(0, 0, 255),
'automatic':QColor(255, 0, 0),
'user':QColor(0, 255, 0)}
for index in xrange(len(items)):
item=items[index]
option=options[index]
dataAsInt, dataIsInt=item.data(self.DRAWABLE_INDEX).toInt()
drawable=None
if dataIsInt:
drawable=self.drawables[dataAsInt]
item.setPen(markupColors[drawable.source])
item.paint(painter, option, None)
The view's method is overridden by "monkey-patching", like this:
self.ui.imageArea.drawItems=self.drawer.drawItems
The above method is self.drawer.drawItems in the last statement.
Any ideas why this happens?