使用msys2 mingw64包编译时,Qt虚拟键盘是一个黑屏

使用msys2 mingw64包编译时,Qt虚拟键盘是一个黑屏,qt,qml,mingw-w64,virtual-keyboard,qtvirtualkeyboard,Qt,Qml,Mingw W64,Virtual Keyboard,Qtvirtualkeyboard,我正在制作一个使用qt中的虚拟键盘的应用程序。 我使用两种不同的编译器构建了它 使用QtCreator 4.14.2附带的捆绑mingw编译器,使用Qt5.15.2 将mingw-w64-x86_64-qt5包与msys2一起使用,msys2也是Qt 5.15.2 下面是一个简单的可复制示例项目,展示了这个问题 .pro文件 QT += quick virtualkeyboard svg CONFIG += c++11 # You can make your code fail to com

我正在制作一个使用qt中的虚拟键盘的应用程序。 我使用两种不同的编译器构建了它

  • 使用QtCreator 4.14.2附带的捆绑mingw编译器,使用Qt5.15.2
  • 将mingw-w64-x86_64-qt5包与msys2一起使用,msys2也是Qt 5.15.2
  • 下面是一个简单的可复制示例项目,展示了这个问题

    .pro文件

    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文件:

    #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();
    }
    
    }

    第一个编译和运行没有任何问题,如下所示:

    第二个编译和运行如下:

    唯一的区别是构建设置,其中一个选择了第一个工具链,第二个选择了另一个

    msys2工具链是我通常使用的工具链,它运行我使用的任何其他应用程序和库,没有任何问题


    我还添加了QT_PLUGIN_DEBUG=1,可以验证在这两个工具链中是否加载并说明了所有库。

    是否没有错误?您是从创建者还是从命令行运行它?在设置
    QT\u LOGGING\u RULES=QT.virtualkeyboard*=true
    后尝试运行它。这可能会打印一些有用的东西。没有错误。如您所建议的那样设置loggin规则并没有在终端中提供任何添加的输出,是否需要我在代码中添加额外的调试日志?QT_LOGGING_RULES=QT.virtualkeyboard*=true给出了一个输出,这是语法错误的原因。我将其更改为QT_LOGGING_RULES=QT.virtualkeyboard.trace=true,我认为这是正确的?
    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
    }