Display Array of Objects in Column
Solved
QML and Qt Quick
-
wrote on 11 Jun 2020, 14:32 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 typeCoreUtilizationDisplay
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
. -
wrote on 11 Jun 2020, 14:38 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
2/2