Results 1 to 2 of 2

Thread: mouse move event filtering in PyQt4

  1. #1
    Join Date
    Apr 2009
    Posts
    2
    Qt products
    Platforms
    Unix/X11 Windows

    Angry mouse move event filtering in PyQt4

    Hi,
    I need to filter mouse moving on a QGraphicsView in PyQt4. I created a filter and install it to a QGraphicsView instance, but desired event seems not to be captured.

    Following a simple example showing how no mouse moving is filtered by eventFilter() function:
    Qt Code:
    1. import sys
    2.  
    3. from PyQt4 import QtCore, QtGui
    4.  
    5. class Filter(QtCore.QObject):
    6. def eventFilter(self, obj, event):
    7. print event.type()
    8. return False
    9.  
    10. class MainWin(QtGui.QMainWindow):
    11.  
    12. def __init__(self, parent=None, flags=QtCore.Qt.Widget):
    13. QtGui.QMainWindow.__init__(self, parent, flags)
    14.  
    15. self.scene = QtGui.QGraphicsScene(self)
    16. self.graphicsview = QtGui.QGraphicsView(self.scene, self)
    17. self.graphicsview.setMouseTracking(True)
    18. self.filter = Filter(self.graphicsview)
    19. self.graphicsview.installEventFilter(self.filter)
    20. self.setCentralWidget(self.graphicsview)
    21.  
    22. def main():
    23. app = QtGui.QApplication(sys.argv)
    24. mainwin = MainWin()
    25. mainwin.show()
    26. sys.exit(app.exec_())
    27.  
    28. if __name__ == '__main__':
    29. main()
    To copy to clipboard, switch view to plain text mode 

    Thanks to all ones that answer after reading this very complex code

  2. #2
    Join Date
    Apr 2009
    Posts
    2
    Qt products
    Platforms
    Unix/X11 Windows

    Default Re: mouse move event filtering in PyQt4

    Can someone help me?

Similar Threads

  1. how to send a emulated mouse event to QListWidget
    By yxmaomao in forum Qt Programming
    Replies: 4
    Last Post: 22nd July 2008, 02:49
  2. Enter event mouse position
    By bunjee in forum Qt Programming
    Replies: 9
    Last Post: 7th May 2008, 18:53
  3. Mouse Move Event
    By merry in forum Newbie
    Replies: 5
    Last Post: 3rd June 2007, 06:26
  4. Move Rectangle on mouse Move
    By vermarajeev in forum Qt Programming
    Replies: 24
    Last Post: 14th May 2007, 05:34
  5. The event fired by the mouse click on the frame
    By Placido Currò in forum Qt Programming
    Replies: 8
    Last Post: 3rd March 2007, 09:05

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.