PySide Bugzilla Closed for New Bugs

PySide is now a Qt Add-on and uses the Qt Project's JIRA Bug Tracker instead of this Bugzilla instance. This Bugzilla is left for reference purposes.

Bug 299 - Possible bug in PySide.QtCore.QModelIndex
: Possible bug in PySide.QtCore.QModelIndex
Status: CLOSED DUPLICATE of bug 295
Product: PySide
Classification: Unclassified
Component: QtCore
: HEAD
: All All
: P5 normal
Assigned To: renato filho
:
:
:
  Show dependency treegraph
 
Reported: 2010-08-16 06:08 EEST by Matti Airas
Modified: 2010-09-10 19:27 EEST (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matti Airas 2010-08-16 06:08:37 EEST
While adapting my application to the new 0.4.1 (Maemo Fremantle) release, I hit
a possible bug (I mean, everything used to work just fine with PySide 0.3.x); I
attached a sample code to this message which triggers this error:

Error calling slot "openSubWin"
Traceback (most recent call last):
  File "pyside-example.py", line 21, in openSubWin
    self.subWindow.show()       
NotImplementedError: pure virtual method 'QAbstractListModel.rowCount()' not
implemented.
Traceback (most recent call last):
  File "pyside-example.py", line 65, in <module>
    sys.exit(app.exec_())
NotImplementedError: pure virtual method 'QAbstractListModel.rowCount()' not
implemented.

The offending line is number 53 in function "data":

    def data(self,index = QModelIndex(),role = Qt.DisplayRole):
----> if index.isValid() & (index.row() >= 0) & (index.row() <
index.model().rowCount()): <----
            if role == Qt.DisplayRole:
                return self.__items[index.row()]
            else:
                return None
        else:
            return None

accessing the data model using index.model() seems to cause the vanishing of
the (re)definition of the "rowCount" method; if we change the line in:

   if index.isValid() & (index.row() >= 0) & (index.row() < self.rowCount()):

it works as expected, but sometimes this is not possible (inside a custom item
delegate class, for example, its methods receive a QModelIndex instance as a
parameter, and I need its model() property to properly work).

--------

Just to add some detail: there are situations when calling the rowCount()
method through QModelIndex.model() works just fine, the error (if it turns to
be an error) seems to be limited to instances of subclasses of
QAbstractListModel and QStyledItemDelegate.
Comment 1 Hugo Parente Lima 2010-08-16 10:27:12 EEST
The problem is that when you call QModelIndex::model, PySide sets the
QModelIndex as parent of the model returned. This was fixed last week.

*** This bug has been marked as a duplicate of bug 295 ***