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. qtvirtualkeyboard not registering keys correctly

qtvirtualkeyboard not registering keys correctly

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
5 Posts 2 Posters 1.0k Views
  • 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.
  • fcarneyF Offline
    fcarneyF Offline
    fcarney
    wrote on last edited by
    #1

    This is the strangest issue I have seen with qml. We have data entry widgets in qml that when you click on them they will bring up the virtual keyboard as expected. However, when trying to press keys on the keyboard the widget will not register a press. However, if you put your finger somewhere else on the touchscreen and then press a key on the keyboard it will register. Is there some sort of multitouch attribute or option on the virtualkeyboard?

    C++ is a perfectly valid school of magic.

    1 Reply Last reply
    0
    • fcarneyF Offline
      fcarneyF Offline
      fcarney
      wrote on last edited by
      #2

      I was able to reproduce this issue. I do not know if this is good code to begin with, but the following will reliably show the problem we are seeing in our other app.

      In order to quit you will have to alt-f4, or whatever the close app keypress is on your system.

      You will find after clicking in the text area that you cannot use the virtualkeyboard to enter values unless you simultaneously press somewhere else on the screen at the same time. This requires a touchscreen to see this. Mouse clicks work just fine.

      main.cpp:

      #include <QGuiApplication>
      #include <QApplication>
      #include <QQmlApplicationEngine>
      #include <QDir>
      #include <QQmlComponent>
      #include <QDebug>
      #include <QMainWindow>
      #include <QQuickWidget>
      
      int main(int argc, char *argv[])
      {
          qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
      
          QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
      
          QApplication app(argc, argv);
      
          QMainWindow *m_MainWindow = new QMainWindow();
          m_MainWindow->setWindowFlags(Qt::FramelessWindowHint);
          m_MainWindow->setAttribute(Qt::WA_NoSystemBackground);
          m_MainWindow->setAttribute(Qt::WA_OpaquePaintEvent);
          QQuickWidget *m_QuickWidget = new QQuickWidget(m_MainWindow);
      
          m_QuickWidget->setSource(QUrl("qrc:/startup.qml"));
          m_MainWindow->showFullScreen();
      
          return app.exec();
      }
      

      startup.qml:

      import QtQuick 2.2
      import QtQuick.Window 2.2
      import QtQuick.Controls 1.3
      import QtGraphicalEffects 1.0
      import QtQuick.VirtualKeyboard 2.1
      import QtQuick.Dialogs 1.2
      
      Item {
          id: startup
          visible: true
          width: 1920
          height: 1080
      
          StackView {
              id: startup_stack
              anchors.fill: parent
              focus: true
              initialItem: main_view
      
              delegate: StackViewDelegate {
                  pushTransition: StackViewTransition {
                          PropertyAnimation {
                              target: enterItem
                              property: "opacity"
                              from: 0
                              to: 1
                              duration: 500
                          }
                      PropertyAnimation {
                          target: exitItem
                          property: "opacity"
                          from: 1
                          to: 0
                          duration: 100
                      }
                  }
              }
          }
      
          Component {
              id: main_view
              TextInput {
                  width: 320
                  height: 50
      
                  text: "Default"
              }
          }
      
          VirtualKB_def {}
      }
      

      VirtualKB_def.qml:

      import QtQuick 2.9
      import QtQuick.VirtualKeyboard 2.2
      import QtQuick.VirtualKeyboard.Settings 2.2
      
      InputPanel {
          id: inputPanel
          z: 99
          x: 0
          y: parent.height
          width: parent.width
      
          //Component.onCompleted: VirtualKeyboardSettings.styleName = "retro"
          //Component.onCompleted: VirtualKeyboardSettings.styleName = "test"
      
          states: State {
              name: "visible"
              when: inputPanel.active
              PropertyChanges {
                  target: inputPanel
                  y: parent.height - inputPanel.height
              }
          }
          transitions: Transition {
              from: ""
              to: "visible"
              reversible: true
              ParallelAnimation {
                  NumberAnimation {
                      properties: "y"
                      duration: 250
                      easing.type: Easing.InOutQuad
                  }
              }
          }
      }
      

      C++ is a perfectly valid school of magic.

      F 1 Reply Last reply
      0
      • fcarneyF fcarney

        I was able to reproduce this issue. I do not know if this is good code to begin with, but the following will reliably show the problem we are seeing in our other app.

        In order to quit you will have to alt-f4, or whatever the close app keypress is on your system.

        You will find after clicking in the text area that you cannot use the virtualkeyboard to enter values unless you simultaneously press somewhere else on the screen at the same time. This requires a touchscreen to see this. Mouse clicks work just fine.

        main.cpp:

        #include <QGuiApplication>
        #include <QApplication>
        #include <QQmlApplicationEngine>
        #include <QDir>
        #include <QQmlComponent>
        #include <QDebug>
        #include <QMainWindow>
        #include <QQuickWidget>
        
        int main(int argc, char *argv[])
        {
            qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
        
            QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
        
            QApplication app(argc, argv);
        
            QMainWindow *m_MainWindow = new QMainWindow();
            m_MainWindow->setWindowFlags(Qt::FramelessWindowHint);
            m_MainWindow->setAttribute(Qt::WA_NoSystemBackground);
            m_MainWindow->setAttribute(Qt::WA_OpaquePaintEvent);
            QQuickWidget *m_QuickWidget = new QQuickWidget(m_MainWindow);
        
            m_QuickWidget->setSource(QUrl("qrc:/startup.qml"));
            m_MainWindow->showFullScreen();
        
            return app.exec();
        }
        

        startup.qml:

        import QtQuick 2.2
        import QtQuick.Window 2.2
        import QtQuick.Controls 1.3
        import QtGraphicalEffects 1.0
        import QtQuick.VirtualKeyboard 2.1
        import QtQuick.Dialogs 1.2
        
        Item {
            id: startup
            visible: true
            width: 1920
            height: 1080
        
            StackView {
                id: startup_stack
                anchors.fill: parent
                focus: true
                initialItem: main_view
        
                delegate: StackViewDelegate {
                    pushTransition: StackViewTransition {
                            PropertyAnimation {
                                target: enterItem
                                property: "opacity"
                                from: 0
                                to: 1
                                duration: 500
                            }
                        PropertyAnimation {
                            target: exitItem
                            property: "opacity"
                            from: 1
                            to: 0
                            duration: 100
                        }
                    }
                }
            }
        
            Component {
                id: main_view
                TextInput {
                    width: 320
                    height: 50
        
                    text: "Default"
                }
            }
        
            VirtualKB_def {}
        }
        

        VirtualKB_def.qml:

        import QtQuick 2.9
        import QtQuick.VirtualKeyboard 2.2
        import QtQuick.VirtualKeyboard.Settings 2.2
        
        InputPanel {
            id: inputPanel
            z: 99
            x: 0
            y: parent.height
            width: parent.width
        
            //Component.onCompleted: VirtualKeyboardSettings.styleName = "retro"
            //Component.onCompleted: VirtualKeyboardSettings.styleName = "test"
        
            states: State {
                name: "visible"
                when: inputPanel.active
                PropertyChanges {
                    target: inputPanel
                    y: parent.height - inputPanel.height
                }
            }
            transitions: Transition {
                from: ""
                to: "visible"
                reversible: true
                ParallelAnimation {
                    NumberAnimation {
                        properties: "y"
                        duration: 250
                        easing.type: Easing.InOutQuad
                    }
                }
            }
        }
        
        F Offline
        F Offline
        fanat9
        wrote on last edited by
        #3

        @fcarney Hit same issue. Did you solve it by any chance? Thanks in advance!

        fcarneyF 1 Reply Last reply
        0
        • F fanat9

          @fcarney Hit same issue. Did you solve it by any chance? Thanks in advance!

          fcarneyF Offline
          fcarneyF Offline
          fcarney
          wrote on last edited by
          #4

          @fanat9 Honestly I don't remember. We took a different route since then. Also using a different version of Qt now. 5.12 instead of 5.9 (or whatever we were using).

          C++ is a perfectly valid school of magic.

          F 1 Reply Last reply
          0
          • fcarneyF fcarney

            @fanat9 Honestly I don't remember. We took a different route since then. Also using a different version of Qt now. 5.12 instead of 5.9 (or whatever we were using).

            F Offline
            F Offline
            fanat9
            wrote on last edited by
            #5

            @fcarney I'm trying 5.13.2 atm. Could you please look into your old sources if you still have them.

            1 Reply Last reply
            0

            • Login

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