Resize VirtualKeyboard ing QWidget
-
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.
-
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 :)
-
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.
@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
keyboardDesignMaximumHeightproperty: 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-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
keyboardDesignMaximumHeightproperty: 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 )
@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
-
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 } } -
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 :)
-
J Joe von Habsburg has marked this topic as solved
-
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 :)
@Joe-von-Habsburg Neat trick! Thanks for sharing.
You can replace the
Bindingobject with a single line:Component.onCompleted: keyboard.style.keyboardDesignMaximumHeight = 300 -
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.
-
How ? I do not know qml. Could you give an example ?
-
Hi,
You can find an example in this StackOverflow answer.
-
thanks you @SGaist