[Qt-interest] QGLWidget: initializeGL not executed

John McClurkin jwm at nei.nih.gov
Thu May 28 14:24:25 CEST 2009


Oliver Demetz wrote:
> Hi again,
> does nobody have an idea on  my question?
> regards,
> Oliver
> 
> Oliver Demetz schrieb:
>> Hi!
>>
>> I've got a QGraphicsView and scene, and the viewport of my vie is an 
>> QGLWidget. Everything works fine, also I am sure that the OpenGL 
>> subsystem is definitely used.
>>
>> Now I want to use my own subclassed QGLWidget as the viewport in order 
>> to check some properties of the opengl subsystem:
>>
>> Instead of
>>
>>      my_view.setViewport(new QGLWidget(...));
>>
>> I state
>>
>>      my_view.setViewport(new GLWidget(...));
>>
>> where my GLWidget is:
>>
>> class GLWidget : public QGLWidget
>> {
>> public:
>>     GLWidget(const QGLFormat & format, QWidget * parent = 0, const 
>> QGLWidget * shareWidget = 0, Qt::WindowFlags f = 0 )
>>     : QGLWidget(format, parent, shareWidget, f)
>>     {
>>
>>     }
>> protected:
>>     void glInit()
>>     {
>>         QGLWidget::glInit();
>>         qDebug() << "glinit";
>>     }
>>     void initializeGL()
>>     {
>>         QGLWidget::initializeGL();
>>
>>         QString strextensions((char*)glGetString(GL_EXTENSIONS));
>>         QStringList extlist = strextensions.split(" ");
>>         foreach(QString s, extlist)
>>             qDebug() << s;
>>
>>     }
>> };
>>
>> If I execute the code, I would expect to see at least the list of 
>> extensions or the debugstring "glinit".
>>
>> BUT NOTHING APPEARS!!!
>> why are thos methods not executed?????
>>
>> Note that the functionality still is as it was with the original 
>> QGLWidget!
>> Only the functions are not executed (also not paintGL).
>>
>
I don't use QGraphicsView but I do use a custom widget derived from 
QGLWidget. What I would suggest is removing the glInit function from the 
derived class. You are using it only to put in a qDebug() statement. 
Also, try not calling QGLWidget::initializeGL in your derived 
initializeGL function. Put the OpenGL initialization functions you need 
directly into your derived initializeGL function. Also, I would get rid 
of the non-OpenGL statements in the initializeGL function. Use a 
debugger and set break points.



More information about the Qt-interest-old mailing list