首页 > 解决方案 > 如何通过 id 获得属性列表

问题描述

我可以拥有一个使用以下列表的属性

property list<Rectangle> childRects: [
    Rectangle { color: "red" },
    Rectangle { color: "blue"}
]

我的元素比我的元素更长更复杂Rectangle,我发现在属性中声明它们不是很可读。

我怎么能有类似的东西

property list<Rectangle> childRects: [rect1, rect2]
Rectangle {id: rect1; color: "red" },
Rectangle {if: rect2; color: "blue"}

标签: qml

解决方案


推荐阅读