[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>
...<br>
def hoverLeaveEvent(self, hoverEvent):<br>
self.scene()._viewCursorReset = \
True<br> <br>
class MyView(QGraphicsView):<br>
...<br>
def mouseMoveEvent(self, mouseEvent):<br>
...<br>
if \
self.scene()._viewCursorReset:<br>
# update \
cursors<br>
# only once \
if view is reentered<br>
\
self.updateItems()<br>
\
self.scene()._viewCursorReset = False<br> \
...<br>
\
<br> class MyScene(QGraphicsScene):<br>
...<br>
def __init__(self, parent=None):<br>
...<br>
self._viewCursorReset = True<br>
...<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