Merge pull request #287 from ales-erjavec/qt5-fix

Qt5 compatifility fixes
This commit is contained in:
Luke Campagnola 2016-04-04 13:06:32 -07:00
commit 63d12c1caa

View File

@ -148,7 +148,7 @@ elif QT_LIB == PYQT5:
# We're using PyQt5 which has a different structure so we're going to use a shim to # We're using PyQt5 which has a different structure so we're going to use a shim to
# recreate the Qt4 structure for Qt5 # recreate the Qt4 structure for Qt5
from PyQt5 import QtGui, QtCore, QtWidgets, Qt, uic from PyQt5 import QtGui, QtCore, QtWidgets, uic
try: try:
from PyQt5 import QtSvg from PyQt5 import QtSvg
except ImportError: except ImportError:
@ -159,10 +159,18 @@ elif QT_LIB == PYQT5:
pass pass
# Re-implement deprecated APIs # Re-implement deprecated APIs
def scale(self, sx, sy):
tr = self.transform() __QGraphicsItem_scale = QtWidgets.QGraphicsItem.scale
tr.scale(sx, sy)
self.setTransform(tr) def scale(self, *args):
if args:
sx, sy = args
tr = self.transform()
tr.scale(sx, sy)
self.setTransform(tr)
else:
return __QGraphicsItem_scale(self)
QtWidgets.QGraphicsItem.scale = scale QtWidgets.QGraphicsItem.scale = scale
def rotate(self, angle): def rotate(self, angle):
@ -181,8 +189,8 @@ elif QT_LIB == PYQT5:
self.setContentsMargins(i, i, i, i) self.setContentsMargins(i, i, i, i)
QtWidgets.QGridLayout.setMargin = setMargin QtWidgets.QGridLayout.setMargin = setMargin
def setResizeMode(self, mode): def setResizeMode(self, *args):
self.setSectionResizeMode(mode) self.setSectionResizeMode(*args)
QtWidgets.QHeaderView.setResizeMode = setResizeMode QtWidgets.QHeaderView.setResizeMode = setResizeMode