Hi,
I have fifteen control (i.e QComboBox) , i want to get text from them. is there any way to traverse the controls from a loop?
Thank you
Hi,
I have fifteen control (i.e QComboBox) , i want to get text from them. is there any way to traverse the controls from a loop?
Thank you
It depends how you defined them.
If you put the pointers in a vector for example - then sure!
==========================signature=============== ==================
S.O.L.I.D principles (use them!):
https://en.wikipedia.org/wiki/SOLID_...iented_design)
Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.
Here are the problem because i defined them in the UI.
Then you can still create a vector list with pointers.
Qt Code:
QVector myVector; myVector.append(ui->combobox1); myVector.append(ui->combobox2); for (int i = 0; i < myVector.size(); ++i) { // Do something with myVector.at(i) }To copy to clipboard, switch view to plain text mode
Or if you want to run through all those items unconditionally:
Note that QObject::findChlidren() might recurse into other child widgets to find children that match the type T & name.Qt Code:
// do the fancy stuff }To copy to clipboard, switch view to plain text mode
Horse sense is the thing that keeps horses from betting on people. --W.C. Fields
Ask Smart Questions
A correction:
In my post above, it should be:
Qt Code:
QVector<QComboBox*> myVector;To copy to clipboard, switch view to plain text mode
Bookmarks