【发布时间】:2021-03-14 03:47:20
【问题描述】:
以下是我的部分代码。它工作得很好,但是我花了很多时间试图用 Repeater 来解决它,使其更加优雅和灵活,但没有成功。
您能否向我提出一个解决方案? areaMachine 在另一个 qml 文件中。
Row {
id: pageIndicatorBoxes
anchors.centerIn: pageIndicatorLine
spacing: 5
Rectangle {
id: pageIndicatorBox1
width: 10
height: 10
color: areaMachine.page == 1 ? "#e5e5e5" : "#404040"
}
Rectangle {
id: pageIndicatorBox2
width: 10
height: 10
color: areaMachine.page == 2 ? "#e5e5e5" : "#404040"
}
Rectangle {
id: pageIndicatorBox3
width: 10
height: 10
color: areaMachine.page == 3 ? "#e5e5e5" : "#404040"
}
Rectangle {
id: pageIndicatorBox4
width: 10
height: 10
color: areaMachine.page == 4 ? "#e5e5e5" : "#404040"
}
}
【问题讨论】: