Kenn Sebesta
Kenn Sebesta

Reputation: 9708

How to access the QtObject inside the Loader inside a Repeater?

Let's say I have a QtObject loaded by a Loader which is embedded in a Repeater (which itself is attached to some arbitrary ListModel).

How would I access the properties and functions of the QtObject?

Repeater {
        id: repeater
        model: listModel
        Loader {
            sourceComponent: QtObject {
                   property int width: 100
                   property int height: 100

                   function foo() {console.log("bar")}
               }
            }
        }
    }

Upvotes: 0

Views: 165

Answers (1)

eyllanesc
eyllanesc

Reputation: 243907

First you access the Loader using itemAt() function and then the QtObject using item property:

var loader = repeater.itemAt(index)
var qt_object = loader.item
console.log(qt_object)

Upvotes: 1

Related Questions