Increment variable in Rectangle
Unsolved
QML and Qt Quick
-
Hello,
I have a variable "b" and I want to increment it from 1 in the 1st rectangle and from 2 in the 2nd ....
How can I do?
Thanksproperty int b:1 Rectangle{ id:container1 color:"red" Text { id : label anchors.centerIn: parent text : b // I would like it to display "2" } Rectangle{ id:container2 color:"blue" Text { id : label2 anchors.centerIn: parent text : b // I would like it to display "3" }
-
@Titi01 But if you don't want to use Repeater and have just for example two or three rectangles, you can write
id: label1 text: b + 1 ... id: label2 text: b + 2
(instead of b+n use (b+n).toString() or "" + (b+n) or whatever works, I don't use javascript often enough to remember now.)
Then the texts should change when the value of b changes, if that's what you want.