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. How to pass `QQuickWheelEvent` to C++?
Qt 6.11 is out! See what's new in the release blog

How to pass `QQuickWheelEvent` to C++?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 3 Posters 216 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.
  • K Offline
    K Offline
    kaixoo
    wrote last edited by
    #1

    I've setup a QQuickFramebufferObject and now I'm trying to receive input from it. How do you pass events (like QML WheelEvent) to C++ code?

    MouseArea {
        anchors.fill: parent
        z: 999
    
        onClicked: (event) => appCanvas.onClicked(event)
    

    and then, in C++..

            Q_INVOKABLE void onClicked(QMouseEvent* event);
    

    Which doesn't seem to work:

    "Could not convert argument 0 from QQuickMouseEvent(0x57f228370c48) to QMouseEvent*"
    
    TypeError: Passing incompatible arguments to C++ functions from JavaScript is not allowed.
    
    JonBJ 1 Reply Last reply
    0
    • K kaixoo

      I've setup a QQuickFramebufferObject and now I'm trying to receive input from it. How do you pass events (like QML WheelEvent) to C++ code?

      MouseArea {
          anchors.fill: parent
          z: 999
      
          onClicked: (event) => appCanvas.onClicked(event)
      

      and then, in C++..

              Q_INVOKABLE void onClicked(QMouseEvent* event);
      

      Which doesn't seem to work:

      "Could not convert argument 0 from QQuickMouseEvent(0x57f228370c48) to QMouseEvent*"
      
      TypeError: Passing incompatible arguments to C++ functions from JavaScript is not allowed.
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote last edited by
      #2

      @kaixoo
      I am not a QMLer, but Can qml signal parameter MouseEvent be mapped to C++ class? suggests you should just explicitly pass those members you are interested in.

      1 Reply Last reply
      1
      • K Offline
        K Offline
        kaixoo
        wrote last edited by
        #3

        Oh, I need all of them :(

        1 Reply Last reply
        0
        • K kaixoo has marked this topic as solved
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote last edited by
          #4

          Hi,
          One thing you could do is create a small wrapper class so you don't have a big function signature.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          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