Merge pull request #1707 from pijyoi/pyqt61_compat
add PyQt6 6.1 forwards compatibility
This commit is contained in:
commit
bb90ef1ec9
@ -376,6 +376,15 @@ if QT_LIB == PYQT6:
|
||||
QtCore.QEvent.type = new_method
|
||||
del new_method
|
||||
|
||||
# PyQt6 6.1 renames some enums and flags to be in line with the other bindings.
|
||||
# "Alignment" and "Orientations" are PyQt6 6.0 and are used in the generated
|
||||
# ui files. Pending a regeneration of the template files, which would mean a
|
||||
# drop in support for PyQt6 6.0, provide the old names for PyQt6 6.1.
|
||||
# This is strictly a temporary private shim. Do not depend on it in your code.
|
||||
if hasattr(QtCore.Qt, 'AlignmentFlag') and not hasattr(QtCore.Qt, 'Alignment'):
|
||||
QtCore.Qt.Alignment = QtCore.Qt.AlignmentFlag
|
||||
if hasattr(QtCore.Qt, 'Orientation') and not hasattr(QtCore.Qt, 'Orientations'):
|
||||
QtCore.Qt.Orientations = QtCore.Qt.Orientation
|
||||
|
||||
# USE_XXX variables are deprecated
|
||||
USE_PYSIDE = QT_LIB == PYSIDE
|
||||
|
@ -826,9 +826,16 @@ class ROI(GraphicsObject):
|
||||
"""
|
||||
return True
|
||||
|
||||
def movePoint(self, handle, pos, modifiers=QtCore.Qt.KeyboardModifiers(0), finish=True, coords='parent'):
|
||||
def movePoint(self, handle, pos, modifiers=None, finish=True, coords='parent'):
|
||||
## called by Handles when they are moved.
|
||||
## pos is the new position of the handle in scene coords, as requested by the handle.
|
||||
if modifiers is None:
|
||||
try:
|
||||
# this works for PyQt6 6.1 and other bindings
|
||||
modifiers = QtCore.Qt.KeyboardModifier.NoModifier
|
||||
except AttributeError:
|
||||
# this works for PyQt6 6.0 and other bindings
|
||||
modifiers = QtCore.Qt.KeyboardModifiers(0)
|
||||
|
||||
newState = self.stateCopy()
|
||||
index = self.indexOfHandle(handle)
|
||||
@ -1454,7 +1461,14 @@ class Handle(UIGraphicsItem):
|
||||
self.currentPen = self.hoverPen
|
||||
self.movePoint(pos, ev.modifiers(), finish=False)
|
||||
|
||||
def movePoint(self, pos, modifiers=QtCore.Qt.KeyboardModifiers(0), finish=True):
|
||||
def movePoint(self, pos, modifiers=None, finish=True):
|
||||
if modifiers is None:
|
||||
try:
|
||||
# this works for PyQt6 6.1 and other bindings
|
||||
modifiers = QtCore.Qt.KeyboardModifier.NoModifier
|
||||
except AttributeError:
|
||||
# this works for PyQt6 6.0 and other bindings
|
||||
modifiers = QtCore.Qt.KeyboardModifiers(0)
|
||||
for r in self.rois:
|
||||
if not r.checkPointMove(self, pos, modifiers):
|
||||
return
|
||||
|
@ -259,6 +259,7 @@ class Renderer(GraphicsView):
|
||||
|
||||
def deserialize_wheel_event(self, wheel_event):
|
||||
pos, gpos, pixelDelta, angleDelta, btns, mods, phase, inverted = wheel_event
|
||||
if QT_LIB != 'PyQt6':
|
||||
btns = QtCore.Qt.MouseButtons(btns)
|
||||
mods = QtCore.Qt.KeyboardModifiers(mods)
|
||||
phase = QtCore.Qt.ScrollPhase(phase)
|
||||
|
Loading…
Reference in New Issue
Block a user