Assigning delegate to repeater model in QML

Marco Martin notmart at gmail.com
Fri Jun 17 19:48:15 CEST 2011


On Friday 17 June 2011, Viranch Mehta wrote:
> However, if I use it as follows, it works:
> 
> Row {
>     Repeater {
>         model: ["hello", "world"]
>         delegate: Item {
>             id: delegateItem
>             Text { text: modelData }
>         }
> }
> 
> But this makes the code look really messed up. Any alternatives?
> 
> Viranch
enclosing the first item that then you use as a delegate in a Component {} 
declaration should solve it (it creates the component but not the insatance)

however.
usually the preferred prettiest thing is to usually declare delegates in 
separate files, especially when they reach a certain size...

so you would do 

Row {
    Repeater {
        model: ["hello", "world"]
        MyFancyDelegate {}
   }
}

then you have MyFancyDelegate.qml

Cheers,
Marco Martin


More information about the Plasma-devel mailing list