[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] setCursor does not seem to work as expected in
From:       "Christopher M. Nahler" <christopher.nahler () papermodels ! at>
Date:       2010-08-31 8:40:11
Message-ID: 4C7CBFEB.1030401 () papermodels ! at
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


  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
         ...

[Attachment #5 (text/html)]

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#ffffff" text="#000000">
    <font face="Courier New, Courier, monospace">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.<br>
      <br>
      So going back to Bazs ideas I added a check to re-update the view
      cursor whenever an item is left.<br>
      <br>
      Thanks for all the help!<br>
      <br>
      class MyRect(QGraphicsRectItem):<br>
      &nbsp;&nbsp;&nbsp; ...<br>
      &nbsp;&nbsp;&nbsp; def hoverLeaveEvent(self, hoverEvent):<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; self.scene()._viewCursorReset = \
True<br>  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>
      class MyView(QGraphicsView):<br>
      &nbsp;&nbsp;&nbsp; ...<br>
      &nbsp;&nbsp;&nbsp; def mouseMoveEvent(self, mouseEvent):<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ...<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if \
                self.scene()._viewCursorReset:<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # update \
                cursors<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # only once \
                if view is reentered<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
                self.updateItems()<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
self.scene()._viewCursorReset = False<br>  &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; \
                ...<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \
<br>  class MyScene(QGraphicsScene):<br>
      &nbsp;&nbsp;&nbsp; ...<br>
      &nbsp;&nbsp;&nbsp; def __init__(self, parent=None):<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ...<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; self._viewCursorReset = True<br>
      &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; ...<br>
    </font>
  </body>
</html>



_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic