<?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[Why if no TreeWidgetItem was clicked the signal itemPressed no emitt?]]></title><description><![CDATA[<p dir="auto">Hi!<br />
I see the document say:</p>
<blockquote>
<p dir="auto">void QTreeWidget::itemPressed(QTreeWidgetItem * item, int column)</p>
<p dir="auto">This signal is emitted when the user presses a mouse button inside the widget.</p>
<p dir="auto">The specified item is the item that was clicked, or 0 if no item was clicked. The column is the item's column that was clicked, or -1 if no item was clicked.</p>
</blockquote>
<p dir="auto">When I connect itemPressed to My slot void EditCurrentItem(QTreeWidgetItem* currentItem, int column):</p>
<pre><code>connect(m_ui.m_TreeWidget,SIGNAL(itemPressed(QTreeWidgetItem*, int)),this,SLOT(EditCurrentItem(QTreeWidgetItem*, int)));
</code></pre>
<p dir="auto">if the item that was clicked the sinal will be emitted. But when I cancel click item(click on the blank space Inside the TreeWidget), no itemPressed be emit? I don't knowWhy.</p>
<p dir="auto"><img src="http://img.blog.csdn.net/20160204125920043" alt="image1" class=" img-fluid img-markdown" /></p>
<p dir="auto"><img src="http://img.blog.csdn.net/20160204125927272" alt="image2" class=" img-fluid img-markdown" /></p>
<p dir="auto">the SLOT void EditCurrentItem(QTreeWidgetItem* currentItem, int column) as below:</p>
<pre><code>void QuesManager::EditCurrentItem(QTreeWidgetItem* currentItem, int column)
{
	if(currentItem != 0)
	{
		m_ui.m_Title-&gt;setText(currentItem-&gt;text(2));
		m_ui.m_Ans-&gt;setText(currentItem-&gt;text(3));
	}
	else
	{
		m_ui.m_Title-&gt;setText("");
		m_ui.m_Ans-&gt;setText("");
	}
}
</code></pre>
<p dir="auto">The small project had been upload to the Attachment.(My Qt version is 5.5 and using VS2010)<br />
Thanks help me!</p>
<p dir="auto">See Attachment:<br />
<a href="https://github.com/ljcduo/TempAns1" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/ljcduo/TempAns1</a></p>
]]></description><link>https://forum.qt.io/topic/63779/why-if-no-treewidgetitem-was-clicked-the-signal-itempressed-no-emitt</link><generator>RSS for Node</generator><lastBuildDate>Wed, 19 Aug 2026 04:58:30 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/63779.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 04 Feb 2016 04:20:01 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Why if no TreeWidgetItem was clicked the signal itemPressed no emitt? on Fri, 05 Feb 2016 05:41:25 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jsulm">@<bdi>jsulm</bdi></a> Thanks! I Change itemPressed to itemSelectionChanged, It works!</p>
]]></description><link>https://forum.qt.io/post/311582</link><guid isPermaLink="true">https://forum.qt.io/post/311582</guid><dc:creator><![CDATA[ljc123456gogo]]></dc:creator><pubDate>Fri, 05 Feb 2016 05:41:25 GMT</pubDate></item><item><title><![CDATA[Reply to Why if no TreeWidgetItem was clicked the signal itemPressed no emitt? on Thu, 04 Feb 2016 05:20:47 GMT]]></title><description><![CDATA[<p dir="auto">Hi!<br />
Well, why should this signal be emitted if you do not click on an item?<br />
It is only emitted if you click on an item (that's why it is called itemPressed) if you click on something else it is not emitted.<br />
If you want to know when nothing is selected then use <a href="http://doc.qt.io/qt-5/qtreewidget.html#itemSelectionChanged" target="_blank" rel="noopener noreferrer nofollow ugc">http://doc.qt.io/qt-5/qtreewidget.html#itemSelectionChanged</a>.</p>
]]></description><link>https://forum.qt.io/post/311368</link><guid isPermaLink="true">https://forum.qt.io/post/311368</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Thu, 04 Feb 2016 05:20:47 GMT</pubDate></item></channel></rss>