<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to override QAbstractItemModel::parent() in QSortFilterProxyModel?]]></title><description><![CDATA[<p dir="auto">I want the QAbstractItemModel::parent() function to return different ancestors at will and the tree structure to change accordingly. To do this, I redefine parent() in QSortFilterProxyModel, but this does not give the desired effect. Is there any working way to override QAbstractItemModel::parent()?</p>
]]></description><link>https://forum.qt.io/topic/142147/how-to-override-qabstractitemmodel-parent-in-qsortfilterproxymodel</link><generator>RSS for Node</generator><lastBuildDate>Fri, 10 Apr 2026 00:07:01 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/142147.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 12 Jan 2023 08:53:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to override QAbstractItemModel::parent() in QSortFilterProxyModel? on Fri, 13 Jan 2023 07:23:29 GMT]]></title><description><![CDATA[<p dir="auto">Thanks for the answer, I'll try it and say what happened.</p>
]]></description><link>https://forum.qt.io/post/743693</link><guid isPermaLink="true">https://forum.qt.io/post/743693</guid><dc:creator><![CDATA[Ilya Andreev]]></dc:creator><pubDate>Fri, 13 Jan 2023 07:23:29 GMT</pubDate></item><item><title><![CDATA[Reply to How to override QAbstractItemModel::parent() in QSortFilterProxyModel? on Fri, 13 Jan 2023 03:53:30 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ilya-andreev">@<bdi>Ilya-Andreev</bdi></a> said in <a href="/post/743563">How to override QAbstractItemModel::parent() in QSortFilterProxyModel?</a>:</p>
<blockquote>
<p dir="auto">I want the QAbstractItemModel::parent() function to return different ancestors at will and the tree structure to change accordingly. To do this, I redefine parent() in QSortFilterProxyModel, but this does not give the desired effect. Is there any working way to override QAbstractItemModel::parent()?</p>
</blockquote>
<p dir="auto">How is the view supposed to know that it needs to check the parent() of a particular item again?</p>
<p dir="auto">The intended path to implement this is via <a href="https://doc.qt.io/qt-6/qabstractitemmodel.html#beginMoveRows" target="_blank" rel="noopener noreferrer nofollow ugc">QAbstractItemModel::beginMoveRows</a> and <a href="https://doc.qt.io/qt-6/qabstractitemmodel.html#endMoveRows" target="_blank" rel="noopener noreferrer nofollow ugc">QAbstractItemMode::endMoveRows</a>, or emit the signals mentioned in the first link directly. If the change is complicated enough, use QAbstractItemModel::beginResetModel and QAbstractItemModel::endResetModel.</p>
]]></description><link>https://forum.qt.io/post/743672</link><guid isPermaLink="true">https://forum.qt.io/post/743672</guid><dc:creator><![CDATA[jeremy_k]]></dc:creator><pubDate>Fri, 13 Jan 2023 03:53:30 GMT</pubDate></item><item><title><![CDATA[Reply to How to override QAbstractItemModel::parent() in QSortFilterProxyModel? on Thu, 12 Jan 2023 13:22:22 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a> Unfortunately, overriding this function has no effect on the tree structure. Perhaps there is another way to redefine the parent without changing the original elements.</p>
]]></description><link>https://forum.qt.io/post/743595</link><guid isPermaLink="true">https://forum.qt.io/post/743595</guid><dc:creator><![CDATA[Ilya Andreev]]></dc:creator><pubDate>Thu, 12 Jan 2023 13:22:22 GMT</pubDate></item><item><title><![CDATA[Reply to How to override QAbstractItemModel::parent() in QSortFilterProxyModel? on Thu, 12 Jan 2023 13:16:26 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ilya-andreev">@<bdi>Ilya-Andreev</bdi></a> said in <a href="/post/743570">How to override QAbstractItemModel::parent() in QSortFilterProxyModel?</a>:</p>
<blockquote>
<p dir="auto"><code>QModelIndex QAbstractItemModel::parent(const QModelIndex &amp;index) const</code></p>
</blockquote>
<p dir="auto">Well since that is virtual you can in principle override the override in <code>QSortFilterProxyModel</code> by sub-classing that.  Whether it will behave as you desire/safely I do not know.</p>
]]></description><link>https://forum.qt.io/post/743594</link><guid isPermaLink="true">https://forum.qt.io/post/743594</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Thu, 12 Jan 2023 13:16:26 GMT</pubDate></item><item><title><![CDATA[Reply to How to override QAbstractItemModel::parent() in QSortFilterProxyModel? on Thu, 12 Jan 2023 10:48:33 GMT]]></title><description><![CDATA[<p dir="auto">I think I need to clarify: I want to redefine the</p>
<pre><code>QModelIndex QAbstractItemModel::parent(const QModelIndex &amp;index) const
</code></pre>
<p dir="auto">not</p>
<pre><code>QObject *  QAbstractItemModel::parent()
</code></pre>
]]></description><link>https://forum.qt.io/post/743570</link><guid isPermaLink="true">https://forum.qt.io/post/743570</guid><dc:creator><![CDATA[Ilya Andreev]]></dc:creator><pubDate>Thu, 12 Jan 2023 10:48:33 GMT</pubDate></item><item><title><![CDATA[Reply to How to override QAbstractItemModel::parent() in QSortFilterProxyModel? on Thu, 12 Jan 2023 09:42:18 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/ilya-andreev">@<bdi>Ilya-Andreev</bdi></a> I don't understand your use case. A QObject based object can only have ONE parent, returning arbitrary object as parent which is not actual parent will not change the parent/child relationship.</p>
]]></description><link>https://forum.qt.io/post/743565</link><guid isPermaLink="true">https://forum.qt.io/post/743565</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Thu, 12 Jan 2023 09:42:18 GMT</pubDate></item></channel></rss>