简体   繁体   English

制作单选按钮组

[英]Make group for radio button

I have 4 radiobutton. 我有4个radiobutton。 Now, I want to group it to 2group. 现在,我想将它分组为2组。

 QRadioButton *radio1 = new QRadioButton(tr("R&adio button 1"));
 QRadioButton *radio2 = new QRadioButton(tr("R&adio button 2"));
 QRadioButton *radio3 = new QRadioButton(tr("R&adio button 3"));
 QRadioButton *radio4 = new QRadioButton(tr("R&adio button 4"));

What will I do . 我该怎么办 。 Using QT.Thanks, 使用QT.Thanks,

使用QButtonGroup http://www.ostools.net/uploads/apidocs/qt/qbuttongroup.html并使用checkid定义每个radiobutton。

You can use QGroupBox for grouping multiple radiobuttons together please try it 您可以使用QGroupBox将多个radiobuttons分组在一起,请尝试一下

Use two differnt QGroupBox for grouping them into different sets and then you can use this QGroupBox in the layout 使用两个不同的QGroupBox将它们分组到不同的集合中,然后您可以在布局中使用此QGroupBox

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM