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)));
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 }
作者:Ants_double
出处:https://www.cnblogs.com/ants_double/
本文版权归作者和博客园所有,欢迎转载。转载请在留言板处留言给我,且在文章标明原文链接,谢谢!
如果您觉得本篇博文对您有所收获,觉得我还算用心,请点击右下角的 [大拇指],谢谢!