我正在做一个可视化项目。它应该在QGLViewer上查看3D模型。我有一个如下定义的QGLViewer子类:
class GLViewer : public QGLViewer
{
Q_OBJECT
public:
explicit GLViewer(QWidget *parent = 0,const QGLWidget* shareWidget=0, Qt::WFlags flags=0);
protected:
void initializeGL();
void resizeGL(int width, int height);
void paintGL();
signals:
public slots:
};
像这样实现c'tor:
GLViewer::GLViewer(QWidget *parent, const QGLWidget* shareWidget, Qt::WFlags flags):
QGLViewer(parent,shareWidget,flags)
{
}
我收到链接器错误:
glviewer.o: In function `GLViewer::GLViewer(QWidget*, QGLWidget const*, QFlags<Qt::WindowType>)':
glviewer.cpp:(.text+0x18): undefined reference to `vtable for GLViewer'
glviewer.cpp:(.text+0x20): undefined reference to `vtable for GLViewer'
编辑:
这是
.pro
文件的内容:QT += core gui opengl xml
TARGET = qglviewer-test
TEMPLATE = app
LIBS += -lqglviewer-qt4 -lGLU -lGLEW
SOURCES += main.cpp\
mainwindow.cpp \
glviewer.cpp
HEADERS += mainwindow.h \
glviewer.cpp
形式+ = mainwindow.ui
最佳答案
您没有通过moc运行glviewer.h。这就是错误的意思。在您的.pro文件中,更改
HEADERS += mainwindow.h \
glviewer.cpp
至
HEADERS += mainwindow.h \
glviewer.h <------