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



  • 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
    
    

  • Lifetime Qt Champion

    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



  • 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?


  • Lifetime Qt Champion

    Check that you have everything available on your target.



  • 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.


  • Lifetime Qt Champion

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



  • 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.


  • Lifetime Qt Champion

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



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



Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.