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. Problem with virtual keyboard in WASM

Problem with virtual keyboard in WASM

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 612 Views 2 Watching
  • 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.
  • A Offline
    A Offline
    apaczenko1993
    wrote on last edited by
    #1

    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);
                        }
                    }
                }```
    JKSHJ 1 Reply Last reply
    0
    • A Offline
      A Offline
      apaczenko1993
      wrote on last edited by
      #4

      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

      1 Reply Last reply
      1
      • A apaczenko1993

        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);
                            }
                        }
                    }```
        JKSHJ Offline
        JKSHJ Offline
        JKSH
        Moderators
        wrote on last edited by
        #2

        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
        )
        

        See https://bugreports.qt.io/browse/QTBUG-123308

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        1 Reply Last reply
        1
        • A Offline
          A Offline
          apaczenko1993
          wrote on last edited by
          #3

          Hi JKSH, you mean add in cmakeLists file but I will have second question, how it should look when I use qmake, not cmake?

          1 Reply Last reply
          0
          • A Offline
            A Offline
            apaczenko1993
            wrote on last edited by
            #4

            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

            1 Reply Last reply
            1
            • A apaczenko1993 has marked this topic as solved on
            • A apaczenko1993 has marked this topic as solved on

            • Login

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