Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Resize QtVirtualKeyboard in QtWidgets App

Resize QtVirtualKeyboard in QtWidgets App

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
8 Posts 2 Posters 1.4k 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.
  • D Offline
    D Offline
    Deneguil
    wrote on last edited by
    #1

    I recently managed to install the QtVirtualKeyboard on my raspberry pi for my embedded app (thank you again for the person that helped me). However now, the keyboard takes the entire window size and blocks of the view of the App 732cae8c-139a-403d-ad4a-0fee45879671-image.png

    I tried adding an inputPanel.qml file to my project and writing

    import QtQuick 2.0
    import QtQuick.VirtualKeyboard 2.1
    
    Item {
       id: root
       InputPanel {
            id: inputPanel
            width: parent.width
            height: parent.height/3;
            y: Qt.inputMethod.visible ? parent.height - inputPanel.height : parent.height
            anchors.left: parent.left
            anchors.right: parent.right
        }
    }
    

    But it doesn't change anything.
    I'm using QtCreator and Qt 5.15.2, does anyone know where I went wrong and how I can embed the keyboard in my application using either QML or C++ ?

    1 Reply Last reply
    0
    • JoeCFDJ Offline
      JoeCFDJ Offline
      JoeCFD
      wrote on last edited by JoeCFD
      #2

      you may not want to display it within your layout which can be too small. Instead show it on top of all widgets. Your mainWindow may have a different name.
      And you can add some animation as well.

          z: 99
          x: 0
          y:  Qt.inputMethod.visible ? mainWindow.height - inputPanel.height * 0.925 :  mainWindow.height  
          width: mainWindow.width
      

      anchors are not needed.

      D 1 Reply Last reply
      0
      • JoeCFDJ JoeCFD

        you may not want to display it within your layout which can be too small. Instead show it on top of all widgets. Your mainWindow may have a different name.
        And you can add some animation as well.

            z: 99
            x: 0
            y:  Qt.inputMethod.visible ? mainWindow.height - inputPanel.height * 0.925 :  mainWindow.height  
            width: mainWindow.width
        

        anchors are not needed.

        D Offline
        D Offline
        Deneguil
        wrote on last edited by
        #3

        @JoeCFD so just

        InputPanel {
            id: inputPanel
            z: 99
            x: 0
            y:  Qt.inputMethod.visible ? mainWindow.height - inputPanel.height * 0.925 :  mainWindow.height
            width: mainWindow.width
        }
        

        in the qml file?
        Also I'm assuming I need to load it somehow since it's not changing anything either. I'm pretty new to Qt as a whole and did everything using the .ui file and C++ so far so I don't really know how to add the qml nicely

        JoeCFDJ 1 Reply Last reply
        0
        • D Deneguil

          @JoeCFD so just

          InputPanel {
              id: inputPanel
              z: 99
              x: 0
              y:  Qt.inputMethod.visible ? mainWindow.height - inputPanel.height * 0.925 :  mainWindow.height
              width: mainWindow.width
          }
          

          in the qml file?
          Also I'm assuming I need to load it somehow since it's not changing anything either. I'm pretty new to Qt as a whole and did everything using the .ui file and C++ so far so I don't really know how to add the qml nicely

          JoeCFDJ Offline
          JoeCFDJ Offline
          JoeCFD
          wrote on last edited by JoeCFD
          #4

          @Deneguil Yes. Does it work? If not, try

          InputPanel {
              id: inputPanel
              z: 99
              x: 0
              y:  inputPanel.active ? mainWindow.height - inputPanel.height * 0.925 :  mainWindow.height
              width: mainWindow.width
          }
          

          you also need to add the following env in your main before QApplication is created.
          qputenv( "QT_IM_MODULE", QByteArray( "qtvirtualkeyboard" ) );

          D 1 Reply Last reply
          0
          • JoeCFDJ JoeCFD

            @Deneguil Yes. Does it work? If not, try

            InputPanel {
                id: inputPanel
                z: 99
                x: 0
                y:  inputPanel.active ? mainWindow.height - inputPanel.height * 0.925 :  mainWindow.height
                width: mainWindow.width
            }
            

            you also need to add the following env in your main before QApplication is created.
            qputenv( "QT_IM_MODULE", QByteArray( "qtvirtualkeyboard" ) );

            D Offline
            D Offline
            Deneguil
            wrote on last edited by
            #5

            @JoeCFD It's still taking up the entire window space. I think the qml file isn't taken into consideration at all do I need to add something in my main.cpp as well?

            #include "mainwindow.h"
            
            
            #include <QApplication>
            #include <QQmlApplicationEngine>
            
            
            int main(int argc, char *argv[])
            {
                qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
                QApplication a(argc, argv);
            
            
            
                MainWindow w;
                w.showFullScreen();
                //w.show();
                return a.exec();
            }
            
            1 Reply Last reply
            0
            • JoeCFDJ Offline
              JoeCFDJ Offline
              JoeCFD
              wrote on last edited by JoeCFD
              #6

              TextInput and InputPanel are created at the same time.

              Rectangle {
                  id: ***
                  color: "-----"
                  border.width: 1
                  border.color: "white"
              
                  TextInput {
                  }
              
                  InputPanel {
                 }
              }
              
              D 1 Reply Last reply
              0
              • JoeCFDJ JoeCFD

                TextInput and InputPanel are created at the same time.

                Rectangle {
                    id: ***
                    color: "-----"
                    border.width: 1
                    border.color: "white"
                
                    TextInput {
                    }
                
                    InputPanel {
                   }
                }
                
                D Offline
                D Offline
                Deneguil
                wrote on last edited by
                #7

                @JoeCFD It doesn't work either :/
                How could I load a QML file even though my MainWindow is the base of my application? I think the QML isn't read

                1 Reply Last reply
                0
                • JoeCFDJ Offline
                  JoeCFDJ Offline
                  JoeCFD
                  wrote on last edited by JoeCFD
                  #8

                  I thought you know how to load it. Read it
                  http://qmlbook.github.io/
                  and
                  https://doc.qt.io/qt-6/qtquick-codesamples.html

                  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