Hi there,
Does anyone know how can I easily iterate through QButtonGroup's buttons?
Hi there,
Does anyone know how can I easily iterate through QButtonGroup's buttons?
Obtain a list of all childs of your QButtonGroup:
http://doc.trolltech.com/4.1/qobject.html#children
Have a for..each-loop iterate over all of them and check wether they are subclasses of QAbstractButton (Qt4) or QButton (Qt3) by using either qt_cast in Qt4 or http://doc.trolltech.com/4.1/qobject.html#inherits
It's nice to be important but it's more important to be nice.
And check their group() value.
I've done it in a more clear way: every button I put in the button group I put also in a QPtrList. But that's as dumb as iterating all the children of the button group. I think it would be very good to have an iterator class for the QButtonGroup class.
...which would iterate over its children thus the effect would be the same and it would slow the code.
I don't get it
Doesn't the QButtonGroup have
Qt Code:
To copy to clipboard, switch view to plain text mode
Qt Code:
QList<QAbstractButton *> list = buttonGroup->buttons(); ... // ....... } // Check !!! delete list; // Not Sure Please Check ??To copy to clipboard, switch view to plain text mode
wont't this Do ?
One More do we need to Delete the List ?
We can't solve problems by using the same kind of thinking we used when we created them
How? It's not a pointer.Originally Posted by sunil.thaha
The question concerned Qt3 and not Qt4 (as you may notice in the header, the author uses Qt3 only) and QButtonGroup::buttons() is not present there.Originally Posted by sunil.thaha
There Again,
Some one forgets to See the Version
We can't solve problems by using the same kind of thinking we used when we created them
Bookmarks