I making an application that uses the virtual keyboard from qt. I have built it using two different compilers
- Using the bundled mingw compiler that comes with Qt Creator 4.14.2 using Qt 5.15.2
- Using the mingw-w64-x86_64-qt5 package with msys2, which is also Qt 5.15.2
Here is a simple reproducable example project showing the issue
.pro file
QT += quick virtualkeyboard svg
CONFIG += c++11
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp
RESOURCES += qml.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
# Additional import path used to resolve QML modules just for Qt Quick Designer
QML_DESIGNER_IMPORT_PATH =
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
main.cpp file:
#include <QGuiApplication>
#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
QGuiApplication app(argc, argv);
QQmlApplicationEngine engine;
const QUrl url(QStringLiteral("qrc:/main.qml"));
QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
&app, [url](QObject *obj, const QUrl &objUrl) {
if (!obj && url == objUrl)
QCoreApplication::exit(-1);
}, Qt::QueuedConnection);
engine.load(url);
return app.exec();
}
main.qml file:
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.VirtualKeyboard 2.15
ApplicationWindow {
id: window
visible: true
width: 640
height: 480
TextField {
anchors.centerIn: parent
}
InputPanel {
id: inputPanel
z: 89
y: active ? parent.height - height : parent.height
anchors.left: parent.left
anchors.right: parent.right
}
}
The first compiles and runs without any issues, looking like this:
and the second compiles and runs like this:
The only difference is the build settings, where one has the first toolchain selected and the second has the other.
The msys2 toolchain is the one I use normally and it runs any other application and library I use without any issues.
I also added QT_PLUGIN_DEBUG=1 and can verify that all libraries are loaded and accounted for in both toolchains.