Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Trying to build OpenGl widget, but getting linking errors.
Qt 6.11 is out! See what's new in the release blog

Trying to build OpenGl widget, but getting linking errors.

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 2.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Andrewm934
    wrote on last edited by
    #1

    glwidget.h

    #ifndef GLWIDGET_H
    #define GLWIDGET_H

    #include <QtOpenGL/QGLWidget>

    class GLWidget : public QGLWidget {
    Q_OBJECT
    public:
    GLWidget(QWidget *parent = 0);
    ~GLWidget();
    QSize sizeHint() ;

    protected:
    void initializeGL();
    void paintGL();
    void resizeGL(int width, int height);
    };

    #endif // GLWIDGET_H

    glwidget.cpp

    #include "glwidget.h"
    #include "ui_glwidget.h"

    GLWidget::GLWidget(QWidget *parent) : QGLWidget(parent) {
    }

    GLWidget::~GLWidget(){ }

    void GLWidget::initializeGL() {
    glClearColor(0.0, 0.0, 0.0, 0.0);
    glEnable(GL_DEPTH_TEST);

    }

    QSize GLWidget::sizeHint(){
    return QSize(400, 400);
    }

    void GLWidget::paintGL(){
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();
    glTranslatef(-1.5f,0.0f,-6.0f);
    glBegin(GL_TRIANGLES);
    glVertex3f( 0.0f, 1.0f, 0.0f);
    glVertex3f(-1.0f,-1.0f, 0.0f);
    glVertex3f( 1.0f,-1.0f, 0.0f);
    glEnd();
    }

    void GLWidget::resizeGL(int w, int h){
    QGLWidget::resize(w,h);
    }

    I keep getting LNK2019 and LNK2001 . I am assuming it is because I did not reimpliment all of the virtual functions and slots. Anythoughts?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to DevNet,

      First thing, please enclose your code with Code tags (one @ at the beginning and one at the end), that will make the post much more readable.

      Then to your problem, could you post the error you are getting ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        ZapB
        wrote on last edited by
        #3

        Which libraries/symbols is it complaining are missing?

        Nokia Certified Qt Specialist
        Interested in hearing about Qt related work

        1 Reply Last reply
        0
        • A Offline
          A Offline
          Andrewm934
          wrote on last edited by
          #4

          All of the errors look something like this.

          glwidget.obj:-1: error: LNK2001: unresolved external symbol "public: virtual class QPaintEngine * __thiscall QGLWidget::paintEngine(void)const " (?paintEngine@QGLWidget@@UBEPAVQPaintEngine@@XZ)

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Do you have
            @QT += opengl@

            in your .pro file ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved