Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Item {
- anchors.fill: parent
- Component {
- id: quadrado1
- Rectangle {
- width: 100
- height: 100
- color: "red"
- }
- }
- Component {
- id: quadrado2
- Rectangle {
- width: 100
- height: 100
- color: "green"
- }
- }
- Component {
- id: quadrado3
- Rectangle {
- width: 100
- height: 100
- color: "blue"
- }
- }
- ListModel {
- id: modelo
- Component.onCompleted: {
- /// ListModel não suporta apontar para variáveis ou componentes,
- /// entao alimentamos ele posteriormente:
- modelo.append({nome: "q1", componente: quadrado1})
- modelo.append({nome: "q2", componente: quadrado2})
- modelo.append({nome: "q2", componente: quadrado3})
- }
- }
- ListView {
- clip: true
- anchors.fill: parent
- model: modelo
- delegate: ColumnLayout {
- Text {
- id: identificador
- text: model.nome
- }
- Loader {
- sourceComponent: model.componente
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement