qtvirtualkeyboard in QWidget App
-
My QWidget based -none QML- app has a mainwindow and several forms.
I use Qt5.15.8 and gcc or clang to compile it.
I googled now for 2 days and tried to understand the abstract documentation given.QT_IM_MODULE is set
qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));before creating
QApplication a(argc, argv);I also did overwrite the focusInEvent of a created subclass myLineEdit
mylineedit.h:#include <QLineEdit> #include <QWidget> class myLineEdit : public QLineEdit { Q_OBJECT public: //myLineEdit(); explicit myLineEdit(QWidget *parent = nullptr); protected: void focusInEvent(QFocusEvent *); void focusOutEvent(QFocusEvent *); };with mylineedit.cpp:
myLineEdit::myLineEdit(QWidget *parent) : QLineEdit(parent) { } void myLineEdit::focusInEvent(QFocusEvent *) { qWarning() << "myLineEdit :FocusInEvent activates kbd"; setAttribute(Qt::WA_InputMethodEnabled, true); QApplication::inputMethod()->show(); } void myLineEdit::focusOutEvent(QFocusEvent *) { qWarning() << "myLineEdit :FocusOutEvent hides kbd"; QApplication::inputMethod()->hide(); }Running the app for desktop it shows the vkbd.
Running the cross compiled app on target, it don't.
The basic example does run fine on the target.I did try to integrate a .qml file in my app to make define an input panel, like documentation requested. So far i came up with:
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 } }Currently i suspect that there might be an additional input.Method needed.
Does anybody can point me in the right direction. (QML curses would help, i know)Thanks, appreciate it.
-
the whole idea of integrating a Qt Virtual keyboard in a QWidget might be not a great one.
I found QQuickWidget and QQuickView attempts which both deal with integrating qml code into
your QWidget application.But I couldn't find a way to only use the qt virtual keyboard without rewriting the ui then.
Well at this point i don't understand the documentation under:
https://doc.qt.io/qt-5/qtvirtualkeyboard-index.html
where it says:Supports both Qt Quick and Qt Widgets applications.
How is that feature meant?