Issue about sending an event to the QGraphicsScene/QML code.
I have a renderwidget (qglwidget subclass) for rendering the game content onto the widget by using the OpenGL technology and I also have a qgraphicsscene for the in game Ui, for instance a menu with options like. 1) Resume 2) Help 3) Quit to the system etc. It appears for instance after pressing a button, like "Esc", inside the game.
The problem is the following, we need to handle the inputs, for example with the qt input events. We have an inputmanager singleton class, and that is the filter for the input events. There is no qgraphicsitem just a qgraphicsscene because we render it onto the off screen framebuffer. What I did is that (It is an implementation sequence, not program workflow (: ):
- Emit a signal with the desired QEvent argument inside the eventFilter reimplementation.
- Connect that signal to a slot which will send the event to the QGraphicsScene by using the QApplication::instance()->sendEvent(...) method. This connection is done in the constructor of the QGraphicsScene subclass, so it is properly connected before getting input events.
- Simple event reimplementation for verifying I get the events and I apparently get them properly. When I try to catch the onPressed signal in QML, it does not really work, I tried to make some log onto the console, but nothing I would have gotten.
InputManager: https://projects.kde.org/projects/playground/games/gluon/repository/revisions/master/entry/input/inputmanager.cpp (eventFilter method)
QGraphicsScene subclass (RenderableScene): https://projects.kde.org/projects/playground/games/gluon/repository/revisions/master/entry/engine/components/graphics/uimanager/renderablescene.cpp
Feel free to ask further questions, if I now miss something for you to understand the issue better. Thank you in advance!
Edit: Looking now into something like this: