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. Settings.hasTouchScreen returns false
Qt 6.11 is out! See what's new in the release blog

Settings.hasTouchScreen returns false

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 813 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.
  • DiracsbracketD Offline
    DiracsbracketD Offline
    Diracsbracket
    wrote on last edited by Diracsbracket
    #1

    Hi.
    I am trying to find out why flicking is not working with a TreeView example on my Raspberry Pi3 with touch screen.

    Looking at the qml code of TreeView.qml, e.g.
    https://github.com/RSATom/Qt/blob/master/qtquickcontrols/src/controls/TreeView.qml:

    BasicTableView {
    ...
        __mouseArea: MouseArea {
            id: mouseArea
    
            parent: __listView
            width: __listView.width
            height: __listView.height
            z: -1
            propagateComposedEvents: true
            focus: true
            // If there is not a touchscreen, keep the flickable from eating our mouse drags.
            // If there is a touchscreen, flicking is possible, but selection can be done only by tapping, not by dragging.
            preventStealing: !Settings.hasTouchScreen
            ...
         }
    }
    

    By similarly looking at the qml code for BasicTableView.qml, it seems that behavior is controlled by Settings.hasTouchScreen

    According to:
    https://code.woboq.org/qt5/qtquickcontrols/src/controls/Private/qquickcontrolsettings.cpp.html
    it corresponds to the following method:

    bool QQuickControlSettings1::hasTouchScreen() const
    {
        const auto devices = QTouchDevice::devices();
        for (const QTouchDevice *dev : devices)
            if (dev->type() == QTouchDevice::TouchScreen)
                return true;
        return false;
    }
    

    However, in my case, Settings.hasTouchScreen returns false; i.e. the touch screen (although working for the rest), is not
    correctly detected by the QML environment, which probably explains why the flicking does not work.

    According to https://doc.qt.io/qt-5/qtouchdevice.html, my touch device should have been registered somehow by the private QWindowSystemInterface::registerTouchDevice() method, but wasn't.

    How can I get this to work?
    Thanks!

    1 Reply Last reply
    0
    • DiracsbracketD Offline
      DiracsbracketD Offline
      Diracsbracket
      wrote on last edited by Diracsbracket
      #2

      It seems things don't work correctly when using tslib as plugin?

      In any case, when using the evdevtouch plugin instead
      https://doc.qt.io/qt-5/embedded-linux.html

      and adding the following test code in my main():

       //TEST TO SEE IF TOUCH DEVICE IS REGISTERED.
       const auto devices = QTouchDevice::devices();
       qDebug() << "************** devices.length(): " << devices.length();
      
       for (const QTouchDevice *dev : devices)
           qDebug() << "**************** dev->type():" << dev->type();
      

      produced:

      __logging_message__06:19:51.871 DEBUG unknown                          ************** devices.length():  1
      __logging_message__06:19:51.872 DEBUG unknown                          **************** dev->type(): QTouchDevice::TouchScreen
      

      And with the device now correctly reported, also the Settings.hasTouchScreen property in QML is correctly set and the flicking of the TreeView working.

      1 Reply Last reply
      0

      • Login

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