Resize QtVirtualKeyboard in QtWidgets App
-
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

I tried adding an
inputPanel.qmlfile to my project and writingimport 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++ ? -
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.widthanchors are not needed.
-
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.widthanchors are not needed.
@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 -
@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@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" ) ); -
@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" ) );@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(); } -
TextInput and InputPanel are created at the same time.
Rectangle { id: *** color: "-----" border.width: 1 border.color: "white" TextInput { } InputPanel { } } -
I thought you know how to load it. Read it
http://qmlbook.github.io/
and
https://doc.qt.io/qt-6/qtquick-codesamples.html