Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Resize VirtualKeyboard ing QWidget
Qt 6.11 is out! See what's new in the release blog

Resize VirtualKeyboard ing QWidget

Scheduled Pinned Locked Moved Solved General and Desktop
virtualkeyboard
10 Posts 4 Posters 639 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.
  • Joe von HabsburgJ Offline
    Joe von HabsburgJ Offline
    Joe von Habsburg
    wrote last edited by
    #1

    I have a qwidget app and I have to use virtualkeyboard.

    I added to main.cpp

    qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
    

    and I tried "QT_VIRTUALKEYBOARD_SCALE_FACTOR " but it did not work.

    Why I need ? Because it is so big and its size is half height of my screen.

    I need help.

    JKSHJ 1 Reply Last reply
    0
    • Joe von HabsburgJ Offline
      Joe von HabsburgJ Offline
      Joe von Habsburg
      wrote last edited by
      #5
      import QtQuick
      import QtQuick.Window
      import QtQuick.VirtualKeyboard
      
      Window {
          id: root
          flags:  Qt.Tool | Qt.FramelessWindowHint | Qt.WindowDoesNotAcceptFocus | Qt.WindowStaysOnTopHint
          color:  "transparent"
          width:  Screen.width
          height: 300
          x: Screen.virtualX
          y: Screen.virtualY + Screen.height - height
      
          visible: inputPanel.active
      
          InputPanel {
              id: inputPanel
              width: parent.width
          }
      
          Binding {
              target:      inputPanel.keyboard.style
              property:    "keyboardDesignMaximumHeight"
              value:       300
              restoreMode: Binding.RestoreNone
          }
      }
      
      int main(int argc, char *argv[])
      {
          qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
          QApplication a(argc, argv);
      
          QQmlApplicationEngine engine;
          engine.load(QUrl(QStringLiteral("qrc:/keyboard.qml")));
      
          MainWindow w;
          w.show();
          return a.exec();
      }
      
      

      It works for me, any opinion for better view please comment :)

      JKSHJ 1 Reply Last reply
      0
      • Joe von HabsburgJ Joe von Habsburg

        I have a qwidget app and I have to use virtualkeyboard.

        I added to main.cpp

        qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
        

        and I tried "QT_VIRTUALKEYBOARD_SCALE_FACTOR " but it did not work.

        Why I need ? Because it is so big and its size is half height of my screen.

        I need help.

        JKSHJ Offline
        JKSHJ Offline
        JKSH
        Moderators
        wrote last edited by JKSH
        #2

        @Joe-von-Habsburg said in Resize VirtualKeyboard ing QWidget:

        it is so big and its size is half height of my screen

        Sounds like this issue: https://qt-project.atlassian.net/browse/QTBUG-128845

        The official solution (available from Qt 6.11 onwards) is to customize the keyboard style and set the keyboardDesignMaximumHeight property: https://doc.qt.io/qt-6/qml-qtquick-virtualkeyboard-styles-keyboardstyle.html#keyboardDesignMaximumHeight-prop

        (Unfortunately, this API is quite unwieldy and not well documented: https://qt-project.atlassian.net/browse/QTBUG-144131 )

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

        Joe von HabsburgJ 1 Reply Last reply
        2
        • JKSHJ JKSH

          @Joe-von-Habsburg said in Resize VirtualKeyboard ing QWidget:

          it is so big and its size is half height of my screen

          Sounds like this issue: https://qt-project.atlassian.net/browse/QTBUG-128845

          The official solution (available from Qt 6.11 onwards) is to customize the keyboard style and set the keyboardDesignMaximumHeight property: https://doc.qt.io/qt-6/qml-qtquick-virtualkeyboard-styles-keyboardstyle.html#keyboardDesignMaximumHeight-prop

          (Unfortunately, this API is quite unwieldy and not well documented: https://qt-project.atlassian.net/browse/QTBUG-144131 )

          Joe von HabsburgJ Offline
          Joe von HabsburgJ Offline
          Joe von Habsburg
          wrote last edited by Joe von Habsburg
          #3

          @JKSH said in Resize VirtualKeyboard ing QWidget:

          Sounds like this issue: https://qt-project.atlassian.net/browse/QTBUG-128845

          Yes I have same problem, but how could I solve the problem on this link, I could not understand.

          Note: I used 6.11.1 and this topic about 6.11, I changed to 6.9.3 and I saw same size problem on keyboard.

          @JKSH said in Resize VirtualKeyboard ing QWidget:

          The official solution (available from Qt 6.11 onwards) is to customize the keyboard style and set the keyboardDesignMaximumHeight property: https://doc.qt.io/qt-6/qml-qtquick-virtualkeyboard-styles-keyboardstyle.html#keyboardDesignMaximumHeight-prop

          Actually I do not know qml and I do not know how I use it.

          Thanks for your reply @JKSH

          1 Reply Last reply
          0
          • Joe von HabsburgJ Offline
            Joe von HabsburgJ Offline
            Joe von Habsburg
            wrote last edited by Joe von Habsburg
            #4

            I tried like that but it did not work

            int main(int argc, char *argv[])
            {
                qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
                QApplication a(argc, argv);
            
                QQmlApplicationEngine engine;
                engine.load(QUrl(QStringLiteral("qrc:/keyboard.qml")));
            
                MainWindow w;
                w.show();
                return a.exec();
            }
            
            import QtQuick
            import QtQuick.Window
            import QtQuick.VirtualKeyboard
            import QtQuick.VirtualKeyboard.Settings
            import QtQuick.VirtualKeyboard.Styles
            
            VirtualKeyboard {
                id: root
            
                KeyboardStyle {
                    keyboardDesignMaximumHeight: 300
                }
            
                InputPanel {
                    id: inputPanel
                    width: parent.width
                    anchors.bottom: parent.bottom
                }
            }
            
            
            1 Reply Last reply
            0
            • Joe von HabsburgJ Offline
              Joe von HabsburgJ Offline
              Joe von Habsburg
              wrote last edited by
              #5
              import QtQuick
              import QtQuick.Window
              import QtQuick.VirtualKeyboard
              
              Window {
                  id: root
                  flags:  Qt.Tool | Qt.FramelessWindowHint | Qt.WindowDoesNotAcceptFocus | Qt.WindowStaysOnTopHint
                  color:  "transparent"
                  width:  Screen.width
                  height: 300
                  x: Screen.virtualX
                  y: Screen.virtualY + Screen.height - height
              
                  visible: inputPanel.active
              
                  InputPanel {
                      id: inputPanel
                      width: parent.width
                  }
              
                  Binding {
                      target:      inputPanel.keyboard.style
                      property:    "keyboardDesignMaximumHeight"
                      value:       300
                      restoreMode: Binding.RestoreNone
                  }
              }
              
              int main(int argc, char *argv[])
              {
                  qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
                  QApplication a(argc, argv);
              
                  QQmlApplicationEngine engine;
                  engine.load(QUrl(QStringLiteral("qrc:/keyboard.qml")));
              
                  MainWindow w;
                  w.show();
                  return a.exec();
              }
              
              

              It works for me, any opinion for better view please comment :)

              JKSHJ 1 Reply Last reply
              0
              • Joe von HabsburgJ Joe von Habsburg has marked this topic as solved
              • Joe von HabsburgJ Joe von Habsburg
                import QtQuick
                import QtQuick.Window
                import QtQuick.VirtualKeyboard
                
                Window {
                    id: root
                    flags:  Qt.Tool | Qt.FramelessWindowHint | Qt.WindowDoesNotAcceptFocus | Qt.WindowStaysOnTopHint
                    color:  "transparent"
                    width:  Screen.width
                    height: 300
                    x: Screen.virtualX
                    y: Screen.virtualY + Screen.height - height
                
                    visible: inputPanel.active
                
                    InputPanel {
                        id: inputPanel
                        width: parent.width
                    }
                
                    Binding {
                        target:      inputPanel.keyboard.style
                        property:    "keyboardDesignMaximumHeight"
                        value:       300
                        restoreMode: Binding.RestoreNone
                    }
                }
                
                int main(int argc, char *argv[])
                {
                    qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
                    QApplication a(argc, argv);
                
                    QQmlApplicationEngine engine;
                    engine.load(QUrl(QStringLiteral("qrc:/keyboard.qml")));
                
                    MainWindow w;
                    w.show();
                    return a.exec();
                }
                
                

                It works for me, any opinion for better view please comment :)

                JKSHJ Offline
                JKSHJ Offline
                JKSH
                Moderators
                wrote last edited by
                #6

                @Joe-von-Habsburg Neat trick! Thanks for sharing.

                You can replace the Binding object with a single line:

                Component.onCompleted: keyboard.style.keyboardDesignMaximumHeight = 300
                

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

                1 Reply Last reply
                1
                • GrecKoG Offline
                  GrecKoG Offline
                  GrecKo
                  Qt Champions 2018
                  wrote last edited by
                  #7

                  The height of the keyboard is proportional to its width. So just setting that should also work.

                  Instead of a QQmlApplicationEngine and a floating top-level window I would have used a non-layouted QQuickWidget to instantiate the InputPanel since you are using QWidgets.

                  1 Reply Last reply
                  0
                  • Joe von HabsburgJ Offline
                    Joe von HabsburgJ Offline
                    Joe von Habsburg
                    wrote last edited by
                    #8

                    How ? I do not know qml. Could you give an example ?

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote last edited by
                      #9

                      Hi,

                      You can find an example in this StackOverflow answer.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      1
                      • Joe von HabsburgJ Offline
                        Joe von HabsburgJ Offline
                        Joe von Habsburg
                        wrote last edited by
                        #10

                        thanks you @SGaist

                        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