My code:
import QtQuick 2.7
import QtQuick.Window 2.2
Window {
visible: true
width: 640
height: 480
Column {
Row {
Repeater {
id: rectRepeater
model: 3
Rectangle {
width: 30
height: 30
color: "red"
radius: 10
}
}
}
Row {
Repeater {
model: 3
Text {
text: rectRepeater.itemAt(0).width;
}
}
}
}
}
I get this error message:
TypeError: Cannot read property 'width' of null
I found this post saying that the solution is to use Component.onCompleted like this (just inserting a Component.onCompleted handler inside the Text object):
import QtQuick 2.7
import QtQuick.Window 2.2
Window {
visible: true
width: 640
height: 480
Column {
Row {
Repeater {
id: rectRepeater
model: 3
Rectangle {
width: 30
height: 30
color: "red"
radius: 10
}
}
}
Row {
Repeater {
model: 3
Text {
Component.onCompleted: {
text: rectRepeater.itemAt(0).width;
}
}
}
}
}
}
But this fails with the same error.
Any idea?