Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. One QGLWidget that manage QGLWidget childs

One QGLWidget that manage QGLWidget childs

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 979 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    polch
    wrote on last edited by
    #1

    Hi devs.

    I would like to know if the following use case is supported by QT.

    I have one "TopLevel" QGLWidget :

    @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);
    }
    

    }@

    There are other "GLWidget" that should be drawn inside the top level widget context :
    @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
    }
    

    }@

    I would like to use them like this :
    @
    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);
    @

    The childs could be managed (drawing, deletion, ...) by the parent (like traditional widgets do).

    II haven't been able to run such a use case.

    Is there any design flaw in this use case ?

    Thank for your help.

    1 Reply Last reply
    0
    • W Offline
      W Offline
      wspilot
      wrote on last edited by
      #2

      If you comment out the childs creation, does the ParentGLWidget show up correctly (so without childs)?

      1 Reply Last reply
      0
      • P Offline
        P Offline
        polch
        wrote on last edited by
        #3

        Yes.

        My test code works if display independently each widget in different contexts.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved