报错:undefined reference to ‘vtable for,刚刚开始学QT,求高手解决困惑
头文件
///////////////////////////
#include <QObject>
class student :public QObject
{
Q_OBJECT
public:
student();
void studentask(int n);
public slots:
void studentslot(int n);
signals:
void studentsend(int n);
};
/////
#include <QObject>
#include<QDebug>
class teach:public QObject
{
Q_OBJECT
public:
teach();
public slots:
void myslot(int n);
signals:
void mysignteach(int n);
};
////
#include <QWidget>
#include "teach.h"
#include "student.h"
namespace Ui {
class Widget;
}
class Widget : public QWidget
{
Q_OBJECT
public:
explicit Widget(QWidget *parent = 0);
~Widget();
protected:
void changeEvent(QEvent *e);
public slots:
void myslots();
signals:
void mysignals();
private:
student *pstu;
teach *ptch;
Ui::Widget *ui;
};
//////////////////////////////////////////////
源文件
///////////////////////////////////////
#include "student.h"
#include <QDebug>
student::student()
{
}
void student::studentslot(int n)
{
qDebug()<<"teacher"<<n;
}
void student::studentask(int n)
{
emit(studentsend(n));
}
//////
#include "teach.h"
#include <QDebug>
teach::teach()
{
}
void teach::myslot(int n)
{
qDebug()<<"studen send come info:"<<n;
}
//////
#include "widget.h"
#include "ui_widget.h"
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ptch = new teach();
pstu = new student();
ui->setupUi(this);
// QObject::connect(pstu,SIGNAL(studentsend(int)),ptch,SLOT(myslots(int)));
// QObject::connect(this,SIGNAL(mysignals()),this,SLOT(myslots()));
// emit(studentask(888));
pstu->studentask(888);
}
Widget::~Widget()
{
delete ptch;
delete pstu;
delete ui;
}
void Widget::changeEvent(QEvent *e)
{
QWidget::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
void Widget::myslots()
{
qDebug()<<"myslots";
} qt
[解决办法]
有中文符号吧
[解决办法]