Is it possible to enumerate the gourpBox object?
That is , I would like to meake a loop which iterate over all the object of a goupBox, an I need the goupBox object's count.
Is it possible to enumerate the gourpBox object?
That is , I would like to meake a loop which iterate over all the object of a goupBox, an I need the goupBox object's count.
I am not sure is it what you want but check children function. It returns a list of all children so you can in easy way to find out how many objects your groupbox has.
Here you are an example code:
Qt Code:
groupBox->setCheckable(true); groupBox->setChecked(false); radio1->setChecked(true); checkBox->setChecked(true); vbox->addWidget(radio1); vbox->addWidget(radio2); vbox->addWidget(radio3); vbox->addWidget(checkBox); vbox->addStretch(1); groupBox->setLayout(vbox); const QList<QObject*> children = groupBox->children(); qDebug() << "Number of children: " << children.count(); for(QList<QObject*>::const_iterator cit = children.begin(); cit != children.end();++cit) { qDebug() << "Child: " << (*cit)->metaObject()->className(); }To copy to clipboard, switch view to plain text mode
Thank you very much. I will try it.
G
Bookmarks