当我使用Android键盘写行编辑时,并按下“完成”按钮(下面的屏幕截图),键盘没有消失。即使在刚刚创建的项目中,只要进行行编辑(我已经对其进行了测试),这种情况都会发生。
如何使“完成”隐藏键盘?
请注意,我正在寻找开发人员解决方案(即编程,而不是面向用户)和 native 方式(即C++/Qt,而不是Java)。
我正在使用Qt 5.2.0。
最佳答案
您必须调用QInputMethod::hide()插槽。
C++解决方案
connect(ui->lineEdit, SIGNAL(editingFinished()), QGuiApplication::inputMethod(), SLOT(hide()));
QML解决方案
TextInput {
Keys.onEnterPressed: {
//...
Qt.inputMethod.hide()
}
Keys.onReturnPressed: {
//...
Qt.inputMethod.hide()
}
}
关于android - Qt Android : Pressing “Done” does not hide the keyboard,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21074012/