How to access child properties from another child in QML
I want to change image(child of Rectangle) on mouse hover of MouseArea(child of Rectangle)
here is my code:
Code:
Rectangle
{
width: 600; height: 400
Row
{
id: myRow; spacing: 5; x: 50; y: 200
Repeater
{
id: myRepeater; model: 10
Rectangle
{
width: 100; height: 100;
property int myIndex: index
Image
{
source: "../GrayPoint.png"
}
MouseArea
{
id: mouseArea; anchors.fill: parent; hoverEnabled: true
onEntered:
updateUI( parent )
}
}
}
}
function updateUI( theParent )
{
theParent.childAt( 0, 0 ).source = "../RedPoint.png"
}
}
Re: How to access child properties from another child in QML
Add a property to the parent and use it in both children.
Cheers,
_
Re: How to access child properties from another child in QML
Or refer to the item using its id:
Code:
Image {
source: ma.containsMouse ? "../RedPoint.png" : "../GrayPoint.png"
}
MouseArea {
id: ma
hoverEnabled: true
anchors.fill: parent
}