<strong><em>Mainwindow.h</em></strong>
private slots:
<span style="white-space:pre"> </span><strong>void refresh(QString &number);</strong> //1、声明槽
Billingdialog.h
signals:
<span style="white-space:pre"> </span><strong>void billed(QString &num);</strong> //2、声明信号
Mainwindow.cpp
void MainWindow::on_action_O_triggered()
{
query.prepare("select ti_num,ti_type,ti_status,ti_place,ti_waiterNam from tableInfo where ti_num=?");
query.addBindValue(ui->titalLabel->text());
query.exec();
query.next();
if(query.value(2).toString() == tr("可用"))
{
bD=new billingDialog(ui->titalLabel->text(),this);
<strong>connect(bD,SIGNAL(billed(QString&)),this,SLOT(refresh(QString&)));</strong> //3、信号与槽的绑定
bD->show();
}
else
QMessageBox::warning(this,tr("Warning"),tr("cute~"),QMessageBox::Ok);
}
<pre name="code" class="plain">void MainWindow::refresh(QString &number) //4、槽的定义
{
<span> </span>……
}
Billingdialog.cpp
void billingDialog::on_okButton_clicked()
{
<span style="white-space:pre"> </span>……
<span style="white-space:pre"> </span><strong>emit billed(this->number);</strong> //5、发送信号,触发绑定的槽函数
}