Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved Display Array of Objects in Column

    QML and Qt Quick
    1
    2
    86
    Loading More Posts
    • 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.
    • S
      sandro4912 last edited by

      So I have A Column like this:

          SystemInformation{
              id: sysinfo
          }
      
          Column{
      
      //...
              CPUUtilizationDisplay{
                  width: root.elementWidth
                  height: root.elementHeight
      
                  value: sysinfo.cpuUtilizationInPercent
              }
              CoreUtilizationDisplay{
                  width: root.elementWidth
                  height: root.elementHeight
                  core: 1 
      //...
              }
              CoreUtilizationDisplay{
                  width: root.elementWidth
                  height: root.elementHeight
                  core: 2
      //...
              }
      
      //...
      }
      

      Now my problem is I only now after startup how many CoreUtilizationDisplay Objects I need when the sysinfo can tell me how many cores the system has. So the count of Elements of type CoreUtilizationDisplay is only nowable at run time. How can I achieve to display them?

      Sysinfo gives me an array of doubles and I need to create for each element one CoreUtilizationDisplay.

      1 Reply Last reply Reply Quote 0
      • S
        sandro4912 last edited by

        Could solve it myself:

            Repeater{
                model: sysinfo.coreUtilizationsInPercent.length
        
                CoreUtilizationDisplay{
                    width: root.elementWidth
                    height: root.elementHeight
                    core: index + 1
        
                    value: sysinfo.coreUtilizationsInPercent[index]
        
                    progressBarColor: "#3399FF" // blue
                    minMaxTextColor: "blue"
                }
            }
        

        I thought I need to create the Objects dynamically. But since I know the count of cores at startup I can just use Repeater

        1 Reply Last reply Reply Quote 0
        • First post
          Last post