[PySide] QGraphicsItem Events

Matthew Ngaha chigga101 at gmail.com
Sun Aug 4 16:13:30 CEST 2013


hi, I'm trying to get familiar with the QGraphics classes. I have made
2 custom subclasses. The main one is a QGraphicsScene subclass and in
it i have an instance of a QGraphicsItem subclass. These are my 2
reimplimented classes. I need the QGraphicsItem instance to respond to
user input (mouse and keyboard). Looking at the docs i have set these
properties in its init method:

self.GraphicsItemFlags(QGraphicsItem.ItemIsFocusable)
self.setFocus(Qt.ActiveWindowFocusReason)

then i print
print(self.hasFocus())

the print returns False and my events like keyPressEvent are ignored
as the Item doesn't have focus. Please can anyone tell me or show me
an example of making a QGraphicsItem respond to user input?



More information about the PySide mailing list