Hi.
I would like to know if the following use case is supported by QT.
I have one “Parent†QGLWidget :
	
	    {
    ...
    ...
        void initializeGL()
        {
        qglClearColor(qtPurple.dark());
        glEnable(GL_CULL_FACE);
        ...
        }
 
        void paintGL()
        {
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        }
 
        void resizeGL(int width, int height)
        {
        glViewport((width - side) / 2, (height - side) / 2, side, side);
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrthof(-0.5, +0.5, -0.5, +0.5, 4.0, 15.0);
        glMatrixMode(GL_MODELVIEW);
        }
    }
        class ParentGLWidget : public QGLWidget 
    {
    ...
        ParentGLWidget(QGLContext * context, QWidget *parent = 0) : QGLWidget(context, parent) {... }
    ...
        void initializeGL()
        {
        qglClearColor(qtPurple.dark());
        glEnable(GL_CULL_FACE);
        ...
        }
     
        void paintGL()
        {
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        }
     
        void resizeGL(int width, int height)
        {
        glViewport((width - side) / 2, (height - side) / 2, side, side);
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrthof(-0.5, +0.5, -0.5, +0.5, 4.0, 15.0);
        glMatrixMode(GL_MODELVIEW);
        }
    }
To copy to clipboard, switch view to plain text mode 
  There are other “childs" GLWidget that should be drawn "inside" the parent widget context :
	
	    {
    ...
    ...
        void initializeGL()
        {
         // optional
         // at least, should not overwrite what have been done in the top level widget
        }
 
        void paintGL()
        {
        glLoadIdentity();
        glTranslatef(0.0, 0.0, -10.0);
        glRotatef(xRot, 1.0, 0.0, 0.0);
        // draw some object in the gl world
        }
 
        void resizeGL(int width, int height)
        {
         // optional
         // at least, should not overwrite what have been done in the top level widget
        }
    }
        class ChildGLWidget : public QGLWidget 
    {
    ...
        ChildGLWidget(QGLContext * context, QWidget *parent = 0) : QGLWidget(context, parent) {... }
    ...
        void initializeGL()
        {
         // optional
         // at least, should not overwrite what have been done in the top level widget
        }
     
        void paintGL()
        {
        glLoadIdentity();
        glTranslatef(0.0, 0.0, -10.0);
        glRotatef(xRot, 1.0, 0.0, 0.0);
        // draw some object in the gl world
        }
     
        void resizeGL(int width, int height)
        {
         // optional
         // at least, should not overwrite what have been done in the top level widget
        }
    }
To copy to clipboard, switch view to plain text mode 
  
I would like to use them like this :
	
	ParentGLWidget * parent = new ParentGLWidget(context);
ChildGLWidget * child_1 = new ChildGLWidget(context, parent);
ChildGLWidget * child_2 = new ChildGLWidget(context, parent);
        QGLContext * context = new QGLContext(QGLFormat(QGL::SampleBuffers));
ParentGLWidget * parent = new ParentGLWidget(context);
ChildGLWidget * child_1 = new ChildGLWidget(context, parent);
ChildGLWidget * child_2 = new ChildGLWidget(context, parent);
To copy to clipboard, switch view to plain text mode 
  
The childs could be managed (drawing, deletion, …) by the parent (like traditional widgets do), and I would be able to have some part of 3D rendering in "modules".
I haven’t been able to run such a use case.
Is there any design flaw in this use case ? Do you think there are others ways to do that ?
Thank for your help.
				
			
Bookmarks