【发布时间】:2017-08-21 21:46:30
【问题描述】:
如果我点击键盘 hide 按钮会出现问题。以下是代码:
import QtQuick 2.6
import QtQuick.Window 2.2
import QtQuick.Controls 2.2
import QtQuick.VirtualKeyboard 2.2
Window {
visible: true
width: 600
height: 500
title: qsTr("Hello World")
TextField {
id: textfield
anchors.bottom:(inputPanel.visible) ? inputPanel.top : parent.bottom
color: "#2B2C2E"
cursorVisible: activeFocus
selectionColor: Qt.rgba(0.0, 0.0, 0.0, 0.15)
selectedTextColor: color
}
InputPanel {
id: inputPanel
z: 89
anchors.bottom:parent.bottom
anchors.left: parent.left
anchors.right: parent.right
visible: Qt.inputMethod.visible //** Warning here
}
}
以下是用例:
如果我点击 TextField 键盘会按预期弹出,但是当我点击隐藏键盘按钮时它不隐藏。
如果我点击 TextField 键盘按预期弹出,接下来如果我双击 TextField 然后点击隐藏键盘按钮 隐藏。
我也收到警告:
QML InputPanel:检测到属性“可见”的绑定循环
请提出建议。
【问题讨论】:
-
我遇到了类似的问题,但没有错误消息(尽管我没有可见性绑定),但我已经在使用 TextInput,如果我事先双击也没关系,它只是不起作用。我正在按照下面米奇的回答中的示例进行操作。 “OnActiveChanged”事件未命中,因此设置
visible: active将不起作用。 (按钮未将活动设置为假)......就像“隐藏”按钮什么都不做。所以任何其他可能的解决方案都会很棒。
标签: qt keyboard qml qtvirtualkeyboard