Problem with virtual keyboard in WASM
-
Hello
I have created program in QML but I have problem with virtual keyboard. When I compile application with MinGW, the keyboard work well, input capture works. But when I compile app with WebAssembly the virtual keyboard don't work, in debug info I have information that "input method is not set". How can I fix this?
My Qt is version is 6.5.3, EMS version is 3.1.25 like is written in doc.My code in QML:
InputPanel { id: inputPanel z: 1 x: 0 y: window.height width: window.width / 1.3 externalLanguageSwitchEnabled: false anchors.left: parent.left states: State { name: "visible" when: inputPanel.active PropertyChanges { target: inputPanel y: window.height - inputPanel.height } } transitions: Transition { from: "" to: "visible" reversible: true ParallelAnimation { NumberAnimation { properties: "y" duration: 450 easing.type: Easing.InOutQuad } } } } TextInput { id: smed2_input height: (window.height * 30) / 730 width: (window.height * 250) / 730 font.pixelSize: (window.height * 25) / 730 validator: RegularExpressionValidator { regularExpression: /^[0-9\+\-\#\*\ ]{6,}$/ } inputMethodHints: Qt.ImhDialableCharactersOnly anchors.bottom: inputPanel.top anchors.bottomMargin: 30 anchors.left: rectangle.right anchors.leftMargin: (window.height * 330) / 730 maximumLength: 3 onFocusChanged: { console.log("SMED2 FOCUS: " + focus) if (smed_input.focus === true || smed2_input.focus === true) { console.log("Pokazuje input") inputPanel.active = true Qt.inputMethod.show(); // Wymuszenie pokazania klawiatury } else{ console.log("chowam") inputPanel.active = false Qt.inputMethod.hide(); } } onTextChanged: { if (smed2_input.text.length >= 0) { console.log("Mamy SMED: " + smed2_input.text); if (row.children.length !== 0) { for (var i = row.children.length; i > 0; i--) { console.log("destroying: " + i); row.children[i - 1].destroy(); } } console.log("Ilosc obiektow po destory: " + row.children.length); console.log("Z nr czesci: " + smed2_input.text); smedBackend.loadSMEDListSMED(liniaMaster, stanowiskoMaster, smed2_input.text); } } } TextInput { id: smed_input height: (window.height * 30) / 730 width: (window.height * 250) / 730 font.pixelSize: (window.height * 25) / 730 inputMethodHints: Qt.ImhUppercaseOnly anchors.bottom: inputPanel.top anchors.bottomMargin: 30 anchors.left: rectangle.right anchors.leftMargin: (window.height * 30) / 730 maximumLength: 15 onFocusChanged: { console.log("SMED1 FOCUS: " + focus) if (smed_input.focus === true || smed2_input.focus === true) { console.log("Pokazuje input") inputPanel.active = true Qt.inputMethod.show(); // Wymuszenie pokazania klawiatury } else{ console.log("chowam") inputPanel.active = false Qt.inputMethod.hide(); } } onTextChanged: { if (smed_input.text.length >= 0) { if (row.children.length !== 0) { for (var i = row.children.length; i > 0; i--) { console.log("destroying: " + i); row.children[i - 1].destroy(); } } console.log("Ilosc obiektow po destory: " + row.children.length); console.log("Z nr czesci: " + smed_input.text); smedBackend.loadSMEDListArt(liniaMaster, stanowiskoMaster, smed_input.text); } } }```
-
For other persons, in pro file:
static { QT += svg QTPLUGIN += qtvirtualkeyboardplugin }
and in main.cpp
#include <QtVirtualKeyboard> qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
with this VKB works well
-
Hello @apaczenko1993, WASM uses static linking so you must manually add the VKB plugin:
qt_import_plugins(my_app_target INCLUDE_BY_TYPE platforminputcontexts Qt::QVirtualKeyboardPlugin )
-
Hi JKSH, you mean add in cmakeLists file but I will have second question, how it should look when I use qmake, not cmake?
-
For other persons, in pro file:
static { QT += svg QTPLUGIN += qtvirtualkeyboardplugin }
and in main.cpp
#include <QtVirtualKeyboard> qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
with this VKB works well
-
-