我正在使用QtQuick.Controls 2.12,我试图显示带有 3 个按钮的窗口,其中一个按钮将具有焦点。使用QtQuick.Controls 1.4一切都很好,并且Button1具有焦点(蓝色边框):
但对于QtQuick.Controls 2.12,结果是这样的:
如果我按下Tab焦点将传递到Button2、Button3、Button1 ...
我也尝试过强制聚焦,但没有结果。
这是main.qml
import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Layouts 1.3
import QtQuick.Controls 2.12
Window {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
RowLayout{
anchors.fill: parent
Button{
id: button1
text: "Button1"
focus: true
}
Button{
text: "Button2"
onClicked: {
button1.forceActiveFocus()
}
}
Button{
text: "Button3"
}
}
}
Run Code Online (Sandbox Code Playgroud)
我试图在窗口启动时得到这个: