<?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[Clearing a QTreeWidget in CustomContextMenuRequest causes crash]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I'm struggling to get the following work:<br />
Ive connected a CustomContextMenuRequest to a QWidgetTree and indeed the menu pops open. But, however, when I want to clear this QWidgetTree in this request I get a null pointer exception. When i run this piece of code in another place or slot it works just fine.</p>
<p dir="auto">When there are multiple items present in the treewidget, i can delete them one for one, and everything works fine, but when I delete the last one the exception occurs again.</p>
<pre><code>void N3LAB_Software::contextMenuTree(const QPoint&amp; pos){
this-&gt;objectList-&gt;clear(); % The QTreeWidget
}

</code></pre>
<p dir="auto">Does somebody know whats causing this problem or how to fix this?</p>
<p dir="auto">Thanks,</p>
<p dir="auto">Perry</p>
<p dir="auto">Ps:<br />
Im using Qt 5.6 with visual studio 2015</p>
]]></description><link>https://forum.qt.io/topic/80970/clearing-a-qtreewidget-in-customcontextmenurequest-causes-crash</link><generator>RSS for Node</generator><lastBuildDate>Fri, 17 Apr 2026 18:53:44 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/80970.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 04 Jul 2017 14:54:32 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Clearing a QTreeWidget in CustomContextMenuRequest causes crash on Tue, 04 Jul 2017 20:15:26 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/vronin">@<bdi>VRonin</bdi></a> said in <a href="/post/403004">Clearing a QTreeWidget in CustomContextMenuRequest causes crash</a>:</p>
<blockquote>
<p dir="auto">QTreeWidgetItem</p>
</blockquote>
<p dir="auto">Thank you very much, that I did not see this.</p>
<p dir="auto">The changedModelSelection(QTreeWidgetItem* currentItem, QTreeWidgetItem* oldItem) which is called when a selection is changed in the tree wants to do an update, but as there are no objects left the currentItem is null and there for causes an exception when I want to do something with it.</p>
<p dir="auto">4 days strugling for this, haha.</p>
]]></description><link>https://forum.qt.io/post/403020</link><guid isPermaLink="true">https://forum.qt.io/post/403020</guid><dc:creator><![CDATA[PerryKipKerrie]]></dc:creator><pubDate>Tue, 04 Jul 2017 20:15:26 GMT</pubDate></item><item><title><![CDATA[Reply to Clearing a QTreeWidget in CustomContextMenuRequest causes crash on Tue, 04 Jul 2017 18:48:38 GMT]]></title><description><![CDATA[<p dir="auto">Crash seems to be in <code>N3LAB_Software::changedModelSelection(QTreeWidgetItem * currentItem, QTreeWidgetItem * oldItem) Line 276</code> almost surely you are trying to use an item that was deleted. can you post the code of that method?</p>
]]></description><link>https://forum.qt.io/post/403004</link><guid isPermaLink="true">https://forum.qt.io/post/403004</guid><dc:creator><![CDATA[VRonin]]></dc:creator><pubDate>Tue, 04 Jul 2017 18:48:38 GMT</pubDate></item><item><title><![CDATA[Reply to Clearing a QTreeWidget in CustomContextMenuRequest causes crash on Tue, 04 Jul 2017 18:38:48 GMT]]></title><description><![CDATA[<p dir="auto">Sure, here it is</p>
<pre><code>Qt5Widgetsd.dll!QTreeWidgetItem::text(int column) Line 106	C++
N3LAB_Software.exe!N3LAB_Software::changedModelSelection(QTreeWidgetItem * currentItem, QTreeWidgetItem * oldItem) Line 276	C++
 	N3LAB_Software.exe!N3LAB_Software::qt_static_metacall(QObject * _o, QMetaObject::Call _c, int _id, void * * _a) Line 108	C++
 	Qt5Cored.dll!QMetaObject::activate(QObject * sender, int signalOffset, int local_signal_index, void * * argv) Line 3742	C++
 	Qt5Cored.dll!QMetaObject::activate(QObject * sender, const QMetaObject * m, int local_signal_index, void * * argv) Line 3603	C++
 	Qt5Widgetsd.dll!QTreeWidget::currentItemChanged(QTreeWidgetItem * _t1, QTreeWidgetItem * _t2) Line 441	C++
 	Qt5Widgetsd.dll!QTreeWidgetPrivate::_q_emitCurrentItemChanged(const QModelIndex &amp; current, const QModelIndex &amp; previous) Line 2303	C++
 	Qt5Widgetsd.dll!QTreeWidget::qt_static_metacall(QObject * _o, QMetaObject::Call _c, int _id, void * * _a) Line 212	C++
 	Qt5Cored.dll!QMetaObject::activate(QObject * sender, int signalOffset, int local_signal_index, void * * argv) Line 3742	C++
 	Qt5Cored.dll!QMetaObject::activate(QObject * sender, const QMetaObject * m, int local_signal_index, void * * argv) Line 3603	C++
 	Qt5Cored.dll!QItemSelectionModel::currentChanged(const QModelIndex &amp; _t1, const QModelIndex &amp; _t2) Line 488	C++
 	Qt5Cored.dll!QItemSelectionModel::clearCurrentIndex() Line 1320	C++
 	Qt5Cored.dll!QItemSelectionModel::clear() Line 1308	C++
 	Qt5Widgetsd.dll!QTreeWidget::clear() Line 3258	C++
 	N3LAB_Software.exe!N3LAB_Software::contextMenuTree(const QPoint &amp; pos) Line 175	C++
</code></pre>
]]></description><link>https://forum.qt.io/post/403002</link><guid isPermaLink="true">https://forum.qt.io/post/403002</guid><dc:creator><![CDATA[PerryKipKerrie]]></dc:creator><pubDate>Tue, 04 Jul 2017 18:38:48 GMT</pubDate></item><item><title><![CDATA[Reply to Clearing a QTreeWidget in CustomContextMenuRequest causes crash on Tue, 04 Jul 2017 16:10:47 GMT]]></title><description><![CDATA[<p dir="auto">Can you post your stack trace at the moment of the crash?</p>
]]></description><link>https://forum.qt.io/post/402985</link><guid isPermaLink="true">https://forum.qt.io/post/402985</guid><dc:creator><![CDATA[VRonin]]></dc:creator><pubDate>Tue, 04 Jul 2017 16:10:47 GMT</pubDate></item></channel></rss>