ListElement fields as properties ?



  • Hello, here is my code :

    @import QtQuick 1.0

    ListModel {
    property real firstValue: 2
    property real secondValue: 3
    property real thirdValue: 1
    id: leftGrid
    ListElement {
    icon: "Images/1.png"
    value: leftGrid.firstValue
    }
    ListElement {
    icon: "2.png"
    value: -1
    }
    ListElement {
    icon: "3.png"
    value: leftGrid.secondValue
    }
    ListElement {
    icon: "4.png"
    value: leftGrid.thirdValue
    }
    }@

    this gives me the error :
    "ListElement: cannot use script for property value"

    What should I do ?

    thx in advance for any help :)



  • Hello,

    take a look at "this article":http://developer.qt.nokia.com/wiki/Qt_Quick_Carousel#70b4903abcb62ace84264ad0443ae759

    I think you need something like this:

    @
    import QtQuick 1.0

    ListModel {
    property real firstValue: 2
    property real secondValue: 3
    property real thirdValue: 1
    id: leftGrid
    ListElement {
    icon: "Images/1.png"
    }
    ListElement {
    icon: "2.png"
    }
    ListElement {
    icon: "3.png"
    }
    ListElement {
    icon: "4.png"
    }

    function value(index) {
        switch(index) {
         case 0: return leftGrid.firstValue
         case 1: return ...
        } 
    

    }
    }
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.