CopperSpice API  1.9.1
QOpenGLWindow Class Reference

The QOpenGLWindow class is a subclass of QWindow used to perform OpenGL painting. More...

Inheritance diagram for QOpenGLWindow:
QPaintDeviceWindow QWindow QPaintDevice QObject QSurface

Public Types

enum  UpdateBehavior
 
- Public Types inherited from QWindow
enum  AncestorMode
 
enum  Visibility
 
- Public Types inherited from QSurface
enum  SurfaceClass
 
enum  SurfaceType
 
- Public Types inherited from QPaintDevice
enum  PaintDeviceMetric
 

Public Signals

void frameSwapped ()
 
- Public Signals inherited from QWindow
void activeChanged ()
 
void contentOrientationChanged (Qt::ScreenOrientation orientation)
 
void focusObjectChanged (QObject *object)
 
void heightChanged (int newHeight)
 
void maximumHeightChanged (int newMaxHeight)
 
void maximumWidthChanged (int newMaxWidth)
 
void minimumHeightChanged (int newMinHeight)
 
void minimumWidthChanged (int newMinWidth)
 
void modalityChanged (Qt::WindowModality modality)
 
void opacityChanged (qreal newOpacity)
 
void screenChanged (QScreen *screen)
 
void visibilityChanged (QWindow::Visibility newVisibility)
 
void visibleChanged (bool newVisible)
 
void widthChanged (int newWidth)
 
void windowStateChanged (Qt::WindowState windowState)
 
void windowTitleChanged (const QString &newTitle)
 
void xChanged (int newX)
 
void yChanged (int newY)
 
- Public Signals inherited from QObject
void destroyed (QObject *obj=nullptr)
 
void objectNameChanged (const QString &objectName)
 

Public Methods

 QOpenGLWindow (QOpenGLContext *shareContext, UpdateBehavior updateBehavior=NoPartialUpdate, QWindow *parent=nullptr)
 
 QOpenGLWindow (UpdateBehavior updateBehavior=NoPartialUpdate, QWindow *parent=nullptr)
 
 ~QOpenGLWindow ()
 
QOpenGLContextcontext () const
 
GLuint defaultFramebufferObject () const
 
void doneCurrent ()
 
QImage grabFramebuffer ()
 
bool isValid () const
 
void makeCurrent ()
 
QOpenGLContextshareContext () const
 
UpdateBehavior updateBehavior () const
 
- Public Methods inherited from QPaintDeviceWindow
qreal devicePixelRatio () const
 
int height () const
 
void update (const QRect &rect)
 
void update (const QRegion &region)
 
int width () const
 
- Public Methods inherited from QWindow
 QWindow (QScreen *screen=nullptr)
 
 QWindow (QWindow *parent)
 
virtual ~QWindow ()
 
QSize baseSize () const
 
Qt::ScreenOrientation contentOrientation () const
 
void create ()
 
QCursor cursor () const
 
void destroy ()
 
qreal devicePixelRatio () const
 
QString filePath () const
 
Qt::WindowFlags flags () const
 
virtual QObjectfocusObject () const
 
QSurfaceFormat format () const override
 
QRect frameGeometry () const
 
QMargins frameMargins () const
 
QPoint framePosition () const
 
QRect geometry () const
 
int height () const
 
QIcon icon () const
 
bool isActive () const
 
bool isAncestorOf (const QWindow *child, AncestorMode mode=IncludeTransients) const
 
bool isExposed () const
 
bool isModal () const
 
bool isTopLevel () const
 
bool isVisible () const
 
QPoint mapFromGlobal (const QPoint &pos) const
 
QPoint mapToGlobal (const QPoint &pos) const
 
QRegion mask () const
 
int maximumHeight () const
 
QSize maximumSize () const
 
int maximumWidth () const
 
int minimumHeight () const
 
QSize minimumSize () const
 
int minimumWidth () const
 
Qt::WindowModality modality () const
 
qreal opacity () const
 
QWindow * parent () const
 
QPoint position () const
 
void reportContentOrientationChange (Qt::ScreenOrientation orientation)
 
QSurfaceFormat requestedFormat () const
 
void resize (const QSize &newSize)
 
void resize (int w, int h)
 
QScreenscreen () const
 
void setBaseSize (const QSize &size)
 
void setCursor (const QCursor &cursor)
 
void setFilePath (const QString &filePath)
 
void setFlags (Qt::WindowFlags flags)
 
void setFormat (const QSurfaceFormat &format)
 
void setFramePosition (const QPoint &point)
 
void setGeometry (const QRect &rect)
 
void setGeometry (int x_pos, int y_pos, int w, int h)
 
void setIcon (const QIcon &icon)
 
bool setKeyboardGrabEnabled (bool grab)
 
void setMask (const QRegion &region)
 
void setMaximumSize (const QSize &size)
 
void setMinimumSize (const QSize &size)
 
void setModality (Qt::WindowModality modality)
 
bool setMouseGrabEnabled (bool grab)
 
void setOpacity (qreal level)
 
void setParent (QWindow *parent)
 
void setPosition (const QPoint &pt)
 
void setPosition (int x_pos, int y_pos)
 
void setScreen (QScreen *screen)
 
void setSizeIncrement (const QSize &size)
 
void setSurfaceType (SurfaceType surfaceType)
 
void setTransientParent (QWindow *parent)
 
void setVisibility (Visibility v)
 
void setVulkanInstance (QVulkanInstance *instance)
 
void setWindowState (Qt::WindowState state)
 
QSize size () const override
 
QSize sizeIncrement () const
 
SurfaceType surfaceType () const override
 
QString title () const
 
QWindow * transientParent () const
 
Qt::WindowType type () const
 
void unsetCursor ()
 
Visibility visibility () const
 
QVulkanInstancevulkanInstance () const
 
int width () const
 
Qt::WindowState windowState () const
 
WId winId () const
 
int x () const
 
int y () const
 
- Public Methods inherited from QObject
 QObject (QObject *parent=nullptr)
 
 ~QObject ()
 
bool blockSignals (bool block)
 
const QList< QObject * > & children () const
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool connect (const QObject *sender, const QString &signalMethod, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
bool disconnect (const QObject *receiver, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod, const QString &location, const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
bool disconnect (const QString &signalMethod=QString (), const QObject *receiver=nullptr, const QString &slotMethod=QString ()) const
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QStringdynamicPropertyNames () const
 
virtual bool event (QEvent *event)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
template<typename T >
findChild (const QString &childName=QString ()) const
 
template<class T >
QList< T > findChildren (const QRegularExpression &regExp, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
template<class T >
QList< T > findChildren (const QString &childName=QString (), Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 
bool inherits (const QString &className) const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const
 
bool isWindowType () const
 
void killTimer (int id)
 
const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const
 
QObject * parent () const
 
template<class T = QVariant>
property (const QString &name) const
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const QString &name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 
QThreadthread () const
 
- Public Methods inherited from QSurface
virtual ~QSurface ()
 
virtual QSurfaceFormat format () const = 0
 
virtual QSize size () const = 0
 
bool supportsOpenGL () const
 
SurfaceClass surfaceClass () const
 
virtual QPlatformSurfacesurfaceHandle () const = 0
 
virtual SurfaceType surfaceType () const = 0
 
- Public Methods inherited from QPaintDevice
virtual ~QPaintDevice ()
 
int colorCount () const
 
int depth () const
 
int devicePixelRatio () const
 
qreal devicePixelRatioF () const
 
int height () const
 
int heightMM () const
 
int logicalDpiX () const
 
int logicalDpiY () const
 
bool paintingActive () const
 
int physicalDpiX () const
 
int physicalDpiY () const
 
int width () const
 
int widthMM () const
 

Protected Methods

virtual void initializeGL ()
 
int metric (PaintDeviceMetric metric) const override
 
void paintEvent (QPaintEvent *event) override
 
virtual void paintGL ()
 
virtual void paintOverGL ()
 
virtual void paintUnderGL ()
 
virtual void resizeGL (int w, int h)
 
- Protected Methods inherited from QPaintDeviceWindow
int metric (PaintDeviceMetric metric) const override
 
- Protected Methods inherited from QWindow
bool event (QEvent *event) override
 
virtual void exposeEvent (QExposeEvent *event)
 
virtual void focusInEvent (QFocusEvent *event)
 
virtual void focusOutEvent (QFocusEvent *event)
 
virtual void hideEvent (QHideEvent *event)
 
virtual void keyPressEvent (QKeyEvent *event)
 
virtual void keyReleaseEvent (QKeyEvent *event)
 
virtual void mouseDoubleClickEvent (QMouseEvent *event)
 
virtual void mouseMoveEvent (QMouseEvent *event)
 
virtual void mousePressEvent (QMouseEvent *event)
 
virtual void mouseReleaseEvent (QMouseEvent *event)
 
virtual void moveEvent (QMoveEvent *event)
 
virtual bool nativeEvent (const QByteArray &eventType, void *message, long *result)
 
virtual void resizeEvent (QResizeEvent *event)
 
virtual void showEvent (QShowEvent *event)
 
virtual void tabletEvent (QTabletEvent *event)
 
virtual void touchEvent (QTouchEvent *event)
 
virtual void wheelEvent (QWheelEvent *event)
 
- Protected Methods inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signalMethod) const
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signalMethod) const
 
bool isSignalConnected (const QMetaMethod &signalMethod) const
 
int receivers (const QString &signal) const
 
QObject * sender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 
- Protected Methods inherited from QSurface
 QSurface (SurfaceClass type)
 
- Protected Methods inherited from QPaintDevice
 QPaintDevice ()
 

Additional Inherited Members

- Public Slots inherited from QPaintDeviceWindow
void update ()
 
- Public Slots inherited from QWindow
void alert (int msec)
 
bool close ()
 
void hide ()
 
void lower ()
 
void raise ()
 
void requestActivate ()
 
void requestUpdate ()
 
void setHeight (int height)
 
void setMaximumHeight (int height)
 
void setMaximumWidth (int width)
 
void setMinimumHeight (int height)
 
void setMinimumWidth (int width)
 
void setTitle (const QString &title)
 
void setVisible (bool visible)
 
void setWidth (int width)
 
void setX (int x_value)
 
void setY (int y_value)
 
void show ()
 
void showFullScreen ()
 
void showMaximized ()
 
void showMinimized ()
 
void showNormal ()
 
- Public Slots inherited from QObject
void deleteLater ()
 
- Static Public Methods inherited from QWindow
static QWindow * fromWinId (WId id)
 
- Static Public Methods inherited from QObject
static bool connect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool connect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection, const QString &location=QString ())
 
static bool connect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod, Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...), Qt::ConnectionType type=Qt::AutoConnection)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool connect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotLambda, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const QMetaMethod &signalMethod, const QObject *receiver, const QMetaMethod &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, const QString &signalMethod, const QString &location, const QObject *receiver, const QString &slotMethod)
 
static bool disconnect (const QObject *sender, std::nullptr_t, const QObject *receiver, std::nullptr_t)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class SlotClass , class... SlotArgs, class SlotReturn >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, SlotReturn (SlotClass::*slotMethod)(SlotArgs...))
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, std::nullptr_t slotMethod=nullptr)
 
template<class Sender , class SignalClass , class... SignalArgs, class Receiver , class T >
static bool disconnect (const Sender *sender, void (SignalClass::*signalMethod)(SignalArgs...), const Receiver *receiver, T slotMethod)
 
static QMetaObjectstaticMetaObject ()
 
static QString tr (const char *text, const char *comment=nullptr, std::optional< int > numArg=std::optional< int >())
 
- Properties inherited from QPaintDeviceWindow
 height
 
 width
 
- Properties inherited from QWindow
 active
 
 contentOrientation
 
 flags
 
 height
 
 maximumHeight
 
 maximumWidth
 
 minimumHeight
 
 minimumWidth
 
 modality
 
 opacity
 
 title
 
 visibility
 
 visible
 
 width
 
 x
 
 y
 
- Properties inherited from QObject
 objectName
 

Detailed Description

The QOpenGLWindow class is a subclass of QWindow used to perform OpenGL painting. This class is an enhanced QWindow that allows easily creating windows that perform OpenGL rendering using an API that is compatible with QOpenGLWidget and is similar to the legacy QGLWidget. Unlike QOpenGLWidget, QOpenGLWindow has no dependency on the widgets module and offers better performance.

A typical application will subclass QOpenGLWindow and reimplement the following virtual methods.

initializeGL()
OpenGL resource initialization
resizeGL()
Set up the transformation matrices and other window size dependent resources
paintGL()
Call OpenGL commands or draw using QPainter

To schedule a repaint call update(). This will not immediately result in a call to paintGL(). Calling update() multiple times in a row will not change the behavior in any way.

This is a slot so it can be connected to a QTimer::timeout() signal to perform animation. Note however that in the modern OpenGL world it is a much better choice to rely on synchronization to the vertical refresh rate of the display. See setSwapInterval() on a description of the swap interval. With a swap interval of 1, which is the case on most systems by default, the swapBuffers() call, that is executed internally by QOpenGLWindow after each repaint, will block and wait for vsync. When ever the swap is done an update can be scheduled again by calling update() without relying on timers.

To request a specific configuration for the context, use setFormat() like for any other QWindow. This allows, among others, requesting a given OpenGL version and profile, or enabling depth and stencil buffers.

Unlike QWindow, QOpenGLWindow allows opening a painter on itself and perform QPainter-based drawing.

QOpenGLWindow supports multiple update behaviors. The default, NoPartialUpdate is equivalent to a regular, OpenGL-based QWindow or the legacy QGLWidget. In contrast, PartialUpdateBlit and PartialUpdateBlend are more in line with QOpenGLWidget's way of working, where there is always an extra, dedicated framebuffer object present. These modes allow, by sacrificing some performance, redrawing only a smaller area on each paint and having the rest of the content preserved from of the previous frame. This is useful for applications than render incrementally using QPainter, because this way they do not have to redraw the entire window content on each paintGL() call.

Similarly to QOpenGLWidget, QOpenGLWindow supports the Qt::AA_ShareOpenGLContexts attribute. When enabled, the OpenGL contexts of all QOpenGLWindow instances will share with each other. This allows accessing each other's shareable OpenGL resources.

For more information on graphics refer to Graphics View.

Member Enumeration Documentation

This enum describes the update strategy of the QOpenGLWindow.

Constant Value Description
QOpenGLWindow::NoPartialUpdate 0 Indicates that the entire window surface will redrawn on each update and so no additional framebuffers are needed. This is the setting used in most cases and is equivalent to how drawing directly via QWindow would function.
QOpenGLWindow::PartialUpdateBlit 1 Indicates that the drawing performed in paintGL() does not cover the entire window. In this case an extra framebuffer object is created under the hood, and rendering performed in paintGL() will target this framebuffer. This framebuffer is then blitted onto the window surface's default framebuffer after each paint. This allows having QPainter-based drawing code in paintGL() which only repaints a smaller area at a time. Unlike NoPartialUpdate, the previous content is preserved.
QOpenGLWindow::PartialUpdateBlend 2 Similar to PartialUpdateBlit, but instead of using framebuffer blits, the contents of the extra framebuffer is rendered by drawing a textured quad with blending enabled. This, unlike PartialUpdateBlit, allows alpha blended content and works even when the glBlitFramebuffer is not available. Performance wise this setting is likely to be somewhat slower than PartialUpdateBlit.

Constructor & Destructor Documentation

QOpenGLWindow::QOpenGLWindow ( QOpenGLWindow::UpdateBehavior  updateBehavior = NoPartialUpdate,
QWindow parent = nullptr 
)
explicit

Constructs a new QOpenGLWindow with the given parent and updateBehavior.

See also
QOpenGLWindow::UpdateBehavior
QOpenGLWindow::QOpenGLWindow ( QOpenGLContext shareContext,
QOpenGLWindow::UpdateBehavior  updateBehavior = NoPartialUpdate,
QWindow parent = nullptr 
)
explicit

Constructs a new QOpenGLWindow with the given parent and updateBehavior. The QOpenGLWindow's context will share with shareContext.

See also
shareContext(), QOpenGLWindow::UpdateBehavior
QOpenGLWindow::~QOpenGLWindow ( )

Destroys this QOpenGLWindow and frees all resources. The OpenGLWindow's context is made current in the destructor allowing for safe destruction of any child object that may need to release OpenGL resources belonging to the context provided by this window.

Warning
If you have objects wrapping OpenGL resources (such as QOpenGLBuffer, QOpenGLShaderProgram, etc.) as members of a QOpenGLWindow subclass you may need to add a call to makeCurrent() in that subclass destructor as well. The child class destructors will be invoked before destroying this base class.
See also
makeCurrent()

Method Documentation

QOpenGLContext * QOpenGLWindow::context ( ) const

Returns the QOpenGLContext used by this window or a nullptr if it is not initialized.

GLuint QOpenGLWindow::defaultFramebufferObject ( ) const

The framebuffer object handle used by this window. When the update behavior is set to NoPartialUpdate, there is no separate framebuffer object. In this case the returned value is the ID of the default framebuffer. Otherwise the value of the ID of the framebuffer object or 0 if not yet initialized.

void QOpenGLWindow::doneCurrent ( )

Releases the context. It is not necessary to call this method in most cases, since the widget will make sure the context is bound and released properly when invoking paintGL().

See also
makeCurrent()
void QOpenGLWindow::frameSwapped ( )
signal

This signal is emitted after the potentially blocking buffer swap has been done. Applications that wish to continuously repaint synchronized to the vertical refresh, should issue an update() upon this signal. This allows for a much smoother experience compared to the traditional usage of timers.

QImage QOpenGLWindow::grabFramebuffer ( )

Returns a copy of the framebuffer.

void QOpenGLWindow::initializeGL ( )
protectedvirtual

Called once before the first call to paintGL() or resizeGL(). his method must be reimplement in a subclass.

This method should set up any required OpenGL resources and state. There is no need to call makeCurrent() because this has already been done when this function is called. Note however that the framebuffer, in case partial update mode is used, is not yet available at this stage, so avoid issuing draw calls from here. Defer such calls to paintGL() instead.

See also
paintGL(), resizeGL()
bool QOpenGLWindow::isValid ( ) const

Returns true if the window's OpenGL resources, like the context, have been successfully initialized. The return value is always false until the window becomes exposed or shown.

void QOpenGLWindow::makeCurrent ( )

Prepares for rendering OpenGL content for this window by making the corresponding context current and binding the framebuffer object, if there is one in that context.

It is not necessary to call this method in most cases, because it is called automatically before invoking paintGL(). It is provided nonetheless to support advanced, multi-threaded scenarios where a thread different than the GUI or main thread may want to update the surface or framebuffer contents. Refer to QOpenGLContext for more information on threading related issues.

This method is suitable for calling also when the underlying platform window is already destroyed. This means that it is safe to call this method from a QOpenGLWindow subclass' destructor. If there is no native window anymore, an offscreen surface is used instead. This ensures that OpenGL resource cleanup operations in the destructor will always work, as long as this method is called first.

See also
QOpenGLContext, context(), doneCurrent(), paintGL()
int QOpenGLWindow::metric ( PaintDeviceMetric  metric) const
overrideprotectedvirtual

Reimplemented from QPaintDevice::metric()

void QOpenGLWindow::paintEvent ( QPaintEvent event)
overrideprotectedvirtual

This event handler will call paintGL().

Reimplemented from QPaintDeviceWindow::paintEvent()

void QOpenGLWindow::paintGL ( )
protectedvirtual

Called any time the window contents needs to be painted. This method must be reimplement in a subclass.

There is no need to call makeCurrent() because this has already been done when this method is called. Before invoking this method the context and the framebuffer, if there is one, are bound, and the viewport is set up by a call to glViewport(). No other state is set and no clearing or drawing is performed by the framework.

When using a partial update behavior, like PartialUpdateBlend, the output of the previous paintGL() call is preserved and, after the additional drawing performed in the current invocation of the method, the content is blitted or blended over the content drawn directly to the window in paintUnderGL().

See also
initializeGL(), resizeGL(), paintUnderGL(), paintOverGL(), QOpenGLWindow::UpdateBehavior
void QOpenGLWindow::paintOverGL ( )
protectedvirtual

Called after each invocation of paintGL(). When the update mode is set to NoPartialUpdate, there is no difference between this function and paintGL(), performing rendering in either of them leads to the same result.

Like paintUnderGL(), rendering in this method targets the default framebuffer of the window, regardless of the update behavior. It gets called after paintGL() has returned and the blit (PartialUpdateBlit) or quad drawing (PartialUpdateBlend) has been done.

See also
paintGL(), paintUnderGL(), QOpenGLWindow::UpdateBehavior
void QOpenGLWindow::paintUnderGL ( )
protectedvirtual

Called before each invocation of paintGL(). When the update mode is set to NoPartialUpdate, there is no difference between this function and paintGL(), performing rendering in either of them leads to the same result.

The difference becomes significant when using PartialUpdateBlend, where an extra framebuffer object is used. There, paintGL() targets this additional framebuffer object, which preserves its contents, while paintUnderGL() and paintOverGL() target the default framebuffer, i.e. directly the window surface, the contents of which is lost after each displayed frame.

Avoid relying on this method when the update behavior is PartialUpdateBlit. This mode involves blitting the extra framebuffer used by paintGL() onto the default framebuffer after each invocation of paintGL(), thus overwriting all drawing generated in this function.

See also
paintGL(), paintOverGL(), QOpenGLWindow::UpdateBehavior
void QOpenGLWindow::resizeGL ( int  w,
int  h 
)
protectedvirtual

Called any time the widget has been resized. This method must be reimplement in a subclass. The new size is passed in w and h.

This method is for convenience to provide an API which is compatible with QOpenGLWidget. Unlike with QOpenGLWidget, derived classes are free to choose to override resizeEvent() instead of this method. Avoid issuing OpenGL commands from this method as there may not be a context current when it is invoked. If it cannot be avoided, call makeCurrent(). Scheduling updates from here is not necessary. The windowing systems will send expose events that trigger an update automatically.

See also
initializeGL(), paintGL()
QOpenGLContext * QOpenGLWindow::shareContext ( ) const

Returns the QOpenGLContext requested to be shared with the current QOpenGLContext.

QOpenGLWindow::UpdateBehavior QOpenGLWindow::updateBehavior ( ) const

Returns the update behavior for the current QOpenGLWindow.