Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. ListElement fields as properties ?
QtWS25 Last Chance

ListElement fields as properties ?

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 1.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Thanana
    wrote on last edited by
    #1

    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 :)

    1 Reply Last reply
    0
    • T Offline
      T Offline
      task_struct
      wrote on last edited by
      #2

      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 ...
          } 
      

      }
      }
      @

      "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program."

      • Linu...
      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved