[Interest] Handling stylus input on a tablet in QML/QtQuick
Shawn Rutledge
Shawn.Rutledge at qt.io
Mon Apr 20 06:07:13 CEST 2020
> On 19 Apr 2020, at 01:16, Thorsten Hofer-Schmitz <thorsten.schmitz.bn.90 at gmail.com> wrote:
>
> Hi
>
> I'm trying to handle the input of a stylus on a tablet. Qt has an example on how to do this using a QWidget-based application. I tested it on my tablet and everything works fine.
>
> I would like to do this in QML/QtQuick. The documentation suggests that PointHandler, like this:
>
> import QtQuick 2.14
> import QtQuick.Window 2.14
>
> Window {
> visible: true
> width: 640
> height: 480
> title: qsTr("Hello World")
>
> PointHandler
> {
> acceptedDevices: PointerDevice.Stylus
> acceptedPointerTypes: PointerDevice.Pen
> onActiveChanged: console.log("Pen Input")
> }
>
> }
It should work in 5.15: see also QTBUG-79660 and the tablet manual test in qtdeclarative/tests/manual/pointer.
> I experimented with eventFilter's to intercept QTabletEvent's before they are converted into mouse events by the QQuickWindow (as far as I can tell). But unless there is a QWidget with WA_TabletTracking=true as target (and some other options as it seems, because just a QMainWindow with a widget isn't enough) I can't recieve TabletEnterProximity-events for hovering.
Those are currently not delivered to the main window, only to the application. So you still need a C++ subclass in Qt 5, as in qtbase/examples/widgets/widgets/tablet/tabletapplication.cpp. I’m hoping to get more complete proximity event delivery in place in Qt 6.
More information about the Interest
mailing list