我可以取消选中一个组框中的一组RadioBottoms吗? [英] Can I un-check a group of RadioBottoms inside a group box?

查看:190
本文介绍了我可以取消选中一个组框中的一组RadioBottoms吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

组合箱内的收音机底部将被视为一组底部。它们是互斥的。我如何清理他们的检查状态?

radio bottoms inside a group Box will be treated as a group of bottoms. They are mutual exclusive. How can I clean up their check states??

我有几个电台底部,其中一个被检查。
如何清理(取消选中)所有电台底部?
setChecked在组内不起作用,我尝试执行以下操作但失败。

I have several radio bottoms, one of them are checked. How can I "clean" (uncheck) all radio bottoms?? "setChecked" doesn't work within a group, I tried to do following things but failed.

我的代码如下,radioButtom在groupBox ,我想取消选中它。
第一个setChecked可以工作,但第二个没有,radioBottom没有取消选中

My code is as following, radioButtom is inside a groupBox, and I want to unchecked it. The first setChecked does works, but the second one doesn't, the radioBottom doesn't been unchecked

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    QRadioButton *radioButton;
    ui->setupUi(this);
    radioButton->setChecked(true);
    radioButton->setChecked(false);
}

我的代码中的问题在哪里?

Where is the problem in my code?

推荐答案

窍门是在取消选中之前禁用 autoExclusive 属性,然后重新启用它。 p>

The trick is to disable the autoExclusive property before unchecking it, then re-enabling it.

ui->radioButton->setChecked(true);
ui->radioButton->setAutoExclusive(false);
ui->radioButton->setChecked(false);
ui->radioButton->setAutoExclusive(true);

此后,radioButton未选中。

After this, the radioButton is unchecked.

这篇关于我可以取消选中一个组框中的一组RadioBottoms吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆