标题:qml 如何让输入框失去焦点?
作者:wang6354
日期:2021-04-09 22:51
内容:
我的界面上只有三个控件:1.输入框,2.Button,3. 单选按钮
我发现当输入框获得焦点后,光标在输入框里闪烁,此时当我单击button或者单选按钮后,光标依然在输入框闪烁,
我的问题
1. 这是否说明当单击Button或者单选按钮后焦点还在输入框里?
2. 如何实现当单击Button或者单选按钮后让输入框失去焦点?
我的代码如下:
import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.12
import QtQuick.Controls 1.4
Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
Rectangle{
width: 240
height: 80
border.color:"#FFFF00"
border.width: 3
anchors.centerIn: parent
radius: 5
TextInput{
id:input
anchors.fill:parent
anchors.margins: 2
}
}
Row{
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
height: 30
spacing: 10
ExclusiveGroup{
id:group
}
  ..
#1 [meteorliu 04-09 11:37]
1) 单机别的后焦点会失去
2) 表示按你说的,文本输入框,单选和按钮并没有出现你的情况,代码如下可参考
Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
Column{
x: 10
y: 10
Rectangle{
width: 150
height: 50
border.color: "black"
TextInput{
width: 150
height: 50
}
}
RadioButton{
width: 150
height: 50
text: "a"
}
RadioButton{
width: 150
height: 50
text: "b"
}
RadioButton{
..