我可以取消选中组框中的一组 RadioBottom 吗?

2024-04-26

组 Box 内的单选底部将被视为一组底部。它们是互斥的。我怎样才能清理他们的检查状态?

我有几件收音机底部,其中一件经过检查。 我怎样才能“清洁”(取消选中)所有收音机底部? “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 将被取消选中。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

我可以取消选中组框中的一组 RadioBottom 吗? 的相关文章

随机推荐