For checking tablet mode you can use bool QWindowsWindowFunctions::isTabletMode()
static function which is introduced in Qt 5.9. For enabling virtual keyboard in table mode and disabling in desktop mode you can periodically check it in a timer and show/hide InputPanel
respectively:
InputPanel {
id: inputPanel
property bool enableKeyboard: false
...
states: State {
name: "visible"
when: enableKeyboard && inputPanel.active
PropertyChanges {
target: inputPanel
y: appContainer.height - inputPanel.height
}
}
...
}
enableKeyboard
property is defined to activate/deactivate keyboard and it should be updated regularly using a Timer
like:
Timer {
onTriggered: enableKeyboard = utils.isTabletMode()
running: true
repeat: true
interval: 1000
}
You should define isTabletMode
function in a QObject
based class like:
#include <QtPlatformHeaders/QWindowsWindowFunctions>
...
Q_INVOKABLE bool isTabletMode() {
return QWindowsWindowFunctions::isTabletMode();
}
Do not forget to expose you class to qml by:
qmlengine->rootContext()->setContextProperty("utils", pointerToMyClass);