Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Issue about sending an event to the QGraphicsScene/QML code.
Forum Updated to NodeBB v4.3 + New Features

Issue about sending an event to the QGraphicsScene/QML code.

Scheduled Pinned Locked Moved QML and Qt Quick
1 Posts 1 Posters 2.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    djszapi
    wrote on last edited by
    #1

    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 (: ):

    1. Emit a signal with the desired QEvent argument inside the eventFilter reimplementation.
    2. 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.
    3. 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:
    http://qt.gitorious.org/qt-labs/qt3d/blobs/master/src/threed/graphicsview/qgraphicsembedscene.cpp#line309

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved