PyQt6 6.0.1 changes QImage constructor api
This commit is contained in:
parent
feaa8fe5fb
commit
54d7c591b5
@ -1298,18 +1298,22 @@ def makeQImage(imgData, alpha=None, copy=True, transpose=True):
|
|||||||
# If the const constructor is used, subsequently calling any non-const method
|
# If the const constructor is used, subsequently calling any non-const method
|
||||||
# will trigger the COW mechanism, i.e. a copy is made under the hood.
|
# will trigger the COW mechanism, i.e. a copy is made under the hood.
|
||||||
|
|
||||||
if QT_LIB == 'PyQt5':
|
if QT_LIB.startswith('PyQt'):
|
||||||
# PyQt5 -> non-const constructor
|
if QtCore.PYQT_VERSION == 0x60000:
|
||||||
img_ptr = imgData.ctypes.data
|
# PyQt5 -> const
|
||||||
elif QT_LIB == 'PyQt6':
|
# PyQt6 >= 6.0.1 -> const
|
||||||
# PyQt5 -> const constructor
|
# PyQt6 == 6.0.0 -> non-const
|
||||||
# PyQt6 -> non-const constructor
|
|
||||||
img_ptr = Qt.sip.voidptr(imgData)
|
img_ptr = Qt.sip.voidptr(imgData)
|
||||||
|
else:
|
||||||
|
# PyQt5 -> non-const
|
||||||
|
# PyQt6 >= 6.0.1 -> non-const
|
||||||
|
img_ptr = int(Qt.sip.voidptr(imgData)) # or imgData.ctypes.data
|
||||||
else:
|
else:
|
||||||
# bindings that support ndarray
|
# bindings that support ndarray
|
||||||
# PyQt5 -> const constructor
|
# PyQt5 -> const
|
||||||
# PySide2 -> non-const constructor
|
# PyQt6 >= 6.0.1 -> const
|
||||||
# PySide6 -> non-const constructor
|
# PySide2 -> non-const
|
||||||
|
# PySide6 -> non-const
|
||||||
img_ptr = imgData
|
img_ptr = imgData
|
||||||
|
|
||||||
img = QtGui.QImage(img_ptr, imgData.shape[1], imgData.shape[0], imgFormat)
|
img = QtGui.QImage(img_ptr, imgData.shape[1], imgData.shape[0], imgFormat)
|
||||||
|
@ -228,10 +228,14 @@ class Renderer(GraphicsView):
|
|||||||
self.shm.resize(size)
|
self.shm.resize(size)
|
||||||
|
|
||||||
## render the scene directly to shared memory
|
## render the scene directly to shared memory
|
||||||
if QT_LIB == 'PyQt5':
|
|
||||||
img_ptr = int(sip.voidptr(self.shm))
|
# see functions.py::makeQImage() for rationale
|
||||||
elif QT_LIB == 'PyQt6':
|
if QT_LIB.startswith('PyQt'):
|
||||||
|
if QtCore.PYQT_VERSION == 0x60000:
|
||||||
img_ptr = sip.voidptr(self.shm)
|
img_ptr = sip.voidptr(self.shm)
|
||||||
|
else:
|
||||||
|
# PyQt5, PyQt6 >= 6.0.1
|
||||||
|
img_ptr = int(sip.voidptr(self.shm))
|
||||||
else:
|
else:
|
||||||
# PySide2, PySide6
|
# PySide2, PySide6
|
||||||
img_ptr = self.shm
|
img_ptr = self.shm
|
||||||
|
Loading…
Reference in New Issue
Block a user