The following members of QML type MouseEvent are deprecated. They are provided to keep old source code working. We strongly advise against using them in new code.
(deprecated since 6.2)
[read-only, since 5.7] source : int |
This property is deprecated since 6.2. We strongly advise against using it in new code.
Use input handlers with acceptedDevices set.
This property holds the source of the mouse event.
The mouse event source can be used to distinguish between genuine and artificial mouse events. When using other pointing devices such as touchscreens and graphics tablets, if the application does not make use of the actual touch or tablet events, mouse events may be synthesized by the operating system or by Qt itself.
The value can be one of:
For example, to react only to events which come from an actual mouse:
MouseArea { onPressed: (mouse)=> { if (mouse.source !== Qt.MouseEventNotSynthesized) mouse.accepted = false } onClicked: doSomething() }
If the handler for the press event rejects the event, it will be propagated further, and then another Item underneath can handle synthesized events from touchscreens. For example, if a Flickable is used underneath (and the MouseArea is not a child of the Flickable), it can be useful for the MouseArea to handle genuine mouse events in one way, while allowing touch events to fall through to the Flickable underneath, so that the ability to flick on a touchscreen is retained. In that case the ability to drag the Flickable via mouse would be lost, but it does not prevent Flickable from receiving mouse wheel events.
This property was introduced in Qt 5.7.
As part of the free Business evaluation, we offer a free welcome call for companies, to talk about your requirements, and how the Felgo SDK & Services can help you. Just sign up and schedule your call.
Sign up now to start your free Business evaluation: