Qt 虚拟键盘触摸屏设备

时间:2021-03-26 16:32:29

标签: qt keyboard qml virtual

我从 QML 上的 Qt 虚拟键盘得到了一些奇怪的行为。我有一个具有焦点的 TextInput,但在我在屏幕上的某处进行实际单击(使用真正的鼠标,而不是触摸)之前,它不会接收击键。我还在日志中收到“未设置输入法”。系统运行的是 Ubuntu 20.04。任何人都遇到过这样的事情。任何提示/帮助将不胜感激。

还要提一下,触摸屏适用于所有其他屏幕导航

请看下面我的代码:

Rectangle {
        id: passwordFieldId
        anchors.top: passwordPromptId.bottom
        anchors.topMargin: 30
        anchors.horizontalCenter: userPasswordBackgroundId.horizontalCenter
        color: HLGStyles.white
        border.color: HLGStyles.black
        border.width: 1
        width: 350
        height: 40

        TextInput {
            id: passwordInputFieldId
            echoMode: TextInput.Password
            anchors.fill: parent
            font {family: liberationSansRegular.name; pointSize: HLGStyles.mediumFont}
            color: HLGStyles.black
            visible: passwordVirtualKeyboardId.visible
            onVisibleChanged: if(visible) passwordInputFieldId.forceActiveFocus()
            onActiveFocusChanged: {
                if(activeFocus) {
                    Qt.inputMethod.update(Qt.ImQueryInput)
                }
            }
            focus: passwordVirtualKeyboardId.visible
            padding: 2
            verticalAlignment: TextInput.AlignVCenter
            anchors.centerIn: parent
            Keys.onReturnPressed: viewModel.onEnterPressed(passwordInputFieldId.text)
        }
    }

    InputPanel {
        id: passwordVirtualKeyboardId
        visible: (guiManager.currentScreenDisplayed === Screens.SoftwareUpdate) && (viewModel.currentScreen === viewModel.userPasswordScreenName) ? true : false
        anchors.horizontalCenter: parent.horizontalCenter
        width: parent.width * 0.95
        height: parent.height * 0.5
        anchors.bottom: parent.bottom
        anchors.bottomMargin: 140
    }

0 个答案:

没有答案
相关问题