Search code examples
c++qtqt5qt-creatorqtvirtualkeyboard

how to add qtvirtualkeyboard to a qt widget project


I have a Qt Widget project that I created using QtCreator and Qt version 5.15.2 to which I'm trying to add the QtVirtualKeyboard as matchbox-keyboard I've already tried using stays under the application when it's in fullscreen mode.

However I'm having trouble getting it to work as it's not appearing at all at the moment. This is how I've tried adding it

Main.cpp

#include "mainwindow.h"

#include <QApplication>
#include <QtWidgets>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
    MainWindow w;
    //w.showFullScreen();
    w.show();
    return a.exec();
}

I've tried adding QT += qtvirtualkeyboard or QT += virtualkeyboard in the .pro file but it just gives me an error saying "unknown module"

How can I add the virtual keyboard to the project?


Solution

  • You will need to make sure that the QtVirtualKeyboard library is selected during the installation process.

    Also, I would recommend you that you start using cmake for Qt applications as Qt has officially dropped qmake since the release of Qt 6.

    It is not to say that you cannot use it, but you will get better support and results by using an actively developed build system rather than an abandoned.

    enter image description here