0
我有問題在QML結合的項目,例如: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工作在不改變結構(鼠標區域是不是目標的兄弟姐妹或孩子)。我用Binding函數返回目標,但它們都沒用。有人能告訴我什麼是錯的嗎?
我認爲你應該把MouseArea放在target元素下,爲什麼你想把它放在容器下並將它綁定到target? – Kunal
我想製作一個獨立的組件並將一個項目(例如.target)傳遞給它的API。該組件可能是Item,Loader或Rectangle ...,它包含一個MouseArea,可用於拖動傳遞的項目。 –