I got the solution, I just miss Rect are Axis Aligned so we can simply apply the item transformation to get the AABB :
AABB.qml
@
import QtQuick 2.1
Rectangle {
id: aabb
color: "#AAAAFF"
property real childrenRotation: {
if (children.length)
return children[0].rotation
else
return false
}
property real childrenScaling: {
if (children.length)
return children[0].scale
else
return false
}
onChildrenRotationChanged: update()
onChildrenScalingChanged: update()
function update()
{
var rect = mapFromItem(children[0], children[0].x, children[0].y, children[0].width, children[0].height)
width = rect.width
height = rect.height
}
}
@
main.qml (Center the child in the AABB component) :
@
import QtQuick 2.0
Rectangle {
width: 360
height: 360
AABB {
anchors.centerIn: parent
Text {
text: qsTr("Hello World")
anchors.centerIn: parent
transformOrigin: Item.Center
SequentialAnimation on rotation {
// Animations on properties start running by default
running: true
loops: Animation.Infinite // The animation is set to loop indefinitely
NumberAnimation { from: 0; to: 359; duration: 50000 }
}
SequentialAnimation on scale {
// Animations on properties start running by default
running: true
loops: Animation.Infinite // The animation is set to loop indefinitely
NumberAnimation { from: 0.25; to: 4; duration: 50000 }
}
}
}
MouseArea {
anchors.fill: parent
onClicked: {
Qt.quit();
}
}
}
@