Hello,
In the UI of my application, there are several radio buttons. They work well when I click them.
However, when I use raidoButton_1->setChecked(true) to set them, UI doesn't change. Shall I call some other functions to update them?
Thank you!
Hello,
In the UI of my application, there are several radio buttons. They work well when I click them.
However, when I use raidoButton_1->setChecked(true) to set them, UI doesn't change. Shall I call some other functions to update them?
Thank you!
There is no busy loop in the application.
Could you let me know what are the commands/functions in QT that can block the event loop?
Thank you!
Does this work for you?
Qt Code:
// main.cpp #include <QtGui> int main(int argc, char* argv[]) { button1.setChecked(true); button2.setChecked(false); button1.show(); button2.show(); return app.exec(); }To copy to clipboard, switch view to plain text mode
Are you sure that the code where you change the check state gets actually executed?
J-P Nurmi
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.
Qt Code:
// 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(); }To copy to clipboard, switch view to plain text mode
Is there any way to make no radiobutton selected?
Thank you!
put needed radiobutons in QGroupBox.
Qt Assistant -- rocks!
please, use tags [CODE] & [/CODE].
As shown in the above sample code, the three radio buttons have been put in the QGroupBox so that only one radiobutton can be selected.
however, if I want to clear the current selection and make all radiobutton unselected, what shall I do?
thank you!
try to add the following code to yours
but in this case you can't be able to check buttons at all.Qt Code:
... radio1->setCheckable(false); radio2->setCheckable(false); radio3->setCheckable(false); ...To copy to clipboard, switch view to plain text mode
Qt Assistant -- rocks!
please, use tags [CODE] & [/CODE].
Radio buttons are "auto-exclusive" by default. If auto-exclusive is enabled, radio buttons that belong to the same parent widget behave as if they were part of the same exclusive button group.
J-P Nurmi
Thank you!
Bookmarks