Settings.hasTouchScreen returns false
-
Hi.
I am trying to find out why flicking is not working with aTreeView
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 bySettings.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
returnsfalse
; 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! -
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.htmland 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 theTreeView
working.