[Interest] Handling stylus input on a tablet in QML/QtQuick

Thorsten Hofer-Schmitz thorsten.schmitz.bn.90 at gmail.com
Sun Apr 19 01:16:40 CEST 2020


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")
     }

}

But it doesn't work, and I can't find out how to make it work.

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.

Does someone know how to do this?

Regards

Thorsten


More information about the Interest mailing list