Settings.hasTouchScreen returns false

  • 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.

    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:
    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, my touch device should have been registered somehow by the private QWindowSystemInterface::registerTouchDevice() method, but wasn't.

    How can I get this to work?

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

    In any case, when using the evdevtouch plugin instead

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

     const auto devices = QTouchDevice::devices();
     qDebug() << "************** devices.length(): " << devices.length();
     for (const QTouchDevice *dev : devices)
         qDebug() << "**************** dev->type():" << dev->type();


    __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.

Log in to reply