I have an item and I want to dynamically add a class based on a variable
import "class1"
import "class2"
Item {
id: myID
property variant myVar: 0;
anchors.fill: parent;
function update() {
switch(myID.myVar) {
case 0:
class1 {
anchors.fill: parent;
}
break;
case 1:
class2 {
anchors.fill: parent;
}
break;
}
}
}
It seems like there may be an issue with the current code, is there a correct way to achieve this?
Thank you.