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. Passing touch coordinates to qml
Forum Updated to NodeBB v4.3 + New Features

Passing touch coordinates to qml

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 1.5k 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.
  • T Offline
    T Offline
    TilmanK
    wrote on last edited by
    #1

    Hi, another problem that I'm facing and where I might need some help:

    I have a parser class in C++ in which I receive coordinates from a touch device every ~15ms. Now here's the big question: is it possible to pass those coordinates directly to qml without any additional parsing? I just want to move a Rectangle around on the screen, so no big rocket science.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      chriadam
      wrote on last edited by
      #2

      If you expose the parser class to QML (ie, make it a QObject and expose the touchX and touchY coordinates as Q_PROPERTY ints) then you can simply bind the rectangle's x/y properties to the parser's touchX and touchY coordinates.

      If you don't want to expose the parser class, you could update context properties, but that will cause all bindings (not just the ones involving those properties) to be re-evaluated on every update, and so will most likely cause a prohibitive performance penalty.

      The final thing you could do is create a mouse click event from the touch coordinates, and send the event to a MouseArea defined in QML - its onClicked signal-handler could manually position the rectangle according to the mouse.x and mouse.y values available in the handler. But this is something I haven't ever tried, so YMMV.

      Cheers,
      Chris.

      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