Qt程序编译make时出现错误:
程序代码:#include<qapplication.h>#include<qwidget.h>#include<qpushbutton.h>#include<qfont...
程序代码:
#include <qapplication.h>
#include <qwidget.h>
#include <qpushbutton.h>
#include <qfont.h>
class MyWidget:public QWidget
{
Q_OBJECT
public:
MyWidget(QWidget *parent=0,const char *name=0);
// MyWidget();
~MyWidget(){};
};
MyWidget::MyWidget(QWidget* parent,const char *name):QWidget(parent,name)
// MyWidget::MyWidget()
{
setMinimumSize(200,120);
setMaximumSize(200,120);
QPushButton *quit=new QPushButton("Quit",this,"quit");
quit->setGeometry(60,40,75,30);
quit->setFont(QFont("Times",18,QFont::Bold));
connect(quit,SIGNAL(clicked()),qApp,SLOT(quit));
}
int main(int argc,char **argv)
{
QApplication a(argc,argv);
MyWidget w;
//w.setGeometry(10,10,200,120);
a.setMainWidget(&w);
w.show();
return a.exec();
}
生成makefile文件后,make出现错误:
quit.o: In function `MyWidget::MyWidget(QWidget*, char const*)':
quit.cpp:(.text+0x2f): undefined reference to `vtable for MyWidget'
quit.cpp:(.text+0x36): undefined reference to `vtable for MyWidget'
quit.o: In function `main':
quit.cpp:(.text+0x215): undefined reference to `vtable for MyWidget'
quit.cpp:(.text+0x21f): undefined reference to `vtable for MyWidget'
quit.o: In function `MyWidget::MyWidget(QWidget*, char const*)':
quit.cpp:(.text+0x27f): undefined reference to `vtable for MyWidget'
quit.o:quit.cpp:(.text+0x286): more undefined references to `vtable for MyWidget' follow
collect2: ld returned 1 exit status
make: *** [quit] Error 1
大家帮忙,指点一下! 展开
#include <qapplication.h>
#include <qwidget.h>
#include <qpushbutton.h>
#include <qfont.h>
class MyWidget:public QWidget
{
Q_OBJECT
public:
MyWidget(QWidget *parent=0,const char *name=0);
// MyWidget();
~MyWidget(){};
};
MyWidget::MyWidget(QWidget* parent,const char *name):QWidget(parent,name)
// MyWidget::MyWidget()
{
setMinimumSize(200,120);
setMaximumSize(200,120);
QPushButton *quit=new QPushButton("Quit",this,"quit");
quit->setGeometry(60,40,75,30);
quit->setFont(QFont("Times",18,QFont::Bold));
connect(quit,SIGNAL(clicked()),qApp,SLOT(quit));
}
int main(int argc,char **argv)
{
QApplication a(argc,argv);
MyWidget w;
//w.setGeometry(10,10,200,120);
a.setMainWidget(&w);
w.show();
return a.exec();
}
生成makefile文件后,make出现错误:
quit.o: In function `MyWidget::MyWidget(QWidget*, char const*)':
quit.cpp:(.text+0x2f): undefined reference to `vtable for MyWidget'
quit.cpp:(.text+0x36): undefined reference to `vtable for MyWidget'
quit.o: In function `main':
quit.cpp:(.text+0x215): undefined reference to `vtable for MyWidget'
quit.cpp:(.text+0x21f): undefined reference to `vtable for MyWidget'
quit.o: In function `MyWidget::MyWidget(QWidget*, char const*)':
quit.cpp:(.text+0x27f): undefined reference to `vtable for MyWidget'
quit.o:quit.cpp:(.text+0x286): more undefined references to `vtable for MyWidget' follow
collect2: ld returned 1 exit status
make: *** [quit] Error 1
大家帮忙,指点一下! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询