我在QML中绑定项目时遇到问题,例如:
Rectangle{
id: thetarget
width:100
height:100
}
Item{
id: container
MouseArea{
id:mousearea
drag.target: thetarget //not work
anchors.fill: thetarget //not work
property int foo: thetarget.width //work
}
}
我想要的是使drag.target,anchors.fill的绑定工作而不改变结构(mousearea不是thetarget的兄弟或孩子) . 我使用了Binding,函数来返回目标,但它们都没用 . 有人能告诉我什么是错的吗?
1 回答
将
mousearea
的父级设置为thetarget
.