博客园 首页 私信博主 显示目录 隐藏目录 管理 动画

QButtonGroup 的使用

1、3以后尽量手写,因为没有现在的控件了

2、

 1   // lyy : 2016/8/26 12:17:41 说明:存放radioButton
 2         QButtonGroup *buttonGroup;
 3   // lyy : 2016/8/26 11:11:55 说明:radioButton
 4     buttonGroup = new QButtonGroup();
 5     buttonGroup->addButton (ui.noSpace_Btn, 0);
 6     buttonGroup->addButton (ui.smallSpace_Btn, 1);
 7     buttonGroup->addButton (ui.mediumSpace_Btn, 2);
 8     buttonGroup->addButton (ui.bigSpace_Btn, 3);
 9 
10 // lyy : 2016/8/26 14:15:58 说明:用这种方法默认选择与mSelectRadioButton保持一致
11     QRadioButton *path = qobject_cast<QRadioButton*> (buttonGroup->button (mSelectRadioButton));
12     path->setChecked (true);
13 
14   connect (buttonGroup, SIGNAL (buttonClicked (int)), this, SLOT (buttonJudge (int)));
View Code

3、槽函数

1 void DailyPaper::buttonJudge (int iid)
2 {
3     quint16 a = buttonGroup->checkedId();
4     QMessageBox::information (this, "test", QString::number (a));
5     mSelectRadioButton = a;
6     //  QMessageBox::information (this, "test1", QString::number (a));
7 }
View Code

 

posted @ 2016-09-19 07:35  ants_double  阅读(855)  评论(0编辑  收藏  举报