From pykde Thu Apr 02 22:01:15 2015 From: Andreas Pakulat Date: Thu, 02 Apr 2015 22:01:15 +0000 To: pykde Subject: Re: [PyQt] causes self to be owned by Qt instead of PyQt ??? Message-Id: X-MARC-Message: https://marc.info/?l=pykde&m=142801222702802 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--===============8702426436694154274==" --===============8702426436694154274== Content-Type: multipart/alternative; boundary=001a11394c8e7bf3540512c4f8fa --001a11394c8e7bf3540512c4f8fa Content-Type: text/plain; charset=UTF-8 Hi Phil, On Thu, Apr 2, 2015 at 11:11 PM, Phil Thompson wrote: > On 02/04/2015 7:37 pm, 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() >>>>> >>>> >> >>> model.parent(QtCore.QModelIndex()) >>>>> >>>> >> >> QAbstractItemModel::parent(QModelIndex) is virtual, but >> QObject::parent() isn't, so it cannot not be overridden. >> > > So the attached C++ code should compile? Not without a fix for qfilesystemmodel.h. qabstractitemmodel.h as well as qstandarditemmodel.h (and probably other qaim subclasses in qt) explicitly 'reuse' QObject::parent using something like: #ifdef Q_NO_USING_KEYWORD inline QObject *parent() const { return QObject::parent(); } #else using QObject::parent; #endif For qfilesystemmodel.h this is missing and hence one cannot call QObject::parent() with a pointer or instance of it. Andreas --001a11394c8e7bf3540512c4f8fa Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
Hi Phil,

On Thu, Apr 2, 2015 at 11:11 PM, Phil Thompson &l= t;phil@riv= erbankcomputing.com> wrote:
On 02/04/2015 7:37 pm, 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(), s= o
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 =3D QtGui.QApplication([])
model =3D 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.

So the attached C++ code should compile?

No= t without a fix for qfilesystemmodel.h. qabstractitemmodel.h as well as qst= andarditemmodel.h (and probably other qaim subclasses in qt) explicitly = 9;reuse' QObject::parent using something like:

#ifdef Q_NO_USING_KEYWORD
=C2=A0 =C2=A0 inline QObject *parent()= const { return QObject::parent(); }
#else
=C2=A0 =C2= =A0 using QObject::parent;
#endif

For qf= ilesystemmodel.h this is missing and hence one cannot call QObject::parent(= ) with a pointer or instance of it.

Andreas
<= /div>
--001a11394c8e7bf3540512c4f8fa-- --===============8702426436694154274== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KUHlRdCBtYWls aW5nIGxpc3QgICAgUHlRdEByaXZlcmJhbmtjb21wdXRpbmcuY29tCmh0dHA6Ly93d3cucml2ZXJi YW5rY29tcHV0aW5nLmNvbS9tYWlsbWFuL2xpc3RpbmZvL3B5cXQ= --===============8702426436694154274==--