switch to usage of QOpenGLWidget

this drops support for Qt4
This commit is contained in:
KIU Shueng Chuan 2021-01-14 14:44:26 +08:00
parent dc46812e5a
commit 9145d7f24d
2 changed files with 7 additions and 16 deletions

View File

@ -1,4 +1,4 @@
from ..Qt import QtCore, QtGui, QtOpenGL, QT_LIB
from ..Qt import QtCore, QtGui, QtWidgets, QT_LIB
from OpenGL.GL import *
import OpenGL.GL.framebufferobjects as glfbo
import numpy as np
@ -9,7 +9,7 @@ from .. import functions as fn
ShareWidget = None
class GLViewWidget(QtOpenGL.QGLWidget):
class GLViewWidget(QtWidgets.QOpenGLWidget):
def __init__(self, parent=None, devicePixelRatio=None, rotationMethod='euler'):
"""
@ -30,13 +30,7 @@ class GLViewWidget(QtOpenGL.QGLWidget):
================ ==============================================================
"""
global ShareWidget
if ShareWidget is None:
## create a dummy widget to allow sharing objects (textures, shaders, etc) between views
ShareWidget = QtOpenGL.QGLWidget()
QtOpenGL.QGLWidget.__init__(self, parent, ShareWidget)
QtWidgets.QOpenGLWidget.__init__(self, parent)
self.setFocusPolicy(QtCore.Qt.ClickFocus)
@ -132,10 +126,7 @@ class GLViewWidget(QtOpenGL.QGLWidget):
if dpr is not None:
return dpr
if hasattr(QtOpenGL.QGLWidget, 'devicePixelRatio'):
return QtOpenGL.QGLWidget.devicePixelRatio(self)
else:
return 1.0
return QtWidgets.QOpenGLWidget.devicePixelRatio(self)
def resizeGL(self, w, h):
pass

View File

@ -8,7 +8,7 @@ Distributed under MIT/X11 license. See license.txt for more infomation.
from ..Qt import QtCore, QtGui
try:
from ..Qt import QtOpenGL
from ..Qt import QtWidgets
from OpenGL.GL import *
HAVE_OPENGL = True
@ -74,7 +74,7 @@ class RawImageWidget(QtGui.QWidget):
if HAVE_OPENGL:
class RawImageGLWidget(QtOpenGL.QGLWidget):
class RawImageGLWidget(QtWidgets.QOpenGLWidget):
"""
Similar to RawImageWidget, but uses a GL widget to do all drawing.
Perfomance varies between platforms; see examples/VideoSpeedTest for benchmarking.
@ -83,7 +83,7 @@ if HAVE_OPENGL:
"""
def __init__(self, parent=None, scaled=False):
QtOpenGL.QGLWidget.__init__(self, parent)
QtWidgets.QOpenGLWidget.__init__(self, parent)
self.scaled = scaled
self.image = None
self.uploaded = False