原因为信号的参数与槽函数参数不对应
通常发生在槽函数有参数时
槽函数:
#include "student.h"
#include <QDebug>
Student::Student(QObject *parent) : QObject(parent)
{
}
void Student::treat(){
qDebug()<< "请老师吃饭";
}
void Student::treat(QString foodName){
qDebug() << "请老师吃" << foodName.toUtf8().data();
}
#include "widget.h"
#include "ui_widget.h"
#include <QPushButton>
#include <QDebug>
//Teacher类 老师类
//student类 学生类
//下课后,老师会触发一个信号,饿了,学生响应信号,请客吃饭
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
//创建一个老师对象
this->zt = new Teacher(this);
//创建一个学生对象
this->st = new Student(this);
//点击一个按钮,再进行下课
QPushButton * btn = new QPushButton("下课",this);
setFixedSize(600,400);