组框内的单选底部将被视为一组底部。它们是互斥的。我怎样才能清理他们的支票状态??
我有几个 radio 底部,其中一个已检查。 我怎样才能“清理”(取消选中)所有 radio 底部? “setChecked”在组内不起作用,我尝试执行以下操作但失败了。
我的代码如下,radioButtom 在一个 groupBox 中,我想取消选中它。 第一个 setChecked 有效,但第二个无效,radioBottom 没有被取消选中
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
QRadioButton *radioButton;
ui->setupUi(this);
radioButton->setChecked(true);
radioButton->setChecked(false);
}
我的代码哪里出了问题?
最佳答案
诀窍是在取消选中之前禁用 autoExclusive
属性,然后重新启用它。
ui->radioButton->setChecked(true);
ui->radioButton->setAutoExclusive(false);
ui->radioButton->setChecked(false);
ui->radioButton->setAutoExclusive(true);
在此之后,radioButton 将被取消选中。
关于c++ - 我可以取消选中组框中的一组 RadioBottoms 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2816229/