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

QScrollArea and QOpenGLWidget problem on Windows

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.9.0
    • GUI: OpenGL
    • None
    • Windows

    Description

      The following program does not show the triangle, but only the text on windows:

      #include <QApplication>
      #include <QMainWindow>
      #include <QOpenGLFunctions_2_1>
      #include <QOpenGLWidget>
      #include <QPainter>
      #include <QScrollArea>
      
      class GLWidget final : public QOpenGLWidget, public QOpenGLFunctions_2_1 {
      
        auto initializeGL() -> void override {
          initializeOpenGLFunctions();
        }
      
        auto paintGL() -> void override {
          glClearColor(0.0, 0.0, 0.0, 1.0);
          glClear(GL_COLOR_BUFFER_BIT);
          glBegin(GL_TRIANGLES);
          glColor3d(1.0, 0.0, 0.0);
          glVertex3d(0.0, 1.0, 0.0);
          glColor3d(0.0, 1.0, 0.0);
          glVertex3d(-1.0, -1.0, 0.0);
          glColor3d(0.0, 0.0, 1.0);
          glVertex3d(1.0, -1.0, 0.0);
          glEnd();
          auto painter = QPainter{};
          painter.begin(this);
          painter.setPen(QColor{"yellow"});
          painter.drawText(100, 100, "Text");
          painter.end();
        }
      };
      
      auto main(int argc, char** argv) -> int {
        auto app = QApplication{argc, argv};
        auto win = QMainWindow{};
        auto widget = new GLWidget{};
        widget->setMinimumSize(QSize{250, 250});
        auto scrollArea = new QScrollArea{};
        scrollArea->setWidget(widget);
        win.setCentralWidget(scrollArea);
        //win.setCentralWidget(widget);
        win.resize(500, 500);
        win.show();
        return QApplication::exec();
      }
      
      • Removing the QScrollArea shows the triangle
      • Removing drawText shows the triangle
      • The order of drawing triangle/text matters
      • On Linux everything works fine

      Attached is a zip containing C++ source and CMake build file.

      Attachments

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

        Activity

          People

            lagocs Laszlo Agocs
            wolf.seifert Wolfgang Seifert
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes