#include "widget.h" #include "ui_widget.h" #include #include Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget) { ui->setupUi(this); //三个按钮的信号都关联到 FoodIsComing 槽函数 connect(ui->pushButtonAnderson, SIGNAL(clicked()), this, SLOT(FoodIsComing())); connect(ui->pushButtonBruce, SIGNAL(clicked()), this, SLOT(FoodIsComing())); connect(ui->pushButtonCastiel, SIGNAL(clicked()), this, SLOT(FoodIsComing())); } Widget::~Widget() { delete ui; } void Widget::FoodIsComing() { //获取信号源头对象的名称 QString strObjectSrc = this->sender()->objectName(); qDebug()<