For example, there are 4 Qlabels named label_1, label_2, label_3 and label_4. Each has a different value and I want to access the value contained in each of them one by one using any loop.
How can I access the text contained in QLabel using a loop?
681 views Asked by Jino At
1
You should put those labels in a container like a
QVector<QLabel*>instead of giving each of them a name, then access via a loop isn't a problem at all - just look them up in the vector by index.If for some reason you have to declare those four labels independently, there's no problem with having a list of them on top of that as another class member.
In your class:
In your constructor:
Iterate over them: