[PyQt] Paint sync issue with OpenGL widget inside MDI area

Thomas Robitaille thomas.robitaille at gmail.com
Wed Jan 20 17:27:39 GMT 2016


Hi everyone,

I am trying to add an OpenGL widget in an application I am working on
in order to display data. However, I'm running into an issue which is
that if I try and add the OpenGL widget to an MDI area, there is a
very noticeable spatial lag between where the Qt window is drawn and
the OpenGL canvas when dragging the MDI window around. Here's a short
screencast demonstrating this problem:

https://www.youtube.com/watch?v=wBg8SRpa580&feature=youtu.be

I see this effect even with the following simple example:

    import numpy as np

    from PyQt4 import QtGui, QtOpenGL

    qtapp = QtGui.QApplication([''])

    viewer = QtOpenGL.QGLWidget()
    viewer.resize(600,600)

    widget = QtGui.QMainWindow()

    mdi = QtGui.QMdiArea()
    widget.setCentralWidget(mdi)

    sub = QtGui.QMdiSubWindow()
    sub.setWidget(viewer)
    mdi.addSubWindow(sub)
    sub.resize(600,600)

    widget.show()

    qtapp.exec_()

Even though nothing is drawn in the OpenGL canvas, if you move the
sub-window from side to side, you'll see that the OpenGL canvas tends
to move ahead of the Qt sub-window.

Does anyone know how to avoid this issue?

Thanks!
Tom


More information about the PyQt mailing list