【Qt】-鼠标点击时-Text等控件移动位置
下面,点击鼠标,Text水平移动:
Rectangle {
anchors.fill: parent
color:"red"
Text {
id: text_id
width: 100
height: 20
//anchors.centerIn: parent
text: qsTr("Click me move.")
}
MouseArea {
anchors.fill: parent
onPressed: {
console.log("onPressed");
text_id.x += 10
}
onPositionChanged: {
console.log("onPositionChanged");
}
}
效果如下图所示: