QML に問題があります。TextInput
アクションに基づいて を編集し、focus
属性をに設定したいと思いますtrue
。が にある場合に機能しますが、 にTextInput
はありRectangle
ませんScrollView
。次に例を示します。
Item {
id: main
width: 640
height: 480
ScrollView{
id: scrollView
height: parent.height/2
width: parent.width
Rectangle{
border.color: "black"
border.width: 1
anchors.centerIn: parent
height: 25
width: 200
TextInput{
id: ti1
anchors.fill: parent
verticalAlignment: TextInput.AlignVCenter
horizontalAlignment: TextInput.AlignHCenter
}
}
}
Rectangle{
y: height
height: parent.height/2
width: parent.width
Rectangle{
border.color: "black"
border.width: 1
anchors.centerIn: parent
height: 25
width: 200
TextInput{
id: ti2
anchors.fill: parent
verticalAlignment: TextInput.AlignVCenter
horizontalAlignment: TextInput.AlignHCenter
}
}
}
MouseArea{
anchors.fill: parent
onClicked: {
if (mouseY < parent.height/2){
ti2.focus = false
ti1.focus = true
}else{
ti1.focus = false
ti2.focus = true
}
}
}
}
ウィンドウの下半分をクリックすると、TextInput
ti2 が編集可能になります。しかし、上半分をクリックすると、ti1 はありません。
誰にもアイデアはありますか?動作は と同じTextEdit
です。
ありがとう。