2

我正在使用QT5.15.2并面临在 QML 虚拟键盘顶部显示弹出窗口的问题。我正在将申请表 5.12.5 迁移到 5.15.2 并发现此问题。相同的代码在 QT5.12.5 中按预期工作。

main.qml

import QtQuick 2.10
import QtQuick.Window 2.10
import QtQuick.VirtualKeyboard 2.2
import QtQuick.Controls 2.5
import QtQuick.Layouts 1.3

Window {
    id: window
    width: 640
    height: 480
    visible: true
    title: qsTr("Hello World")

    Button{
        id:buttonID
        height: 50
        width: 150
        text: "Click me"
        onClicked: {
            popupX.open()
        }
    }

    TextField{
        anchors.top: buttonID.bottom
        anchors.topMargin: 10
        placeholderText: qsTr("Enter name")
    }

    InputPanel {
        id: inputPanel
        x: 0
        y: window.height/2
        width: window.width
        anchors.bottom:parent.bottom
    }

    Popup{
        id: popupX
        focus: true
        width: 200
        height: 300
        modal: true
        padding: 0
        closePolicy: Popup.NoAutoClose
        anchors.centerIn: parent
        Overlay.modal: Rectangle {
            color: "#c8000000"
            /* here we use 8 bit color coding
                       first 2 bits define opacity.
                       the remaining six define standard color code.
                       */
        }
        ColumnLayout {
            anchors.fill: parent
            CheckBox { text: qsTr("E-mail") }
            CheckBox { text: qsTr("Calendar") }
            CheckBox { text: qsTr("Contacts") }
        }
    }
}

主文件

#include <QGuiApplication>
#include <QQmlApplicationEngine>

int main(int argc, char *argv[])
{
    qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));

    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);

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

在 QT 5.15 和 5.12 上运行的结果:

QT 5.15.2 QT 5.15.2

QT 5.12.5 QT 5.12.5

如果您对如何在 5.15.2 中解决此问题有任何建议,请告诉我。

4

0 回答 0