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

OpenGL painting doesn't work in QOpenGLWidget when QPainter is used

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 5.15.2
    • Fix Version/s: None
    • Component/s: GUI: OpenGL
    • Labels:
      None

      Description

      The attached testcase doesn't draw the triangle through OpenGL when QPainter is created in QOpenGLWidget::paintGL().

      This is contrary to what documentation (https://doc.qt.io/qt-5/qopenglwidget.html) says:

      It is also possible to draw 2D graphics onto a QOpenGLWidget subclass using QPainter:
      
         * In paintGL(), instead of issuing OpenGL commands, construct a QPainter object for use on the widget.
         * Draw primitives using QPainter's member functions.
         * Direct OpenGL commands can still be issued. However, you must make sure these are enclosed by a call to the painter's beginNativePainting() and endNativePainting().
      
      

      Command to compile the testcase:

      c++ -std=c++20 -fPIC testcase-painting-fails-in-QOpenGLWidget+QPainter.cpp `pkg-config --cflags --libs Qt5Core Qt5Widgets Qt5OpenGL` -I /usr/local/include -L /usr/local/lib -lGL
      

        Attachments

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

          Activity

            People

            Assignee:
            lagocs Laszlo Agocs
            Reporter:
            yurivict Yuri
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes