Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.9.0
-
None
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.