PDA

View Full Version : access the members of the Form from a loop.



cbarmpar
25th September 2008, 01:04
Hi all,

I have a form which includes several widgets(lineedits). Is it possible to read all of them programmatically without reading one by one? Perhaps through a loop.

Can this applied to any widget as well?

Many thanks in advance.

momesana
25th September 2008, 01:32
Assuming all these labels have a common parent widget (The Form containing them) this may be a viable solution:


QList<QLabel*> labels = this->findChildren<QLabel *>(); // This refers to the formwidget
foreach(QLabel* lb, labels) {
// do something with the labels
}
Hope I could help you.

Kind regards
momesana

cbarmpar
25th September 2008, 01:35
Many thanks friend thats what i wanted.

Regards.