Hi everyone,
I have a question about the for() loop function in Qt.
in my program, i have 10 labels, which indicate 10 led lights.
I can change the color for each label by using:
ui->label_led_1->setPixmap(picLedRed);
ui->label_led_2->setPixmap(picLedRed);
...
ui->label_led_1->setPixmap(picLedRed);
ui->label_led_2->setPixmap(picLedRed);
...
To copy to clipboard, switch view to plain text mode
I wonder how can i use the For() loop to simplify the code.
ex:
for (int i = 1; i <=10; i ++)
ui->label_led_i->setPixmap(picLedRed);
for (int i = 1; i <=10; i ++)
ui->label_led_i->setPixmap(picLedRed);
To copy to clipboard, switch view to plain text mode
Can any one tell me how i can increment the label number i, please?
Thanks in advance.
Bookmarks