How to pass `QQuickWheelEvent` to C++?
-
I've setup a
QQuickFramebufferObjectand now I'm trying to receive input from it. How do you pass events (like QMLWheelEvent) 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. -
I've setup a
QQuickFramebufferObjectand now I'm trying to receive input from it. How do you pass events (like QMLWheelEvent) 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. -
K kaixoo has marked this topic as solved on
-
Hi,
One thing you could do is create a small wrapper class so you don't have a big function signature. -
Hopefully, this will seem obvious in retrospect.
Event objects in QML must logically either be special-cased by the engine, or
QObjectinstances with properties accessed via the normal mechanism.A look at some source code suggests the later. As such, event instances can be passed to functions that receive a
QObject *. Properties of the object can then be read via QObject::property() or QMetaObject::property().