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();