1
votes

I want to fill the colours in the following rectangles created through Repeaters, dynamically.

I am not able to access the bottom Repeater at all.

How should I access "all" the rectangles here?

        Row
        {
            spacing: 20
            Repeater
            {
                id: repeater3

                property Repeater repeater2: repeater2

                model: head.rows
                Column
                {
                    id: columnInBetween
                    spacing: 20
                    Repeater
                    {
                        id: repeater2
                        model: head.columns
                        property Row row1: row1
                        Row
                        {
                            id: row1
                            property Repeater repeater1: repeater1
                            Repeater
                            {
                                id: repeater1
                                model: 2
                                Rectangle
                                {
                                    width: 20; height: 20
                                    color: "red" 
                                }
                            }
                        }
                    }
                }
            }
        }
1
I am not able to access the bottom Repeater at all - Why not? What did you try? - Mitch
If you need to access the items created by the repeaters, you can either traverse the children property of their parents (remembeer, Repeater parents what it creates to its own parent -- after itself!) or "register" the items of interest in a property of an item with an id visible at the file scope; - mlvljr
...if you are looking for ways to access outer Repeaters' per-item model data, there are ways, too (i.e. "alias" it with smth like property var modelData2: modelData -- provided the name of the property Repeater attaches is modelData -- don't remember right now, can be plain model, these things are a bit inconsistent between Repeater and ListView, iirc). - mlvljr

1 Answers

0
votes

Repeater will expand Item they contians.So you can use .children[index] to access those Item expanded. In your case:

/*0< index < head.rows
you get first Column expanded by repeater3*/
repeater3.itemAt(index).children[0]

/*0< index < head.columns
you get first Row of first Column expanded by repeater3 and repeater2*/
repeater3.itemAt(index).children[0].children[0]

/*0< index < 2
you get first Rectangle of first Row of first Column expanded by repeater3 and repeater2 and repeater1*/
repeater3.itemAt(index).children[0].children[0].children[0]

By the way, I do not know your intention and just remaid that you are getting a head.columns rows and 2 * head.rows columns of tables.