通过QPushButton的
QString whatsThis() const
void setWhatsThis(const QString &)
实现标识传递。
添加多个按钮,
for(int i=0;i<count;i++)
{
QRadioButton *radio = new QRadioButton (this);
radio->setText("Process"+QString::number(i+1));
ui->gridLayoutProcess->addWidget(radio,i,0,1,1);
QPushButton *btn = new QPushButton(this);
btn->setText("Setup");
btn->setWhatsThis(QString::number(i+1));
ui->gridLayoutProcess->addWidget(btn,i,1,1,1);
connect(btn,SIGNAL(clicked()),this,SLOT(on_pushButton_clicked()));
}
槽函数
void WProcessPlasma::on_pushButton_clicked()
{
QPushButton* pBtn= qobject_cast<QPushButton*>(sender());
QString tag= pBtn->whatsThis();
QMessageBox::information(this,"",tag);
}