calling Qt's QGraphicsView::setViewport with a custom QGLWidget

Posted by mos on Stack Overflow See other posts from Stack Overflow or by mos
Published on 2009-07-10T21:48:00Z Indexed on 2010/03/24 9:13 UTC
Read the original article Hit count: 696

Filed under:
|
|
|

I've derived from QGLWidget before, like so:

class MyGLWidget : public QGLWidget
{
public:
   // stuff...

   virtual void initializeGL() { /* my custom OpenGL initialization routine */ }

   // more stuff...
};

However, I find that if I try to initialize a QGraphicsView with my custom QGLWidget as the viewport, initializeGL doesn't get called (setting a breakpoint within the Qt library, neither does QGLWidget::initializeGL() when created plain).

// initializeGL, resizeGL, paintGL not called
ui.graphicsView->setViewport(new MyGLWidget(QGLFormat(QGL::DoubleBuffer)));

// initializeGL, resizeGL, paintGL *still* not called
ui.graphicsView->setViewport(new QGLWidget(QGLFormat(QGL::DoubleBuffer)));

Where is the correct location to place the code that currently resides in MyGLWidget::initializeGL()?

© Stack Overflow or respective owner

Related posts about qt

Related posts about opengl