To get values of properties of parent component and assign them to child properties we can use parent properties directly
//Component1.qml:
Item
{
Component2
{
contentWidth:200
}
}
//Component2.qml:
Item
{
property int contentWidth:0
Rectangle
{
width:parent.contentWidth
}
}
or create an alias
//Component1.qml:
Item
{
Component2
{
contentWidth:200
}
}
//Component2.qml:
Item
{
property alias contentWidth:rect.width
Rectangle
{
id:rect
}
}
What is the most appropriate way and when?
My thought is that alias should be used when parent property is intended only for one particular child component property (contentWidth is intended only for rect.width)