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 use PointerDevice
Forum Updated to NodeBB v4.3 + New Features

How to use PointerDevice

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
pointerdevicepointereventpointerhandlerstyluspen
1 Posts 1 Posters 341 Views
  • 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.
  • L Offline
    L Offline
    larkei15
    wrote on 15 Oct 2019, 14:17 last edited by
    #1

    Hello all,

    I am trying to detect when a stylus (such as a surface pen or apple pencil) is being used for input in my application using only QML. I see there is a PointerDevice type (https://doc.qt.io/qt-5/qml-qtquick-pointerdevice.html) that I can get the device type from. I can access the PointerDevice from a PointerEvent, but the problem is the only place in the documentation that seems to show how to get a PointerEvent is from the tapped event of TapHandler. Even then, the documentation doesn't explicitly say that the event property is a PointerEvent, it just says it is an object, however, in the example code it shows there being a device property of this event. Anyway, I cannot use the TapHandler because I want to detect the device type without releasing and long presses don't emit the PointerEvent with the longPressed signal.

    The workaround that I tried is by making a PointHandler that only accepts PointerDevice.Pen and when I handle the pressed signal in a MouseArea, I check to see if the PointHandler is active. It does detect when the PointHandler is active with not specified pointer type, but it's never activating when I force it to look for only PointerDevice.Pen. I am having a lot of trouble debugging this because I have no way of seeing what device type it is detecting the stylus as, because the stylus doesn't activate the PointHandler when I force it to accept only PointerDevice.Finger input.

    It is extremely frustrating that the PointerEvent could supply me with the functionality to do exactly what I need, but there seems to be no way to access it within the limited documentation.

    Any help would be greatly appreciated.

    Thanks,
    Keith

    1 Reply Last reply
    0

    1/1

    15 Oct 2019, 14:17

    • Login

    • Login or register to search.
    1 out of 1
    • First post
      1/1
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved