Qt World Summit: Submit your Presentation

[SOLVED] OpenGlWidget Error: undefined reference to `vtable for GLWidget'

  • Hello guys!
    I'm trying to simulate some points in the plane of the environment (x, y, z). Then i created a class Glwidget.h as follows:

    #ifndef GLWIDGET
    #define GLWIDGET
    #endif // GLWIDGET

    #include <QOpenGLWidget>
    #include <QObject>

    class GLWidget : public QOpenGLWidget

    GLWidget(QWidget *parent);
    void paintGL();
    void initializeGL();
    void resizeGL(int w, int h);
    GLWidget::GLWidget(QWidget *parent): QOpenGLWidget(parent)


    void GLWidget::paintGL()
    /* glBegin(GL_POINT);

    void GLWidget::initializeGL()

    void GLWidget::resizeGL(int w, int h)

    Then I inserted a QOpenGLWidget in my .ui file and promoted to glwidget.h
    But at compile time, the following error occurs: undefined reference to `vtable is GLWidget '
    I could not find much solution in google, can anyone help me?

  • Lifetime Qt Champion


    this error generally comes from adding/removing the Q_OBJECT macro. Re-run qmake and rebuild your project and you should be good to go

  • @SGaist Thanks! Solved this!

Log in to reply