openglqt5qtopengl

QWidget::paintEngine being called from QCoreApplication::processEvents


I'm converting an OSX application from Qt 4/Carbon to Qt5.11 with the QOpenGLWidget.

I've moved the drawing "calls" to my overridden QOpenGlWidget::paintGL().

The problem is I'm still getting these messages on the console:

QWidget::paintEngine: Should no longer be called

Getting a stack trace, I've discovered that this is being called eventually from QCoreApplication::processEvents, which I'm calling from my own internal event loop.

Here's a stack trace (edited for readability)

The problem is that ::processEvents is eventually calling ::paintEngine for the QOpenGLWidget, OUTSIDE of ::paintGL, but it's totally out of my control.

FWIW, the Event driving this is a QEvent::UpdateRequest.

I tried overriding ::event in my QOpenGLWidget-inheriting class to call QOpenGlWidget::update when it receives a QEvent::UpdateRequest, but that just ended up making the app non-responsive.

How should I handle ::processEvents attempting to draw QOpenGlWidgets?

Thanks!


Solution

  • I fixed this by removing this statement from our QOpenGlWidget subclass:

    setAttribute( Qt::WA_PaintOnScreen, true );

    Removing this got ride of the paintEngine calls (and solved all kinds of other problems).