1 void AddCheckBox()
 2 {
 3   QStringList list;
 4   list<<"one"<<"two"<<"three";
 5   foreach(QString number,list)
 6   {
 7     QCheckBox *button = new QCheckBox(number,this); //widget添加button
 8     connect(button,SIGNAL(clicked()),this,SLOT(getButtonText()));
 9   }
10 }
11 void getButtonText()
12 {
13   QCheckBox *button = (QCheckBox * )(sender()); //关键一步是利用sender()
14   qDebug()<<"button text:"<<button->text();
15 }

 

相关文章:

  • 2021-08-29
  • 2021-12-31
  • 2021-08-17
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-16
猜你喜欢
  • 2021-12-09
  • 2021-09-28
  • 2021-10-24
  • 2022-02-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案