[PyQt] event filters vs subclassing
halbert at halwitz.org
Tue Aug 3 15:27:24 BST 2010
I am implementing a simple specialized graphical editor in PyQt using a QGraphicsPixmapItem and related classes. I need to place points with mouse clicks and do a bit of dragging.
I can either subclass QGraphicsPixmapItem to handle various mouse events, or do installEventFilter(). In Mark Summerfield's PyQt book (p. 304), he cautions against using event filters, and suggests subclassing for most purposes, for complexity and efficiency reasons. I cannot find a pro/con discussion about this choice elsewhere, either in the C++ Qt book or on the web.
Is Mark cautioning against event filters in PyQt specifically (due to Python/Qt boundary crossing and filtering events in Python code), or is there some more general caution here? In my case, the choice seems to be a wash, but I may as well use good style. Any advice is appreciated.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the PyQt