[PyQt] setCursor does not seem to work as expected in graphicsScene/View

Christopher M. Nahler christopher.nahler at papermodels.at
Tue Aug 31 09:40:11 BST 2010


  After some test I have found that if the mouse cursor is "over" an 
item, a call to set the cursor of the view is ignored.

So going back to Bazs ideas I added a check to re-update the view cursor 
whenever an item is left.

Thanks for all the help!

class MyRect(QGraphicsRectItem):
     ...
     def hoverLeaveEvent(self, hoverEvent):
         self.scene()._viewCursorReset = True

class MyView(QGraphicsView):
     ...
     def mouseMoveEvent(self, mouseEvent):
         ...
         if self.scene()._viewCursorReset:
             # update cursors
             # only once if view is reentered
             self.updateItems()
             self.scene()._viewCursorReset = False
         ...

class MyScene(QGraphicsScene):
     ...
     def __init__(self, parent=None):
         ...
         self._viewCursorReset = True
         ...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20100831/6cf1e06e/attachment.html>


More information about the PyQt mailing list