How to use virtual keyboard on Raspberry Pi 4
-
# virtualKeyboard static { QTPLUGIN += qtvirtualkeyboardplugin QT += svg } int main(int argc, char* argv[]) { // [가상 키보드] qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard")); }
I am developing with Qwidget.
Please tell me how to use virtual keyboard
I've tried several ways, but nothing happens. -
I'll add debug content. It seems to be working normally, but why doesn't the keyboard appear?
@IknowQT Got keys from plugin meta data ("qtvirtualkeyboard") QFactoryLoader::QFactoryLoader() checking directory path "/home/pi/Desktop/POP/platforminputcontexts" ... loaded library "/usr/local/qt5pi/plugins/platforminputcontexts/libqtvirtualkeyboardplugin.so" QFactoryLoader::QFactoryLoader() checking directory path "/usr/local/qt5pi/plugins/virtualkeyboard" ... QFactoryLoader::QFactoryLoader() looking at "/usr/local/qt5pi/plugins/virtualkeyboard/libqtvirtualkeyboard_hangul.so" Found metadata in lib /usr/local/qt5pi/plugins/virtualkeyboard/libqtvirtualkeyboard_hangul.so, metadata= { "IID": "org.qt-project.qt.virtualkeyboard.plugin/5.12", "MetaData": { "InputMethod": "HangulInputMethod", "Name": "hangul", "Provider": "Qt Hangul Extension", "Version": 100 }, "archreq": 0, "className": "QtVirtualKeyboardHangulPlugin", "debug": false, "version": 331520 } Got keys from plugin meta data () QFactoryLoader::QFactoryLoader() looking at "/usr/local/qt5pi/plugins/virtualkeyboard/libqtvirtualkeyboard_openwnn.so" Found metadata in lib /usr/local/qt5pi/plugins/virtualkeyboard/libqtvirtualkeyboard_openwnn.so, metadata= { "IID": "org.qt-project.qt.virtualkeyboard.plugin/5.12", "MetaData": { "InputMethod": "JapaneseInputMethod", "Name": "japanese", "Provider": "Qt OpenWNN Extension", "Version": 100 }, "archreq": 0, "className": "QtVirtualKeyboardOpenWnnPlugin", "debug": false, "version": 331520 } Got keys from plugin meta data () QFactoryLoader::QFactoryLoader() looking at "/usr/local/qt5pi/plugins/virtualkeyboard/libqtvirtualkeyboard_pinyin.so" Found metadata in lib /usr/local/qt5pi/plugins/virtualkeyboard/libqtvirtualkeyboard_pinyin.so, metadata= { "IID": "org.qt-project.qt.virtualkeyboard.plugin/5.12", "MetaData": { "InputMethod": "PinyinInputMethod", "Name": "pinyin", "Provider": "Qt Pinyin Extension", "Version": 100 }, "Version": 100 }, "archreq": 0, "className": "QtVirtualKeyboardPinyinPlugin", "debug": false, "version": 331520 } Got keys from plugin meta data () QFactoryLoader::QFactoryLoader() looking at "/usr/local/qt5pi/plugins/virtualkeyboard/libqtvirtualkeyboard_tcime.so" Found metadata in lib /usr/local/qt5pi/plugins/virtualkeyboard/libqtvirtualkeyboard_tcime.so, metadata= { "IID": "org.qt-project.qt.virtualkeyboard.plugin/5.12", "MetaData": { "InputMethod": "TCInputMethod", "Name": "traditional_chinese", "Provider": "Qt TCIME Extension", "Version": 100 }, "archreq": 0, "className": "QtVirtualKeyboardTCImePlugin", "debug": false, "version": 331520 } Got keys from plugin meta data () QFactoryLoader::QFactoryLoader() looking at "/usr/local/qt5pi/plugins/virtualkeyboard/libqtvirtualkeyboard_thai.so" Found metadata in lib /usr/local/qt5pi/plugins/virtualkeyboard/libqtvirtualkeyboard_thai.so, metadata= { "IID": "org.qt-project.qt.virtualkeyboard.plugin/5.12", "MetaData": { "InputMethod": "ThaiInputMethod", "Name": "thai", "Provider": "Qt Thai Extension", "Version": 100 }, "archreq": 0, "className": "QtVirtualKeyboardThaiPlugin", "debug": false, "version": 331520 } Got keys from plugin meta data () QFactoryLoader::QFactoryLoader() checking directory path "/home/pi/Desktop/POP/virtualkeyboard" ... loaded library "/usr/local/qt5pi/plugins/virtualkeyboard/libqtvirtualkeyboard_tcime.so" loaded library "/usr/local/qt5pi/plugins/virtualkeyboard/libqtvirtualkeyboard_hangul.so" loaded library "/usr/local/qt5pi/plugins/virtualkeyboard/libqtvirtualkeyboard_thai.so" loaded library "/usr/local/qt5pi/plugins/virtualkeyboard/libqtvirtualkeyboard_hangul.so" loaded library "/usr/local/qt5pi/plugins/virtualkeyboard/libqtvirtualkeyboard_thai.so" loaded library "/usr/local/qt5pi/plugins/virtualkeyboard/libqtvirtualkeyboard_openwnn.so" loaded library "/usr/local/qt5pi/plugins/virtualkeyboard/libqtvirtualkeyboard_pinyin.so" QFactoryLoader::QFactoryLoader() checking directory path "/usr/local/qt5pi/plugins/styles" ... QFactoryLoader::QFactoryLoader() checking directory path "/home/pi/Desktop/POP/styles" ... QFactoryLoader::QFactoryLoader() checking directory path "/usr/local/qt5pi/plugins/iconengines" ... QFactoryLoader::QFactoryLoader() looking at "/usr/local/qt5pi/plugins/iconengines/libqsvgicon.so" Found metadata in lib /usr/local/qt5pi/plugins/iconengines/libqsvgicon.so, metadata= { "IID": "org.qt-project.Qt.QIconEngineFactoryInterface", "MetaData": { "Keys": [ "svg", "svgz", "svg.gz" ] }, "archreq": 0, "className": "QSvgIconPlugin", "debug": false, "version": 331520 }
-
@IknowQT said in How to use virtual keyboard on Raspberry Pi 4:
I am developing with Qwidget.
Please tell me how to use virtual keyboard
I've tried several ways, but nothing happens.The keyboard is normally hidden until an input widget (like QLineEdit) receives focus.
It might be useful to download and run the example code: https://github.com/qt/qtvirtualkeyboard/tree/dev/examples/virtualkeyboard/basic
-
I saw this example too, but things are a little different
My development environment is QWidget and the example is qmlDo I have to use the virtual keyboard by using qml?
Are there any examples of using virtual keyboard in qwidget?When running on Ubuntu, the keyboard works normally. However, when I put it on the Raspberry Pi 4 board, it does not appear.
-
@IknowQT said in How to use virtual keyboard on Raspberry Pi 4:
When running on Ubuntu, the keyboard works normally. However, when I put it on the Raspberry Pi 4 board, it does not appear.
Do a sanity check first: Try to run the QML example on your Raspberry Pi.
-
@IknowQT said in How to use virtual keyboard on Raspberry Pi 4:
I tried the example called basic.
The virtual keyboard works normally.OK, that's good.
Now, modify that example code: Convert the
QGuiApplication
into aQApplication
, and then create + show aQTextEdit
. What happens when you click on the QTextEdit? What happens when you click on one of the fields in the QQuickView? -
Do you run your app with EGLFS plugin? It only supports single window IIRC, so the virtual keyboard can't get itself shown. Switch to X11 and it will show up, same as on Ubuntu.
I may be totally wrong about it though :D
-
Is there a way to check whether it is eglfs or x11?
I am not very good at Linux.===============================================
I tried the option to change the qt platform.
export QT_QPA_PLATFORM="x11"qt.qpa.plugin: Could not find the Qt platform plugin "x11" in "" This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem. Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, webgl, xcb.
Do I need to install x11?
Is there a command to find out which platform is currently set? -
@IknowQT said in How to use virtual keyboard on Raspberry Pi 4:
Is there a way to check whether it is eglfs or x11?
Your plugin debug output will show which platform plugin was loaded.
I tried the option to change the qt platform.
export QT_QPA_PLATFORM="x11"Use QT_QPA_PLATFORM="xcb"
-
@IknowQT said in How to use virtual keyboard on Raspberry Pi 4:
I tried again after changing to xcb platform, but the virtual keyboard still does not work.
See my earlier post:
Now, modify that example code: Convert the
QGuiApplication
into aQApplication
, and then create + show aQTextEdit
. What happens when you click on the QTextEdit? What happens when you click on one of the fields in the QQuickView? -
#include <QQuickView> #include <QGuiApplication> #include <QQmlEngine> #include <QtWidgets/QApplication> int main(int argc, char *argv[]) { qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard")); QGuiApplication app(argc, argv); QApplication n = qobject_cast<QApplication>(app); QQuickView view(QString("qrc:/%2").arg(MAIN_QML)); if (view.status() == QQuickView::Error) return -1; view.setResizeMode(QQuickView::SizeRootObjectToView); view.show(); return app.exec(); }
Are you talking about converting QGuiApplication to QApplication?
An error occurs. >: -
@IknowQT said in How to use virtual keyboard on Raspberry Pi 4:
An error occurs. >:
And what is the error?
-
@IknowQT said in How to use virtual keyboard on Raspberry Pi 4:
QGuiApplication app(argc, argv);
QApplication n = qobject_cast<QApplication>(app);What is this actually?!
Why not simply
QApplication app(argc, argv);
?
-
@jsulm
I didn't quite understand what you mean to convert QguiApplication.@JKSH
The keyboard works normally when you follow the steps you mentioned.int main(int argc, char *argv[]) { qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard")); QApplication app(argc, argv); //QApplication app2 = static_cast<QApplication>(app); QQuickView view(QString("qrc:/%2").arg(MAIN_QML)); if (view.status() == QQuickView::Error) return -1; view.setResizeMode(QQuickView::SizeRootObjectToView); view.show(); return app.exec(); }
-
@IknowQT said in How to use virtual keyboard on Raspberry Pi 4:
The keyboard works normally when you follow the steps you mentioned.
I also said:
...create + show a QTextEdit. What happens when you click on the QTextEdit? What happens when you click on one of the fields in the QQuickView?
-
-
@IknowQT said in How to use virtual keyboard on Raspberry Pi 4:
I tried what you did, the result is that once you click on lineedit made into widget the keyboard appears
...
It seems certain that the keyboard reacts when lineEdit is clicked.
Great! You now have Qt Virtual Keyboard working with a QWidget.
However, the keyboard appears within the quick screen UI area.
I'm not sure what you mean -- the keyboard is always meant to appear in the bottom half of the screen.