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. PySide6: Why QSpacerItem uses kwargs [hv]Data instead of [hv]Policy?

PySide6: Why QSpacerItem uses kwargs [hv]Data instead of [hv]Policy?

Scheduled Pinned Locked Moved Unsolved Qt for Python
4 Posts 2 Posters 564 Views
  • 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.
  • A Offline
    A Offline
    anonyumu
    wrote on last edited by anonyumu
    #1

    Could this be some sort of a bug? Or is it just undocumented/hard to find change?

    Got an error saying AttributeError: PySide6.QtWidgets.QSpacerItem.__init__(): unsupported keyword 'hPolicy', so checked Qt6 doc for changes, but everything seemed fine. After checking PySide6 doc it turned out that keyword args [hv]Policy were specified as [hv]Data in call signature, yet doc body still mentioned [hv]Policy...

    Update.

    Damn... The same happened with PySide6.QtGui.PySide6.QtGui.QPixmap.scaled: aspectRatioMode is aspectMode and transformMode is mode...

    eyllanescE 1 Reply Last reply
    0
    • A anonyumu

      Could this be some sort of a bug? Or is it just undocumented/hard to find change?

      Got an error saying AttributeError: PySide6.QtWidgets.QSpacerItem.__init__(): unsupported keyword 'hPolicy', so checked Qt6 doc for changes, but everything seemed fine. After checking PySide6 doc it turned out that keyword args [hv]Policy were specified as [hv]Data in call signature, yet doc body still mentioned [hv]Policy...

      Update.

      Damn... The same happened with PySide6.QtGui.PySide6.QtGui.QPixmap.scaled: aspectRatioMode is aspectMode and transformMode is mode...

      eyllanescE Offline
      eyllanescE Offline
      eyllanesc
      wrote on last edited by
      #2

      @anonyumu please provide a minimun and reproducible example

      If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        anonyumu
        wrote on last edited by
        #3

        Sorry it took so long...

        pip install PySide6==6.0.1

        PySide6.QtWidgets.QSpacerItem:

        from PySide6.QtWidgets import QSpacerItem, QSizePolicy
        
        QSpacerItem(0, 0, hPolicy = QSizePolicy.Expanding)
        QSpacerItem(0, 0, vPolicy = QSizePolicy.Fixed)
        

        PySide6.QtGui.QPixmap.scaled:

        from PySide6.QtCore import Qt, QSize
        from PySide6.QtGui import QPixmap
        from PySide6.QtWidgets import QApplication
        
        app = QApplication()
        
        QPixmap().scaled(QSize(640, 480), aspectRatioMode=Qt.IgnoreAspectRatio)
        QPixmap().scaled(QSize(640, 480), transformMode=Qt.FastTransformation)
        
        app.exec_()
        

        In both cases AttributeError: PySide6.{module}.{class}.{method}(): unsupported keyword '{kwarg}' is raised.

        eyllanescE 1 Reply Last reply
        0
        • A anonyumu

          Sorry it took so long...

          pip install PySide6==6.0.1

          PySide6.QtWidgets.QSpacerItem:

          from PySide6.QtWidgets import QSpacerItem, QSizePolicy
          
          QSpacerItem(0, 0, hPolicy = QSizePolicy.Expanding)
          QSpacerItem(0, 0, vPolicy = QSizePolicy.Fixed)
          

          PySide6.QtGui.QPixmap.scaled:

          from PySide6.QtCore import Qt, QSize
          from PySide6.QtGui import QPixmap
          from PySide6.QtWidgets import QApplication
          
          app = QApplication()
          
          QPixmap().scaled(QSize(640, 480), aspectRatioMode=Qt.IgnoreAspectRatio)
          QPixmap().scaled(QSize(640, 480), transformMode=Qt.FastTransformation)
          
          app.exec_()
          

          In both cases AttributeError: PySide6.{module}.{class}.{method}(): unsupported keyword '{kwarg}' is raised.

          eyllanescE Offline
          eyllanescE Offline
          eyllanesc
          wrote on last edited by eyllanesc
          #4

          @anonyumu It seems that it is a PySide6 bug that has changed the name of the kwargs, for example using help you get the names of the kwargs:

          dir(QSpacerItem)
          

          output

          Help on class QSpacerItem in module PySide6.QtWidgets:
          
          class QSpacerItem(QLayoutItem)
           |  QSpacerItem(self, w: int, h: int, hData: PySide6.QtWidgets.QSizePolicy.Policy = PySide6.QtWidgets.QSizePolicy.Policy.Minimum, vData: PySide6.QtWidgets.QSizePolicy.Policy = PySide6.QtWidgets.QSizePolicy.Policy.Minimum) -> None
           |  
           |  QSpacerItem(self, w: int, h: int, hData: PySide6.QtWidgets.QSizePolicy.Policy = PySide6.QtWidgets.QSizePolicy.Policy.Minimum, vData: PySide6.QtWidgets.QSizePolicy.Policy = PySide6.QtWidgets.QSizePolicy.Policy.Minimum) -> None
           |  
           |  Method resolution order:
           |      QSpacerItem
           |      QLayoutItem
           |      Shiboken.Object
           |      builtins.object
           |  
           |  Methods defined here:
           |  
           |  __delattr__(self, name, /)
           |      Implement delattr(self, name).
           |  
           |  __init__(self, w: int, h: int, hData: PySide6.QtWidgets.QSizePolicy.Policy = PySide6.QtWidgets.QSizePolicy.Policy.Minimum, vData: PySide6.QtWidgets.QSizePolicy.Policy = PySide6.QtWidgets.QSizePolicy.Policy.Minimum) -> None
           |      __init__(self, w: int, h: int, hData: PySide6.QtWidgets.QSizePolicy.Policy = PySide6.QtWidgets.QSizePolicy.Policy.Minimum, vData: PySide6.QtWidgets.QSizePolicy.Policy = PySide6.QtWidgets.QSizePolicy.Policy.Minimum) -> None
           |      
           |      Initialize self.  See help(type(self)) for accurate signature.
           |  
           |  __setattr__(self, name, value, /)
           |      Implement setattr(self, name, value).
           |  
           |  changeSize(self, w: int, h: int, hData: PySide6.QtWidgets.QSizePolicy.Policy = PySide6.QtWidgets.QSizePolicy.Policy.Minimum, vData: PySide6.QtWidgets.QSizePolicy.Policy = PySide6.QtWidgets.QSizePolicy.Policy.Minimum) -> None
           |      changeSize(self, w: int, h: int, hData: PySide6.QtWidgets.QSizePolicy.Policy = PySide6.QtWidgets.QSizePolicy.Policy.Minimum, vData: PySide6.QtWidgets.QSizePolicy.Policy = PySide6.QtWidgets.QSizePolicy.Policy.Minimum) -> None
           |  
           |  expandingDirections(self) -> PySide6.QtCore.Qt.Orientations
           |      expandingDirections(self) -> PySide6.QtCore.Qt.Orientations
           |  
           |  geometry(self) -> PySide6.QtCore.QRect
           |      geometry(self) -> PySide6.QtCore.QRect
           |  
           |  isEmpty(self) -> bool
           |      isEmpty(self) -> bool
           |  
           |  maximumSize(self) -> PySide6.QtCore.QSize
           |      maximumSize(self) -> PySide6.QtCore.QSize
           |  
           |  minimumSize(self) -> PySide6.QtCore.QSize
           |      minimumSize(self) -> PySide6.QtCore.QSize
           |  
           |  setGeometry(self, arg__1: PySide6.QtCore.QRect) -> None
           |      setGeometry(self, arg__1: PySide6.QtCore.QRect) -> None
           |  
           |  sizeHint(self) -> PySide6.QtCore.QSize
           |      sizeHint(self) -> PySide6.QtCore.QSize
           |  
           |  sizePolicy(self) -> PySide6.QtWidgets.QSizePolicy
           |      sizePolicy(self) -> PySide6.QtWidgets.QSizePolicy
           |  
           |  spacerItem(self) -> PySide6.QtWidgets.QSpacerItem
           |      spacerItem(self) -> PySide6.QtWidgets.QSpacerItem
           |  
           |  ----------------------------------------------------------------------
           |  Static methods defined here:
           |  
           |  __new__(*args, **kwargs) from Shiboken.ObjectType
           |      Create and return a new object.  See help(type) for accurate signature.
           |  
           |  ----------------------------------------------------------------------
           |  Methods inherited from QLayoutItem:
           |  
           |  alignment(self) -> PySide6.QtCore.Qt.Alignment
           |      alignment(self) -> PySide6.QtCore.Qt.Alignment
           |  
           |  controlTypes(self) -> PySide6.QtWidgets.QSizePolicy.ControlTypes
           |      controlTypes(self) -> PySide6.QtWidgets.QSizePolicy.ControlTypes
           |  
           |  hasHeightForWidth(self) -> bool
           |      hasHeightForWidth(self) -> bool
           |  
           |  heightForWidth(self, arg__1: int) -> int
           |      heightForWidth(self, arg__1: int) -> int
           |  
           |  invalidate(self) -> None
           |      invalidate(self) -> None
           |  
           |  layout(self) -> PySide6.QtWidgets.QLayout
           |      layout(self) -> PySide6.QtWidgets.QLayout
           |  
           |  minimumHeightForWidth(self, arg__1: int) -> int
           |      minimumHeightForWidth(self, arg__1: int) -> int
           |  
           |  setAlignment(self, a: PySide6.QtCore.Qt.Alignment) -> None
           |      setAlignment(self, a: PySide6.QtCore.Qt.Alignment) -> None
           |  
           |  widget(self) -> PySide6.QtWidgets.QWidget
           |      widget(self) -> PySide6.QtWidgets.QWidget
           |  
           |  ----------------------------------------------------------------------
           |  Data descriptors inherited from QLayoutItem:
           |  
           |  align
           |  
           |  ----------------------------------------------------------------------
           |  Methods inherited from Shiboken.Object:
           |  
           |  __getattribute__(self, name, /)
           |      Return getattr(self, name).
           |  
           |  ----------------------------------------------------------------------
           |  Data descriptors inherited from Shiboken.Object:
           |  
           |  __dict__
          

          Considering the above then the solution is:

          QSpacerItem(0, 0, hData = QSizePolicy.Expanding)
          QSpacerItem(0, 0, vData = QSizePolicy.Fixed)
          

          Same for scaled:

          help(QPixmap.scaled)
          
          Help on method_descriptor:
          
          scaled(...)
              scaled(self, s: PySide6.QtCore.QSize, aspectMode: PySide6.QtCore.Qt.AspectRatioMode = PySide6.QtCore.Qt.AspectRatioMode.IgnoreAspectRatio, mode: PySide6.QtCore.Qt.TransformationMode = PySide6.QtCore.Qt.TransformationMode.FastTransformation) -> PySide6.QtGui.QPixmap
              scaled(self, w: int, h: int, aspectMode: PySide6.QtCore.Qt.AspectRatioMode = PySide6.QtCore.Qt.AspectRatioMode.IgnoreAspectRatio, mode: PySide6.QtCore.Qt.TransformationMode = PySide6.QtCore.Qt.TransformationMode.FastTransformation) -> PySide6.QtGui.QPixmap
          

          then

          QPixmap().scaled(QSize(640, 480), aspectMode=Qt.AspectRatioMode.IgnoreAspectRatio)
          QPixmap().scaled(QSize(640, 480), mode=Qt.TransformationMode.FastTransformation)
          

          If you want me to help you develop some work then you can write to my email: e.yllanescucho@gmal.com.

          1 Reply Last reply
          1

          • Login

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