Need help to code VirtualKeyboard using QQuickWidget on Widget-based app



  • Hi everybody,
    I need to use the VirtualKeyboard on a Raspberry Pi 3 running in boot2qt. But my current application is based on widget (not QML). I saw (and read) that virtualKeyboard not working in that configuration. It is necessary to use QtQuick.
    So I need to code my one QLineEdit which integrate a QML code to open virtual keyboard and integrate it using QQuickWidget class. But because I'm a noob in QML I need some help.

    Anyone can help me?.. Thank you


  • Moderators

    @Foufy said in Need help to code VirtualKeyboard using QQuickWidget on Widget-based app:

    So I need to code my one QLineEdit which integrate a QML code to open virtual keyboard and integrate it using QQuickWidget class.

    this way you also wont be able to achieve what you want, since the focus scope is not shared between QML and QtWidgets.
    So even if you would be able to show the keyboard. The pressed keys won't be send to the QWidget having the input focus



  • You say that their is no solution to use virtualkeyboard on widget-based app on boot2qt?!


  • Moderators

    @Foufy
    No, not with EGLFS (what only allowes 1 window). Which is used by boot2qt AFAIK.



  • Ok. To solve the problem I've coded my own virtualkeyboard.
    Thank you

    0_1556664697399_0d2ae3ea-d1fe-48ea-a493-c81315eb894c-image.png



  • @raven-worx said in Need help to code VirtualKeyboard using QQuickWidget on Widget-based app:

    @Foufy
    No, not with EGLFS (what only allowes 1 window). Which is used by boot2qt AFAIK.

    Hi @raven-worx
    [Just don't want to create a new topic for this!]

    So if we don't configure Qt with EGLFS and instead enable these options on cross-compile:

    • EGL on X11
    • XCB

    And having windowed applications, we're able to use VK in form of Desktop Integration Method?

    Regards.


  • Moderators

    @iman4k said in Need help to code VirtualKeyboard using QQuickWidget on Widget-based app:

    And having windowed applications, we're able to use VK in form of Desktop Integration Method?

    yes, if you want to use it with QtWidgets.
    An InputPanel QML element can also show a virtualkeyboard using EGLFS.



  • @raven-worx said

    yes, if you want to use it with QtWidgets.
    An InputPanel QML element can also show a virtualkeyboard using EGLFS.

    So far so good!
    I have managed to cross compile Qt v5.12.3 on Raspbian stretch@Raspberry Pi3B+ without EGLFS and with EGL on X11 and all Virtual Keyboard plugins are deployed correctly based on Deployment Guide BUT VK won't run and if we set QT_DEBUG_PLUGINS to true only $$[QT_INSTALL_PLUGINS]/platforminputcontexts/libqtvirtualkeyboardplugin.so is loaded(full log).
    So do you have any clue about what's wrong?
    Regards.

    Hope to get to a solution on this topic for anyone else


  • Moderators

    @iman4k
    did you set QT_IM_MODULE=qtvirtualkeyboard env variable?
    How do you start your application? With what parameters and or platform plugin?
    Do you see your application in your X11 display?



  • @raven-worx said in Need help to code VirtualKeyboard using QQuickWidget on Widget-based app:

    @iman4k
    did you set QT_IM_MODULE=qtvirtualkeyboard env variable?
    How do you start your application? With what parameters and or platform plugin?
    Do you see your application in your X11 display?

    • Yes, before QApplication creation in the main function:
      • qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
    • ./<my-app> -platform xcb
    • Not sure about seeing application on X11 display but yes my app running normally(windowed) just like the desktop-x86 one.


  • @raven-worx

    Also for more debugging when I set qputenv("QT_LOGGING_RULES", QByteArray("qt.virtualkeyboard=true"));, the VK's logs
    for raspberry is like this :

    qt.virtualkeyboard: Loading extension "japanese"
    qt.virtualkeyboard: Loading extension "traditional_chinese"
    qt.virtualkeyboard: Loading extension "pinyin"
    qt.virtualkeyboard: Loading extension "thai"
    qt.virtualkeyboard: Loading extension "hangul"
    qt.virtualkeyboard: PlatformInputContext::setFocusObject(): QLineEdit(0x7ec96790)
    qt.virtualkeyboard: PlatformInputContext::update(): QFlags<Qt::InputMethodQuery>(ImQueryAll)
    qt.virtualkeyboard: PlatformInputContext::update(): QFlags<Qt::InputMethodQuery>(ImInputItemClipRectangle)
    qt.virtualkeyboard: PlatformInputContext::setFocusObject(): QLineEdit(0x7ec96790)
    qt.virtualkeyboard: PlatformInputContext::update(): QFlags<Qt::InputMethodQuery>(ImQueryAll)
    qt.virtualkeyboard: PlatformInputContext::update(): QFlags<Qt::InputMethodQuery>(ImQueryAll)
    qt.virtualkeyboard: PlatformInputContext::update(): QFlags<Qt::InputMethodQuery>(ImQueryAll)
    qt.virtualkeyboard: PlatformInputContext::update(): QFlags<Qt::InputMethodQuery>(ImQueryAll)
    qt.virtualkeyboard: PlatformInputContext::showInputPanel()
    qt.virtualkeyboard: PlatformInputContext::commit()
    qt.virtualkeyboard: PlatformInputContext::commit()
    qt.virtualkeyboard: PlatformInputContext::hideInputPanel()
    qt.virtualkeyboard: PlatformInputContext::setFocusObject(): QObject(0x0)
    qt.virtualkeyboard: PlatformInputContext::update(): QFlags<Qt::InputMethodQuery>(ImQueryAll)
    

    So showInputPanel() is called but actually is not shown! and couldn't find the reason.
    And these logs are for running on Desktop:

    qt.virtualkeyboard: PlatformInputContext::update(): QFlags<Qt::InputMethodQuery>(ImInputItemClipRectangle)
    qt.virtualkeyboard: PlatformInputContext::setFocusObject(): QLineEdit(0x7ffe8952fa60)
    qt.virtualkeyboard: PlatformInputContext::update(): QFlags<Qt::InputMethodQuery>(ImQueryAll)
    qt.virtualkeyboard: InputContext::setFocus(): true
    qt.virtualkeyboard: PlatformInputContext::setFocusObject(): QLineEdit(0x7ffe8952fa60)
    qt.virtualkeyboard: PlatformInputContext::update(): QFlags<Qt::InputMethodQuery>(ImQueryAll)
    qt.virtualkeyboard: InputContext::setLocale(): "en_GB"
    qt.virtualkeyboard: PlatformInputContext::setLocale(): QLocale(English, Latin, UnitedKingdom)
    qt.virtualkeyboard: InputEngine::setInputMethod(): QtVirtualKeyboard::PlainInputMethod(0x1110b60)
    qt.virtualkeyboard: InputEngine::setInputMode(): 0
    qt.virtualkeyboard: PlatformInputContext::update(): QFlags<Qt::InputMethodQuery>(ImQueryAll)
    qt.virtualkeyboard: PlatformInputContext::showInputPanel()
    qt.virtualkeyboard: DesktopInputPanel::repositionView(): QRect(55,24 1865x1056)
    qt.virtualkeyboard: PlatformInputContext::hideInputPanel()
    qt.virtualkeyboard: PlatformInputContext::commit()
    qt.virtualkeyboard: PlatformInputContext::commit()
    qt.virtualkeyboard: PlatformInputContext::setFocusObject(): QObject(0x0)
    qt.virtualkeyboard: PlatformInputContext::update(): QFlags<Qt::InputMethodQuery>(ImQueryAll)
    qt.virtualkeyboard: InputContext::setFocus(): false
    qt.virtualkeyboard: PlatformInputContext::update(): QFlags<Qt::InputMethodQuery>(ImInputItemClipRectangle)
    qt.virtualkeyboard: PlatformInputContext::setFocusObject(): QLineEdit(0x7ffe8952fa60)
    qt.virtualkeyboard: PlatformInputContext::update(): QFlags<Qt::InputMethodQuery>(ImQueryAll)
    qt.virtualkeyboard: InputContext::setFocus(): true
    qt.virtualkeyboard: PlatformInputContext::setFocusObject(): QLineEdit(0x7ffe8952fa60)
    qt.virtualkeyboard: PlatformInputContext::update(): QFlags<Qt::InputMethodQuery>(ImQueryAll)
    qt.virtualkeyboard: PlatformInputContext::commit()
    qt.virtualkeyboard: PlatformInputContext::commit()
    qt.virtualkeyboard: InputContext::setFocus(): false
    


  • @raven-worx
    Any idea or hint would be appreciated.
    Regards.


  • Moderators

    @iman4k
    seems you somehow loosing input-focus in your non-working case?
    are you running the exact same application on desktop and on your pi?
    any other output in the console?



  • @raven-worx said in Need help to code VirtualKeyboard using QQuickWidget on Widget-based app:

    @iman4k
    seems you somehow loosing input-focus in your non-working case?
    are you running the exact same application on desktop and on your pi?
    any other output in the console?

    • No, input focus is just fine and the lineedit will get focus as expected(the last 3 line of logs in the non-working case is because I clicked on the outside of widget area at the end)
    • Yes, the exact same application is running on Desktop and also on Embedded(raspberry) kit
    • Nothing more than those logs I mentioned!

    This is somehow strange, it took 1 week struggling on this :(


  • Moderators

    @iman4k
    then i guess either something in your application or your used Qt installation.
    Just to amke sure: I assume - becasue of the log output - the qtvirtualkeyboard plugin is available on your Pi?
    are you also using QML in your application or is it a pure QtWidget application?



  • @raven-worx said in Need help to code VirtualKeyboard using QQuickWidget on Widget-based app:

    @iman4k
    then i guess either something in your application or your used Qt installation.
    Just to amke sure: I assume - becasue of the log output - the qtvirtualkeyboard plugin is available on your Pi?
    are you also using QML in your application or is it a pure QtWidget application?

    • Yes, these are deployed on the pi side in install step of cross-compile:

      • /usr/local/qt5pi/plugins/platforminputcontexts/libqtvirtualkeyboardplugin.so
      • /usr/local/qt5pi/qml/QtQuick/VirtualKeyboard/libqtquickvirtualkeyboardplugin.so
      • /usr/local/qt5pi/qml/QtQuick/Layouts/libqquicklayoutsplugin.so
      • /usr/local/qt5pi/lib/libQt5VirtualKeyboard.so

      So I assume the plugin is available.

    • It's a simple QtWidgets application:

    #include <QtWidgets>
    
    int main(int argc, char *argv[]) {
        qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
        qputenv("QT_LOGGING_RULES", QByteArray("qt.virtualkeyboard=true"));
        QApplication a(argc, argv);
        QMainWindow w;
        QLineEdit edit(&w);
        edit.move(50, 50);
        w.show();
        return a.exec();
    }
    

    Is this problem related to Openbox WindowManager?
    I'm also curious to know why DesktopInputPanel::repositionView(): QRect(55,24 1865x1056) is not called after PlatformInputContext::showInputPanel() in raspberry?


Log in to reply