Problema con el elemento de enlace QML
Pregunta
Tengo un problema al vincular un elemento en QML, por ejemplo:
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
}
}
Lo que quiero es hacer que los enlaces para drag.target, Anchors.fill funcionen sin cambiar la estructura (el área del mouse no es hermana ni hija de thetarget).He usado la función Binding para devolver el objetivo, pero todas son inútiles.¿Alguien podría decirme qué pasa?
Solución
Establecer el padre del mousearea
a thetarget
.
import QtQuick 1.1
Item {
Rectangle {
id: thetarget
width: 100
height: 100
}
Item {
id: container
MouseArea {
id: mousearea
parent: thetarget
drag.target: thetarget
anchors.fill: thetarget
property int foo: thetarget.width
}
}
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow