无法使用QGLWidget编译Qt



我正在用c++编写一个Maya插件。然而,每当我想使用QGLWidget时,我都会收到大量vtable错误:

Undefined symbols for architecture x86_64:
  "QGLWidget::paintEvent(QPaintEvent*)", referenced from:
      vtable for GLWidget in myOpenGLWindowClass.o
  "QGLWidget::qt_metacall(QMetaObject::Call, int, void**)", referenced from:
      vtable for GLWidget in myOpenGLWindowClass.o
  "QGLWidget::qt_metacast(char const*)", referenced from:
      vtable for GLWidget in myOpenGLWindowClass.o
  "QGLWidget::resizeEvent(QResizeEvent*)", referenced from:
      vtable for GLWidget in myOpenGLWindowClass.o
  "QGLWidget::paintOverlayGL()", referenced from:
      vtable for GLWidget in myOpenGLWindowClass.o
  "QGLWidget::resizeOverlayGL(int, int)", referenced from:
      vtable for GLWidget in myOpenGLWindowClass.o
  "QGLWidget::updateOverlayGL()", referenced from:
      vtable for GLWidget in myOpenGLWindowClass.
...

这是代码:

#include <QtGui/QApplication>
#include <QGLWidget>
class GLWidget :public QGLWidget
{
public:
    GLWidget(QWidget *parent = 0);
    virtual ~GLWidget(){};
protected:
    virtual void initializeGL();
    virtual void resizeGL( int width, int height );
    virtual void paintGL();
};
GLWidget::GLWidget(QWidget *parent) : QGLWidget(parent)
{
}
void GLWidget::initializeGL() {
    glDisable(GL_TEXTURE_2D);
    glDisable(GL_DEPTH_TEST);
    glDisable(GL_COLOR_MATERIAL);
    glEnable(GL_BLEND);
    glEnable(GL_POLYGON_SMOOTH);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glClearColor(0, 0, 0, 0);
}
void GLWidget::resizeGL(int w, int h)
{
    glViewport(0, 0, w, h);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
}
void GLWidget::paintGL()
{
    glClear(GL_COLOR_BUFFER_BIT);
    glColor3f(1,0,0);
    glBegin(GL_POLYGON);
    glVertex2f(0,0);
    glVertex2f(100,500);
    glVertex2f(500,100);
    glEnd();
}

我的汇编中是否需要添加库或其他错误内容?

我需要在编译中添加QtOpenGL框架。

相关内容

  • 没有找到相关文章

最新更新