Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Virtual keyboard does not show up in QWidgets app on RPi 2

Virtual keyboard does not show up in QWidgets app on RPi 2

Scheduled Pinned Locked Moved Solved Mobile and Embedded
virtualkeyboardcross-compileqtwidgetsqt 5.7eglfs rpi2
11 Posts 5 Posters 8.5k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mr_max
    wrote on last edited by
    #1

    Hello everybody,

    I recently managed to set up a cross-compiling toolchain for Qt 5.7 on a Raspberry Pi 2 with eglfs (following https://wiki.qt.io/RaspberryPi2EGLFS). It works great, but I ran into one issue which I currently can't tackle:
    I intend to use the Qt Virtual Keyboard in a QtWidgets based application with a touch screen. I already tried out the Basic example (from examples/virtualkeyboard/basic/) and it's working fine with the Keyboard showing up on tapping the LineEdits.
    However, with my example code below the keyboard does not show up if I compile and copy the binary to the Raspberry - although it does when I compile and run it natively on my workstation with the standard toolchain (a self-compiled, shared Qt 5.7 on Linux x64).
    There is no error message printed in the terminal.
    Any ideas?

    Here's the code:

    // main.cpp
    #include <QtWidgets>
    #include <QtGui>
    
    int main(int argc, char *argv[])
    {
        qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
        qputenv("QT_QPA_EGLFS_PHYSICAL_WIDTH", QByteArray("165"));
        qputenv("QT_QPA_EGLFS_PHYSICAL_HEIGHT", QByteArray("105"));
    
        QApplication a(argc, argv);
    
        QWidget w;
        QVBoxLayout layout(&w);
        layout.addWidget(new QLineEdit());
        layout.addWidget(new QLineEdit());
    
        w.show();
    
        return a.exec();
    }
    
    

    and here is my .pro file:

    #-------------------------------------------------
    #
    # Project created by QtCreator 2017-01-13T21:12:59
    #
    #-------------------------------------------------
    
    QT       += core gui widgets
    
    static {
        QT   += svg
        QTPLUGIN += qtvirtualkeyboardplugin
    }
    
    TARGET = VirtualKeyboardTest
    TEMPLATE = app
    
    DEFINES += QT_DEPRECATED_WARNINGS
    
    SOURCES += main.cpp
    
    
    1 Reply Last reply
    1
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      You can run your application with the QT_DEBUG_PLUGINS environment variable set to 1. This should give you more clues as to why the VK is not shown.

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      M 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi and welcome to devnet,

        You can run your application with the QT_DEBUG_PLUGINS environment variable set to 1. This should give you more clues as to why the VK is not shown.

        Hope it helps

        M Offline
        M Offline
        mr_max
        wrote on last edited by
        #3

        Thank you for the advice, @SGaist! I compared the logs of all three cases. In all of them QVirtualKeyboardPlugin is loaded properly, but in my application on the Raspberry there are a number of plugins not being loaded which are loaded on the desktop and the Basic example, including QtVirtualKeyboardStylesPlugin and several QML/QtQuick related plugins. How can I make them load or find out why they don't get loaded?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Check that you have everything available on your target.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • M Offline
            M Offline
            mr_max
            wrote on last edited by
            #5

            Today I cross-recompiled and reinstalled the whole Qt 5.7.1 toolkit on the target. Then I compiled the virtualkeyboard/basic example again as well as my own application shown above using exactly the same toolchain. Still, my application only loads QVirtualKeyboardPlugin but not the remaining ones. And they are available on the target - virtualkeyboard/basic loads all of them flawlessly. I still have no clue what causes this discrepancy.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Did you compare the .pro files ?
              Did you check with ldd the plugins that don't load on your target ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mr_max
                wrote on last edited by
                #7

                OK, I finally figured out why it doesn't work as I would like it to. Apparently, in non-desktop environments like EGLFS it is necessary to create an InputPanel with QML. So I guess it is impossible to write an application the traditional, QtWidgets-based way if you want to use Qt's virtual keyboard without X11. On the desktop, the only thing you need to do is to set QT_IM_MODULE=qtvirtualkeyboard and it just works out of the box.

                SGaistS A P 3 Replies Last reply
                2
                • M mr_max

                  OK, I finally figured out why it doesn't work as I would like it to. Apparently, in non-desktop environments like EGLFS it is necessary to create an InputPanel with QML. So I guess it is impossible to write an application the traditional, QtWidgets-based way if you want to use Qt's virtual keyboard without X11. On the desktop, the only thing you need to do is to set QT_IM_MODULE=qtvirtualkeyboard and it just works out of the box.

                  SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by SGaist
                  #8

                  @mr_max as a workaround you can use a QQuickWidget to contain the input panel.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  1
                  • M mr_max

                    OK, I finally figured out why it doesn't work as I would like it to. Apparently, in non-desktop environments like EGLFS it is necessary to create an InputPanel with QML. So I guess it is impossible to write an application the traditional, QtWidgets-based way if you want to use Qt's virtual keyboard without X11. On the desktop, the only thing you need to do is to set QT_IM_MODULE=qtvirtualkeyboard and it just works out of the box.

                    A Offline
                    A Offline
                    amruz
                    wrote on last edited by
                    #9

                    @mr_max I also have the same issue..Is it working now?

                    P 1 Reply Last reply
                    0
                    • A amruz

                      @mr_max I also have the same issue..Is it working now?

                      P Offline
                      P Offline
                      Poonam Gupta
                      wrote on last edited by
                      #10

                      @mr_max is it working for you? I have the same problem.

                      1 Reply Last reply
                      0
                      • M mr_max

                        OK, I finally figured out why it doesn't work as I would like it to. Apparently, in non-desktop environments like EGLFS it is necessary to create an InputPanel with QML. So I guess it is impossible to write an application the traditional, QtWidgets-based way if you want to use Qt's virtual keyboard without X11. On the desktop, the only thing you need to do is to set QT_IM_MODULE=qtvirtualkeyboard and it just works out of the box.

                        P Offline
                        P Offline
                        petero3
                        wrote on last edited by
                        #11

                        Thank you! Yes, InputPanel was what was needed to make the VirtualKeyboard actually show on embedded (eglfs_kms or wayland). Then it also needs a y and width. And then it is always visible by default, so I guess need to bind visible: active.

                        The code shown on this page, i.e. without InputPanel, "just worked" on desktop (except the virtual keyboard was massive), but not embedded
                        https://doc.qt.io/qt-6/qtvirtualkeyboard-basic-example.html
                        and the "Detailed Description" here didn't really explain why/when to use it
                        https://doc.qt.io/qt-6/qml-qtquick-virtualkeyboard-inputpanel.html

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved