Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-1974

Regression: Usage of PySide6 enums via QVariant broken

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • None
    • 6.3.1
    • PySide
    • None
    • All
    • All
    • f8e945097c (pyside/pyside-setup/dev) eb845eb705 (pyside/pyside-setup/6.3) eb845eb705 (pyside/tqtc-pyside-setup/6.3) f8e945097c (pyside/tqtc-pyside-setup/dev) eb845eb705 (pyside/pyside-setup/wip/6.3_pypy) eb845eb705 (pyside/tqtc-pyside-setup/wip/6.3_pypy)

    Description

      Returning a PySide 6 enum for role Qt.ItemDataRole.TextAlignmentRole from the data() method of a model is broken in Qt 6.3.1. Sample code below:

      from PySide6.QtCore import Qt, QAbstractTableModel
      from PySide6.QtWidgets import QTableView, QApplication
      class M(QAbstractTableModel):    
          def rowCount(self, *a):
              return 1
          def columnCount(self, *a):
              return 1
          def data(self, index, role):
              if role == Qt.ItemDataRole.DisplayRole:
                  return 'testing'
              if role == Qt.ItemDataRole.TextAlignmentRole:
                  ans = Qt.AlignmentFlag.AlignVCenter | Qt.AlignmentFlag.AlignHCenter
                  return ans
      app = QApplication([])
      v = QTableView()
      v.setModel(M())
      v.resize(v.sizeHint())
      v.show()
      app.exec()
      

      The string testing is displayed in the top left corner instead of centered. Changing return ans to return int(ans) gives the expected behavior. Therefore, conversion of the PySide6 enum to int is failing. This used to work fine with Qt 6.2.3. It also fails with PyQt6.

      Attachments

        1. pyside1964_pyqt63.png
          pyside1964_pyqt63.png
          27 kB
        2. pyside1974_list.py
          2 kB
        3. pyside1974_p515.png
          pyside1974_p515.png
          23 kB
        4. pyside1974_p621.png
          pyside1974_p621.png
          26 kB
        5. pyside1974_p623.png
          pyside1974_p623.png
          23 kB
        6. pyside1974_p631.png
          pyside1974_p631.png
          23 kB
        7. pyside1974_pyqt.py
          2 kB
        8. pyside1974.py
          2 kB

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              shpremna Shyamnath Premnadh
              kovidgoyal Kovid Goyal
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes