[Qt-interest] Event Propagation Architecture of Graphics View Framework

varun singh mailthatmale at yahoo.co.in
Sat Aug 15 09:47:46 CEST 2009


hi,
 So, I'm making this Tank's game using The Graphics View Framework.
I've three classes of Tank(QGraphicsItem), Scene(QGraphicScene) and View(QGraphicsView).
View contains a variable of Scene and Scene contains a variable of Tank.

Now, I want the Tank to move using Keys (Up, Down etc.).

So, I've programmed the Tank::keyPressEvent accordingly. The problem is that, I can't figure out how KeyEvents get propagated in the Framework.

According to the documentation, QGraphicsView receives keyboard event n forwards it to QGraphicsScene which in turn forwards it to QGraphicsItem.
But they, haven't specified it through an example (which is where I'm stuck). I can't simply call the keyPressEvent of one class from the other (they are protected). And moreover, like QEvent::QGraphicsSceneMousePressEvent, there is no such keyEvent specialized for it.

Any help here would be like an oxygen mask to a drowning diver, or a parachute to a skydiver...

-Varun 




      Yahoo! recommends that you upgrade to the new and safer Internet Explorer 8. http://downloads.yahoo.com/in/internetexplorer/




More information about the Qt-interest-old mailing list