Hello,
The code works. In fact, I did another test: put three radio buttons in one qgroupbox. Using setChecked( true) to select one radio button. But, if I want to clear the selection, the setChecked( false ) seems not working. In following code, first radio button is selected. But it can not be unselected.
// main.cpp
#include <QtGui>
int main(int argc, char* argv[])
{
vbox->addWidget(radio1);
vbox->addWidget(radio2);
vbox->addWidget(radio3);
vbox->addStretch(1);
groupBox->setLayout(vbox);
groupBox->show();
radio1->setChecked(true);
radio1->setChecked(false);
return app.exec();
}
// main.cpp
#include <QtGui>
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QGroupBox *groupBox = new QGroupBox("Exclusive Radio Buttons");
QRadioButton *radio1 = new QRadioButton("&Radio button 1");
QRadioButton *radio2 = new QRadioButton("R&adio button 2");
QRadioButton *radio3 = new QRadioButton("Ra&dio button 3");
QVBoxLayout *vbox = new QVBoxLayout;
vbox->addWidget(radio1);
vbox->addWidget(radio2);
vbox->addWidget(radio3);
vbox->addStretch(1);
groupBox->setLayout(vbox);
groupBox->show();
radio1->setChecked(true);
radio1->setChecked(false);
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Is there any way to make no radiobutton selected?
Thank you!
Bookmarks