You can use:
property alias someName: someItem
I created a quick example based on your code
main.qml
import QtQuick 2.1
import QtQuick.Controls 1.1
Rectangle{
id: developmentView
width: 600
height: 400
MyApp {
id: myApp
anchors.fill: parent
}
Button{
text: "Debug"
property bool activeDebug: false
onClicked: {
if( !activeDebug ){
activeDebug = true
debugLoader.sourceComponent = debugItem
}else{
activeDebug = false
debugLoader.sourceComponent = undefined
}
}
}
Loader {
id: debugLoader
anchors.fill: parent
}
Component{
id: debugItem
Rectangle{
id: debugZone
anchors.fill: parent
z: 10
opacity: 0.3
color: "lightBlue"
states: State{
name: "reparented"
ParentChange{
target: debugZone
parent: myApp.targetItem
x: myApp.targetItem.x
y: myApp.targetItem.y
width: myApp.targetItem.width
height: myApp.targetItem.height
scale: myApp.targetItem.scale
}
Component.onCompleted: {
debugZone.state = "reparented"
}
}
}
}
}
MyApp.qml
import QtQuick 2.0
Item{
id: application
property alias targetItem: draggableItem
Rectangle{
id: draggableItem
width: 100
height: 100
x: parent.width / 2
y: parent.height / 2
border.color: "red"
MouseArea {
anchors.fill: parent
drag.axis: Drag.XAndYAxis
drag.target: parent
}
}
}
↧