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

model.index() returns wrong class

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P3: Somewhat important
    • None
    • 6.1.3
    • Documentation, PySide
    • None
    • Debian 10.10 Buster
      PySide2 5.15.2
      Python 3.7.3
    • Linux/X11

    Description

      documentation:
      https://doc.qt.io/qtforpython-5/PySide2/QtCore/QModelIndex.html#PySide2.QtCore.PySide2.QtCore.QModelIndex.model

      says, the return type of model() is a

      QAbstractItemModel,

      but print(type(model_index.model())) shows

      <class 'PySide2.QtGui.QStandardItemModel'>
      

      (run the attached Python script)

      problem:

      modelIndex.model() returns QStandardItemModel
      modelIndex.model() should return QAbstractItemModel

      the difference are the signatures:

      (1) modelIndex.model().index(row, col ) for QStandardItemModel
      (2) modelIndex.model().index(row, col, parentIndex) for QAbstractItemModel

      so,
      with (1) I never get the proper item in non-trivial trees,
      which (2) would allow

      I guess that QStandardItemModel.index() has inadvertentlt dropped the 3rd parameter, because just the first two does not make sense.

      Attachments

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

        Activity

          People

            kleint Friedemann Kleint
            nst0022 Detlev Schmidtke
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes