⚠️ Forum Maintenance: Feb 6th, 8am - 14pm (UTC+2)

QGLWidget not showing

  • Hi there,

    I am new to OpenGL and fairly new to Qt and I encountered a curious problem. Based on the "tutorial":http://files.linux-addicted.net/qtproject/learning/developerguides/qtopengltutorial/OpenGLTutorial.pdf linked on this homepage I implemented some basic OpenGL examples. They work fine and I was even able to extend them to my wishes.

    But, as soon as I try to use the widget as a component in a layout the frame stays black.

    After some trail and error I also found that the original widget does not show if I instantiate it through a pointer. I suppose this might have something to do with the problem.

    @#include <QtWidgets/QApplication>
    #include "GlWidget.h"

    int main(int argc, char *argv[])
    QApplication a(argc, argv);

    //This is not showing:
    GlWidget *sphere1 = new GlWidget();

    //This is showing:
    GlWidget sphere2;

    return a.exec();

    I am using Qt 5.3 and really hope you can help me solve this. It is a central point for the project I'm working on right now. If you need any further code please let me know (but basically it is the code described in chapter 3.5 of the tutorial and can be downloaded via "link ":http://download.qt.io/learning/developerguides/qtopengltutorial/ ).

    Cheers and thanks in advance,

  • Hi again,

    just tried it with the original scr and works perfectly. I'll just try and rebuild it from that point.

    Thanks for the interest in the topic,

  • Okay,

    I solved it. It was a case of personal stupidity and not a technical problem. I failed with the declaration of a parameter (I love C++ ;-D).
    Somebody please close this thread.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    What parameter was it ? It might help another forum user :)

Log in to reply