So I have this little example where data of a ListElement determines what
component to load in a list view something like this
ListView {
ListModel {
id: aModel
ListElement {
name: "Bill Smith"
componentID: "redRectangle"
number: "555 3264"
}
ListElement {
name: "John Brown"
componentID:"brownRectangle"
number: "555 8426"
}
ListElement {
name: "Sam Wise"
componentID: "yellowRectangle"
number: "555 0473"
}
}
Component{
id: redRectangle
Rectangle{
width: 180; height: 200
color:"red"
}
}
Component{
id: brownRectangle
Rectangle{
width: 180; height: 200
color:"brown"
}
}
Component{
id: yellowRectangle
Rectangle{
width: 180; height: 200
color:"yellow"
}
}
width: 180; height: 600
model: aModel
delegate:Loader{
id:myLoader
sourceComponent: (componentID == "redRectangle")? redRectangle
: (componentID == "yellowRectangle"? yellowRectangle
: brownRectangle)
}
}
This all works fine and nice. But I was wondering if
sourceComponent: (componentID == "redRectangle")? redRectangle :
(componentID == "yellowRectangle"? yellowRectangle : brownRectangle)
could perhaps be more generic without all the nested stuff. Something that
would ideally look like this
sourceComponent: componentID
Any input would be great. Otherwise QML is fun, fun, fun.
Thanks,Bartosh
_______________________________________________
Qt-qml mailing list
[email protected]
http://lists.qt.nokia.com/mailman/listinfo/qt-qml