[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] causes self to be owned by Qt instead of PyQt ???
From:       Andreas Pakulat <apaku () gmx ! de>
Date:       2015-04-02 22:01:15
Message-ID: CAExHGmQoLeUvSM-fNC-sJQVejw0aMKuLeUy_3kisxmqww1hb3A () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Hi Phil,

On Thu, Apr 2, 2015 at 11:11 PM, Phil Thompson <phil@riverbankcomputing.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(), 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.
>>
>
> 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

[Attachment #5 (text/html)]

<div dir="ltr">Hi Phil,<div class="gmail_extra"><br><div class="gmail_quote">On Thu, \
Apr 2, 2015 at 11:11 PM, Phil Thompson <span dir="ltr">&lt;<a \
href="mailto:phil@riverbankcomputing.com" \
target="_blank">phil@riverbankcomputing.com</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span \
class="">On 02/04/2015 7:37 pm, Baz Walter wrote:<br> <blockquote class="gmail_quote" \
style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
 On 02/04/15 18:33, Phil Thompson wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
 On 02/04/2015 5:38 pm, Baz Walter wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
 On 02/04/15 17:18, Andreas Pakulat wrote:<br>
<br>
QAbstractItemModel.parent(<u></u>QModelIndex) overloads QObject.parent(), so<br>
it is a bug in PyQt4/5 that it doesn&#39;t support the latter.<br>
</blockquote>
<br>
Eh? The QAbstractItemModel parent() hides the QObject parent().<br>
</blockquote>
<br>
No, it shouldn&#39;t do. A QAbstractItemModel is a QObject. It takes<br>
another QObject as its parent, not a QModelIndex:<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><blockquote \
class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><blockquote \
class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
 from PyQt4 import QtCore, QtGui<br>
app = QtGui.QApplication([])<br>
model = QtGui.QStandardItemModel(app)<br>
model.parent()<br>
</blockquote></blockquote></blockquote>
&lt;PyQt4.QtGui.QApplication object at 0x7f397aae0c18&gt;<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><blockquote \
class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><blockquote \
class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
 model.parent(QtCore.<u></u>QModelIndex())<br>
</blockquote></blockquote></blockquote>
&lt;PyQt4.QtCore.QModelIndex object at 0x7f3975078358&gt;<br>
<br>
QAbstractItemModel::parent(<u></u>QModelIndex) is virtual, but<br>
QObject::parent() isn&#39;t, so it cannot not be overridden.<br>
</blockquote>
<br></span>
So the attached C++ code should compile?</blockquote><div><br></div><div>Not without \
a fix for qfilesystemmodel.h. qabstractitemmodel.h as well as qstandarditemmodel.h \
(and probably other qaim subclasses in qt) explicitly &#39;reuse&#39; QObject::parent \
using something like:</div><div><br></div><div>#ifdef Q_NO_USING_KEYWORD</div><div>   \
inline QObject *parent() const { return QObject::parent(); \
}</div><div>#else</div><div>      using \
QObject::parent;</div><div>#endif</div><div><br></div><div>For qfilesystemmodel.h \
this is missing and hence one cannot call QObject::parent() with a pointer or \
instance of it.</div><div><br></div><div>Andreas</div></div></div></div>


[Attachment #6 (text/plain)]

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic