pyqt4topyqt5
pyqt4topyqt5 copied to clipboard
QGraphicsItem subclasses init refactoring bug
It seems that all initializations of QGraphicsItem subclasses are refactored in this way:
class MyEllipse(QtGui.QGraphicsEllipseItem):
+class MyEllipse(QtWidgets.QGraphicsEllipseItem):
def __init__(self, radius=5.0):
- super(MyEllipse, self).__init__(-radius/2, -radius/2, radius, radius)
+ super(MyEllipse, self).__init__(-radius/2, -radius/2, radius)
+ if radius is not None: radius.addItem(self)
The last argument is assumed to be scene
and the addition to the scene is moved to a separate line. This assumption is not always true, in the sample above, the arguments are x, y, width, height
and the addition to the scene
is done elsewhere.
Workaround
Review the automatic changes using git.
changes not commited yet:
git diff --no-color > diff.txt
already commited changes:
git log # find the commit with changes done by pyqt4topyqt5
git show <commit> --no-color > diff.txt
Find new lines with addItem
text using regexp: ^\+.*addItem
(e.g. with less diff.txt
).