Unsolved Possible bug where keyword arguments don't work in PySide2 when they do in PyQt5
-
I made a resizable image class, and I'm using
transformMode=QtCore.Qt.SmoothTransformation
when scaling. It works fine in PyQt5, but it is ignored in PySide2. Instead you can only pass it in as a regular argument, which means you've got to specifically set everything before it too, such asaspectRatioMode
, and that's not quite as pythonic.
I even tried using**{QtCore.Qt.TransformationMode: QtCore.Qt.SmoothTransformation}
, as PySide2 says it internally uses that, but it was also ignored.Here is what it is supposed to look like (PyQt5):
Here is what it looks like under PySide2:
Btw, if anyone wants a quick try, the particular line is here, to run just clone the repo and run
load_gui.py
. -
Hi @PeterH92 ,
I checked your Code.
I think that aspectMode arguments are probably missing at Qt for Python(PySide2).See Document as below
https://doc-snapshots.qt.io/qtforpython/PySide2/QtGui/QPixmap.html#PySide2.QtGui.PySide2.QtGui.QPixmap.scaled -
Thanks for the link, looks like PyQt's
transformMode
is just namedmode
in PySide2.I think this is the first difference I've actually seen, at least in my opinion though, PyQt's version is what it should be.
-
PyQt's version is what it should be.
I'm not really familiar with PyQt5. Therefore, I don't know why it hasn't happened.
Because I can't generate the same environment.Can you try the following?
Please addaspectMode = QtCore.Qt.IgnoreAspectRatio
as 3rd argument.-31: scaled_pixmap = self._pixmapOriginal.scaled(self._pixmapWidth * size_mult, self._pixmapHeight * size_mult, transformMode=QtCore.Qt.SmoothTransformation) +31: scaled_pixmap = self._pixmapOriginal.scaled(self._pixmapWidth * size_mult, self._pixmapHeight * size_mult, aspectMode=QtCore.Qt.IgnoreAspectRatio, transformMode=QtCore.Qt.SmoothTransformation)
-
That still has the same problem, just did a quick test and it seems PySide 1 has the same behaviour.
Doesn't work:
aspectMode=QtCore.Qt.IgnoreAspectRatio, transformMode=QtCore.Qt.SmoothTransformation
Works:aspectMode=QtCore.Qt.IgnoreAspectRatio, mode=QtCore.Qt.SmoothTransformation
It's not a huge issue, just seems a bit inconsistent, especially when it says it's a
QtCore.Qt.TransformationMode
parameter in tracebacks.(I'm lucky I noticed this reply just now haha, turns out I'd accidentally deleted the UI code yesterday, fortunately was still in my undo history)