Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Possible bug where keyword arguments don't work in PySide2 when they do in PyQt5
Forum Updated to NodeBB v4.3 + New Features

Possible bug where keyword arguments don't work in PySide2 when they do in PyQt5

Scheduled Pinned Locked Moved Unsolved Qt for Python
5 Posts 2 Posters 1.4k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    PeterH92
    wrote on 2 Jan 2019, 11:07 last edited by PeterH92 1 Feb 2019, 11:10
    #1

    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 as aspectRatioMode, 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):

    PyQt5

    Here is what it looks like under PySide2:

    PySide2

    Btw, if anyone wants a quick try, the particular line is here, to run just clone the repo and run load_gui.py.

    K 1 Reply Last reply 7 Jan 2019, 06:43
    0
    • P PeterH92
      2 Jan 2019, 11:07

      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 as aspectRatioMode, 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):

      PyQt5

      Here is what it looks like under PySide2:

      PySide2

      Btw, if anyone wants a quick try, the particular line is here, to run just clone the repo and run load_gui.py.

      K Offline
      K Offline
      KazuoAsano
      Qt Champions 2018
      wrote on 7 Jan 2019, 06:43 last edited by
      #2

      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

      1 Reply Last reply
      0
      • P Offline
        P Offline
        PeterH92
        wrote on 7 Jan 2019, 11:54 last edited by
        #3

        Thanks for the link, looks like PyQt's transformMode is just named mode 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.

        K 1 Reply Last reply 8 Jan 2019, 04:39
        0
        • P PeterH92
          7 Jan 2019, 11:54

          Thanks for the link, looks like PyQt's transformMode is just named mode 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.

          K Offline
          K Offline
          KazuoAsano
          Qt Champions 2018
          wrote on 8 Jan 2019, 04:39 last edited by
          #4

          @PeterH92,

          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 add aspectMode = 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)
          
          1 Reply Last reply
          0
          • P Offline
            P Offline
            PeterH92
            wrote on 9 Jan 2019, 16:04 last edited by PeterH92 1 Sept 2019, 16:07
            #5

            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)

            1 Reply Last reply
            0

            1/5

            2 Jan 2019, 11:07

            • Login

            • Login or register to search.
            1 out of 5
            • First post
              1/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved