Important: Please read the Qt Code of Conduct -

Set LineWith using Qt5 on Windows with OpenGL

  • Hi,

    today I was successful drawing lines with OpenGL using Qt5 on Windows. However I was not able to change the OpenGL line width.

    Minimum example:
    Started with the project gui/openglwindow. In the file main.cpp I changed the command to draw the triangle from
    glDrawArrays(GL_TRIANGLES, 0, 3);
    glDrawArrays(GL_LINE_STRIP, 0, 3);
    which results in two lines being drawn that change colors between the vertex points.

    Question: How do I change the width of the lines being drawn? Is there a simple solution using Qt or OpenGL methods (glLineWidth does not seem to work but gives no error either)? Can shaders be employed? If so, how? Does the behaviour differ if desktop OpenGL is used instead of OpenGL ES with the ANGLE library?

    Thanks in advance for your help.

    Best regards,

Log in to reply