[PyQt] causes self to be owned by Qt instead of PyQt ???

Baz Walter bazwal at ftml.net
Thu Apr 2 19:56:11 BST 2015


On 02/04/15 19:37, Baz Walter wrote:
> On 02/04/15 18:33, Phil Thompson wrote:
>> On 02/04/2015 5:38 pm, Baz Walter wrote:
>>> On 02/04/15 17:18, Andreas Pakulat wrote:
>>>
>>> QAbstractItemModel.parent(QModelIndex) overloads QObject.parent(), so
>>> it is a bug in PyQt4/5 that it doesn't support the latter.
>>
>> Eh? The QAbstractItemModel parent() hides the QObject parent().
>
> No, it shouldn't do. A QAbstractItemModel is a QObject. It takes another
> QObject as its parent, not a QModelIndex:
>
>  >>> from PyQt4 import QtCore, QtGui
>  >>> app = QtGui.QApplication([])
>  >>> model = QtGui.QStandardItemModel(app)
>  >>> model.parent()
> <PyQt4.QtGui.QApplication object at 0x7f397aae0c18>
>  >>> model.parent(QtCore.QModelIndex())
> <PyQt4.QtCore.QModelIndex object at 0x7f3975078358>
>
> QAbstractItemModel::parent(QModelIndex) is virtual, but
> QObject::parent() isn't, so it cannot not be overridden.
>

Of course, I meant "it cannot be overridden".

PS: I tested most of the other built-in model classes, and it just seems 
to be QFileSystemModel that is lacking QObject::parent().

-- 
Regards
Baz Walter


More information about the PyQt mailing list