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. Create a list of properties
Forum Update on Monday, May 27th 2025

Create a list of properties

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 2 Posters 407 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.
  • D Offline
    D Offline
    DavidM29
    wrote on last edited by
    #1

    Hello,

    I would like to create a list of properties that I can iterate on.
    For example I do have the following properties :

    property bool myBool1 : false
    property bool myBool2 : true
    property int myInt1 : 0
    property bool myBool1 : false
    property int myInt2 : 4
    

    I would like to be able to make a function that take the index of the property and then set the value to that property.
    For example :

    function setData(index, value) {
          myProperties[index] = value 
    }
    

    How could I achieve that ?

    I thought about creating a list of JS element. But I'm not sure it is the best way. What would you recommend if it is possible ?

    ODБOïO 1 Reply Last reply
    0
    • D DavidM29

      Hello,

      I would like to create a list of properties that I can iterate on.
      For example I do have the following properties :

      property bool myBool1 : false
      property bool myBool2 : true
      property int myInt1 : 0
      property bool myBool1 : false
      property int myInt2 : 4
      

      I would like to be able to make a function that take the index of the property and then set the value to that property.
      For example :

      function setData(index, value) {
            myProperties[index] = value 
      }
      

      How could I achieve that ?

      I thought about creating a list of JS element. But I'm not sure it is the best way. What would you recommend if it is possible ?

      ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by
      #2

      @DavidM29 hi,
      one way https://doc.qt.io/qt-5/qml-variant.html#storing-arrays-and-objects

      D 1 Reply Last reply
      2
      • ODБOïO ODБOï

        @DavidM29 hi,
        one way https://doc.qt.io/qt-5/qml-variant.html#storing-arrays-and-objects

        D Offline
        D Offline
        DavidM29
        wrote on last edited by
        #3

        @LeLev

        Thank you for that answer.
        From what I saw on the link you sent me. The map is made with multiple variant list. Do you think it is the best way to do that ?

        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