新闻资讯

质量为本、客户为根、勇于拼搏、务实创新

< 返回新闻资讯列表

qt radiobutton选中状态如何设置,qt radiobutton默认选中

发布时间:2023-11-15 00:19:11

qt radiobutton选中状态如何设置

要设置Qt中的RadioButton控件的选中状态,可使用setChecked(bool)函数。将bool参数设置为true表示选中,设置为false表示未选中。

代码示例:

// 创建RadioButton控件
QRadioButton *radioButton = new QRadioButton("Option 1", this);

// 设置选中状态
radioButton->setChecked(true); // 选中
radioButton->setChecked(false); // 未选中

这样就能够设置RadioButton控件的选中状态了。