Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-43748

qopenglwidget.h includes qopengl.h needlessly - interferes with use

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P4: Low
    • None
    • 5.4.0
    • GUI: OpenGL
    • None
    • Windows with MinGW

    Description

      I'm writing a derived class of QOpenGLWidget that has member variables whose type comes from typedefs in <GL/glcorearb.h> (for example: PFNGLCLEARPROC.) However, this is difficult to make work correctly because the order of inclusion of different GL headers matters and because <QOpenGLWidget> includes <QtGui/qopengl.h> which in turns includes some GL headers.

      I looked at qopenglwidget.h, and found that it doesn't seem to make use of any GL specific symbols. In fact, it seems to use a Pimpl to get around that. I can't even write a GL Pimpl for my own class, because I have to include MyGLWidget.h at the start of MyGLWidget.cpp which in turns includes the GL headers.

      There are probably some alternate solutions that kind of work at the cost of making the code more complex, but I think that it's a mistake that <QtGui/qopengl.h> is included transitively from <QOpenGLWidget> in the first place. It makes the class harder to use, it doesn't seem to be necessary, and it violates the Qt tradition of using forward declarations effectively. The only advantage is that it's maybe more convenient for a novice OpenGL user who expects OpenGL functions to be brought in magically without realizing that OpenGL is a more complex beast than that, due to the fact that its functions have to be queried dynamically based on the platform's capabilities.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            lagocs Laszlo Agocs
            nguillemot Nicolas Guillemot
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes