<?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[QTableView clicked() versus doubleClicked()]]></title><description><![CDATA[<p dir="auto">I capture the TableView clicked(signal) in my code which works fine if I want the user to select a single row.</p>
<p dir="auto">Unfortunately I also get this signal if the Ctrl or Shift keys were pressed that time the table was clicked on, and also when the user has <strong>double</strong> clicked a cell in the table view to edit a cell.</p>
<p dir="auto">Further experimentation shows that I actually seem to require to <em><strong>triple</strong></em> click to get the item editor to open!!!</p>
<p dir="auto">What do I need to do so I only get the clicked signal for a single click without modifiers?  I still want the Ctrl-Click and Shift-Click actions to select ...</p>
<p dir="auto">And so the a double click will work to open the item editor!</p>
<p dir="auto">Thanks<br />
David</p>
]]></description><link>https://forum.qt.io/topic/139616/qtableview-clicked-versus-doubleclicked</link><generator>RSS for Node</generator><lastBuildDate>Thu, 05 Nov 2026 02:13:28 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/139616.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 27 Sep 2022 15:23:05 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QTableView clicked() versus doubleClicked() on Wed, 05 Oct 2022 09:44:58 GMT]]></title><description><![CDATA[<p dir="auto">It behaves as I would expect and hope on Qt 6.4.0 😊</p>
<p dir="auto">David</p>
]]></description><link>https://forum.qt.io/post/731392</link><guid isPermaLink="true">https://forum.qt.io/post/731392</guid><dc:creator><![CDATA[Perdrix]]></dc:creator><pubDate>Wed, 05 Oct 2022 09:44:58 GMT</pubDate></item><item><title><![CDATA[Reply to QTableView clicked() versus doubleClicked() on Sun, 02 Oct 2022 18:02:17 GMT]]></title><description><![CDATA[<p dir="auto">Then please share a minimal compilable example that shows this behaviour.</p>
]]></description><link>https://forum.qt.io/post/731089</link><guid isPermaLink="true">https://forum.qt.io/post/731089</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Sun, 02 Oct 2022 18:02:17 GMT</pubDate></item><item><title><![CDATA[Reply to QTableView clicked() versus doubleClicked() on Fri, 30 Sep 2022 20:23:07 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> No Sir</p>
]]></description><link>https://forum.qt.io/post/730914</link><guid isPermaLink="true">https://forum.qt.io/post/730914</guid><dc:creator><![CDATA[Perdrix]]></dc:creator><pubDate>Fri, 30 Sep 2022 20:23:07 GMT</pubDate></item><item><title><![CDATA[Reply to QTableView clicked() versus doubleClicked() on Fri, 30 Sep 2022 17:59:15 GMT]]></title><description><![CDATA[<p dir="auto">Did you keep any custom code / event filter after changing to use the selection model ?</p>
]]></description><link>https://forum.qt.io/post/730879</link><guid isPermaLink="true">https://forum.qt.io/post/730879</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Fri, 30 Sep 2022 17:59:15 GMT</pubDate></item><item><title><![CDATA[Reply to QTableView clicked() versus doubleClicked() on Fri, 30 Sep 2022 10:03:35 GMT]]></title><description><![CDATA[<p dir="auto">It must be set because I can d-click the cell later (after the image has loaded) and it opens the editor just fine</p>
]]></description><link>https://forum.qt.io/post/730805</link><guid isPermaLink="true">https://forum.qt.io/post/730805</guid><dc:creator><![CDATA[Perdrix]]></dc:creator><pubDate>Fri, 30 Sep 2022 10:03:35 GMT</pubDate></item><item><title><![CDATA[Reply to QTableView clicked() versus doubleClicked() on Fri, 30 Sep 2022 10:01:37 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/perdrix">@<bdi>Perdrix</bdi></a> said in <a href="/post/730800">QTableView clicked() versus doubleClicked()</a>:</p>
<blockquote>
<p dir="auto">What it doesn't do is open the editor on the cell that was double clicked!</p>
</blockquote>
<p dir="auto">Check editTriggers is set to QAbstractItemView::DoubleClicked</p>
]]></description><link>https://forum.qt.io/post/730804</link><guid isPermaLink="true">https://forum.qt.io/post/730804</guid><dc:creator><![CDATA[mpergand]]></dc:creator><pubDate>Fri, 30 Sep 2022 10:01:37 GMT</pubDate></item><item><title><![CDATA[Reply to QTableView clicked() versus doubleClicked() on Fri, 30 Sep 2022 10:02:45 GMT]]></title><description><![CDATA[<p dir="auto">No I can't do thumbnails as I don't know a-priori what files are involved and there might be 100s of them.</p>
<p dir="auto">Now back to the problem - selectionChanged works fine to detect the newly selected row to trigger image loading.</p>
<p dir="auto">Unfortunately, double clicking on a editable cell still results in selectionChanged driving the image loading to start.</p>
<p dir="auto">What it <em><strong>doesn't</strong></em> do is open the editor on the cell that was double clicked!</p>
<p dir="auto">I had a quick look at the code of mouseDoubleClickEvent in QAbstractItemView.cpp, and I <em>think</em> it is written so that it should always open the editor.   I suspect that the way mousePressedEvent() is written means that the double click event isn't generated if the selection change is driven from there (I don't think it should be driven from there - rather it should be driven from a mouseClickedEvent()) which isn't present.   I do see code in mousPressedEvent() that is intended to open the editor, but don't quite "get" why that wasn't invoked.</p>
<p dir="auto">David</p>
]]></description><link>https://forum.qt.io/post/730800</link><guid isPermaLink="true">https://forum.qt.io/post/730800</guid><dc:creator><![CDATA[Perdrix]]></dc:creator><pubDate>Fri, 30 Sep 2022 10:02:45 GMT</pubDate></item><item><title><![CDATA[Reply to QTableView clicked() versus doubleClicked() on Wed, 28 Sep 2022 19:41:00 GMT]]></title><description><![CDATA[<p dir="auto">Hence my suggestion, have a "pre-processing" phase where you create thumbnails to show quickly and load the complete file in the background. Once it's done notify your application and do what you need with it.</p>
]]></description><link>https://forum.qt.io/post/730594</link><guid isPermaLink="true">https://forum.qt.io/post/730594</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Wed, 28 Sep 2022 19:41:00 GMT</pubDate></item><item><title><![CDATA[Reply to QTableView clicked() versus doubleClicked() on Wed, 28 Sep 2022 19:36:05 GMT]]></title><description><![CDATA[<p dir="auto">Still need to load them - I am caching once loaded.</p>
]]></description><link>https://forum.qt.io/post/730591</link><guid isPermaLink="true">https://forum.qt.io/post/730591</guid><dc:creator><![CDATA[Perdrix]]></dc:creator><pubDate>Wed, 28 Sep 2022 19:36:05 GMT</pubDate></item><item><title><![CDATA[Reply to QTableView clicked() versus doubleClicked() on Wed, 28 Sep 2022 18:19:39 GMT]]></title><description><![CDATA[<p dir="auto">Do you want to show the full image size ?<br />
Otherwise creating a cache with small versions of them might be a better solution in terms of speed and only load the real version when really needed.</p>
]]></description><link>https://forum.qt.io/post/730577</link><guid isPermaLink="true">https://forum.qt.io/post/730577</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Wed, 28 Sep 2022 18:19:39 GMT</pubDate></item><item><title><![CDATA[Reply to QTableView clicked() versus doubleClicked() on Wed, 28 Sep 2022 16:22:36 GMT]]></title><description><![CDATA[<p dir="auto">Large images that take a while to load from file.</p>
]]></description><link>https://forum.qt.io/post/730571</link><guid isPermaLink="true">https://forum.qt.io/post/730571</guid><dc:creator><![CDATA[Perdrix]]></dc:creator><pubDate>Wed, 28 Sep 2022 16:22:36 GMT</pubDate></item><item><title><![CDATA[Reply to QTableView clicked() versus doubleClicked() on Wed, 28 Sep 2022 16:18:27 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/perdrix">@<bdi>Perdrix</bdi></a> said in <a href="/post/730564">QTableView clicked() versus doubleClicked()</a>:</p>
<blockquote>
<p dir="auto">it can take quite a while for some of these images.</p>
</blockquote>
<p dir="auto">Just because I am interested: do you mean (it takes much time) to <em>load</em> the image (once generated if that is what you are doing) into the UI, or do you mean to <em>generate</em> an image to load?</p>
]]></description><link>https://forum.qt.io/post/730570</link><guid isPermaLink="true">https://forum.qt.io/post/730570</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Wed, 28 Sep 2022 16:18:27 GMT</pubDate></item><item><title><![CDATA[Reply to QTableView clicked() versus doubleClicked() on Wed, 28 Sep 2022 15:59:07 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mpergand">@<bdi>mpergand</bdi></a> said in <a href="/post/730557">QTableView clicked() versus doubleClicked()</a>:</p>
<blockquote>
<p dir="auto">tableView-&gt;setFocus(Qt::OtherFocusReason);</p>
</blockquote>
<p dir="auto">Woohoo! That worked a treat.</p>
<p dir="auto">Thanks<br />
David</p>
]]></description><link>https://forum.qt.io/post/730569</link><guid isPermaLink="true">https://forum.qt.io/post/730569</guid><dc:creator><![CDATA[Perdrix]]></dc:creator><pubDate>Wed, 28 Sep 2022 15:59:07 GMT</pubDate></item><item><title><![CDATA[Reply to QTableView clicked() versus doubleClicked() on Wed, 28 Sep 2022 15:54:46 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a> Separate thread?  Yes - it can take quite a while for some of these images.</p>
]]></description><link>https://forum.qt.io/post/730564</link><guid isPermaLink="true">https://forum.qt.io/post/730564</guid><dc:creator><![CDATA[Perdrix]]></dc:creator><pubDate>Wed, 28 Sep 2022 15:54:46 GMT</pubDate></item><item><title><![CDATA[Reply to QTableView clicked() versus doubleClicked() on Wed, 28 Sep 2022 15:04:10 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/perdrix">@<bdi>Perdrix</bdi></a> said in <a href="/post/730551">QTableView clicked() versus doubleClicked()</a>:</p>
<blockquote>
<p dir="auto">and the image loading is started in another thread, and the table view is disabled.</p>
</blockquote>
<p dir="auto">Just asking: do you really need a separate thread for this "image loading" and having this "disabling" and consequent "focus losing"?  Maybe you do, but have you tried without bothering?</p>
]]></description><link>https://forum.qt.io/post/730559</link><guid isPermaLink="true">https://forum.qt.io/post/730559</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Wed, 28 Sep 2022 15:04:10 GMT</pubDate></item><item><title><![CDATA[Reply to QTableView clicked() versus doubleClicked() on Wed, 28 Sep 2022 14:45:34 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/perdrix">@<bdi>Perdrix</bdi></a> said in <a href="/post/730551">QTableView clicked() versus doubleClicked()</a>:</p>
<blockquote>
<p dir="auto">the table view is enabled again, but the highlight is lost</p>
</blockquote>
<p dir="auto">Because the table lost the focus, set it again with:</p>
<pre><code>tableView-&gt;setFocus(Qt::OtherFocusReason);
</code></pre>
]]></description><link>https://forum.qt.io/post/730557</link><guid isPermaLink="true">https://forum.qt.io/post/730557</guid><dc:creator><![CDATA[mpergand]]></dc:creator><pubDate>Wed, 28 Sep 2022 14:45:34 GMT</pubDate></item><item><title><![CDATA[Reply to QTableView clicked() versus doubleClicked() on Wed, 28 Sep 2022 14:23:28 GMT]]></title><description><![CDATA[<p dir="auto">To answer my own question!  This seems to work:</p>
<pre><code>	void StackingDlg::tableView_selectionChanged(&lsqb;&lsqb;maybe_unused&rsqb;&rsqb; const QItemSelection&amp; selected, &lsqb;&lsqb;maybe_unused&rsqb;&rsqb; const QItemSelection&amp; deselected)
	{

		QItemSelectionModel * qsm = ui-&gt;tableView-&gt;selectionModel();
		QModelIndexList selectedRows = qsm-&gt;selectedRows();
		qDebug() &lt;&lt; "Number of selected rows: " &lt;&lt; selectedRows.count();
		//
		// If only one row is selected, we want to know the filename
		//
		if (1 == selectedRows.count())
		{
			QModelIndex&amp; ndx = selectedRows[0];
			qDebug() &lt;&lt; "  Selected row: " &lt;&lt; ndx.row();
</code></pre>
<p dir="auto">though there's one remaining oddity.</p>
<p dir="auto">When I click on the single row, the row is highlighted to show it's selected, and the image loading is started in another thread, and the table view is disabled.</p>
<p dir="auto">On completion of the loading, the table view is enabled again, but the highlight is lost until I click on somewhere else in the window (not the rows of the tableview).</p>
<p dir="auto">I changed that code to NOT disable the table view and the highlight did not go away.</p>
<p dir="auto">Is there a way to prevent USER interaction with a control but allow internal events to continue processing?</p>
]]></description><link>https://forum.qt.io/post/730551</link><guid isPermaLink="true">https://forum.qt.io/post/730551</guid><dc:creator><![CDATA[Perdrix]]></dc:creator><pubDate>Wed, 28 Sep 2022 14:23:28 GMT</pubDate></item><item><title><![CDATA[Reply to QTableView clicked() versus doubleClicked() on Wed, 28 Sep 2022 14:21:04 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/perdrix">@<bdi>Perdrix</bdi></a> said in <a href="/post/730543">QTableView clicked() versus doubleClicked()</a>:</p>
<blockquote>
<p dir="auto">connect(qsm, SIGNAL(currentChanged(const QModelIndex&amp;, const QModelIndex&amp;)),<br />
this, SLOT(tableView_currentChanged(const QModelIndex&amp;, const QModelIndex&amp;)));</p>
</blockquote>
<p dir="auto">Do yourself a one-time nice favor: change over to <code>connect()</code> "new" style syntax (yours is now <em>really</em> old) for ever, and don't look back :)</p>
<p dir="auto">You are not the first person to struggle with the difference between "current" and "selected", myself included!  <a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> may know better, as he made the suggestion.  If you find <code>selectionChanged()</code> a better/more intelligible signal, I would try that :)</p>
]]></description><link>https://forum.qt.io/post/730550</link><guid isPermaLink="true">https://forum.qt.io/post/730550</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Wed, 28 Sep 2022 14:21:04 GMT</pubDate></item><item><title><![CDATA[Reply to QTableView clicked() versus doubleClicked() on Wed, 28 Sep 2022 13:50:45 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a> Thanks yet again!</p>
<p dir="auto">I'm now doing this:</p>
<pre><code>QItemSelectionModel* qsm = ui-&gt;tableView-&gt;selectionModel();
connect(qsm, SIGNAL(currentChanged(const QModelIndex&amp;, const QModelIndex&amp;)),
			this, SLOT(tableView_currentChanged(const QModelIndex&amp;, const QModelIndex&amp;)));

</code></pre>
<p dir="auto">and that works fine, but there's a small puzzle.</p>
<p dir="auto">When I click on a table row for the FIRST time, the slot is invoked just fine, and it executes this code:</p>
<pre><code>qDebug() &lt;&lt; "Table View selected item changed to row " &lt;&lt; index.row();

QItemSelectionModel * qsm = ui-&gt;tableView-&gt;selectionModel();
		QModelIndexList selectedRows = qsm-&gt;selectedRows();
qDebug() &lt;&lt; "Number of selected rows is " &lt;&lt; selectedRows.count();
</code></pre>
<p dir="auto">which produces the somewhat unexpected output:</p>
<pre><code>Table View selected item changed to row  3
Number of selected rows is  0
</code></pre>
<p dir="auto">Yet the row in question is highlighted to tell me it's selected!!!</p>
<p dir="auto">Please can you explain for me?</p>
<p dir="auto">And it gets wierder when I click on another row, the index of the selected item I get is the one that WAS selected!????</p>
<p dir="auto">Should I instead of the currentChanged signal be using the selectionChanged signal???</p>
<p dir="auto">Thank you<br />
David</p>
]]></description><link>https://forum.qt.io/post/730543</link><guid isPermaLink="true">https://forum.qt.io/post/730543</guid><dc:creator><![CDATA[Perdrix]]></dc:creator><pubDate>Wed, 28 Sep 2022 13:50:45 GMT</pubDate></item><item><title><![CDATA[Reply to QTableView clicked() versus doubleClicked() on Wed, 28 Sep 2022 09:47:35 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/perdrix">@<bdi>Perdrix</bdi></a><br />
<a href="https://doc.qt.io/qt-6/qtableview.html#currentChanged" target="_blank" rel="noopener noreferrer nofollow ugc">void QTableView::currentChanged(const QModelIndex &amp;current, const QModelIndex &amp;previous)</a> is <code>[override virtual protected]</code>, it is not a <em>signal</em>!</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> referred you to <a href="https://doc.qt.io/qt-6/qitemselectionmodel.html#currentChanged" target="_blank" rel="noopener noreferrer nofollow ugc">void QItemSelectionModel::currentChanged(const QModelIndex &amp;current, const QModelIndex &amp;previous)</a>, which <em>is</em> a signal, but on the <code>QItemSelectionModel</code>, not the <code>QTableView</code>.  Hence <code>void on_tableView_currentChanged(...)</code> is not going to work.</p>
<p dir="auto">BTW, most (advanced) people here do <em>not</em> use <code>connectSlotsByName()</code>, it has too many potential issues.  Consider changing over to <em>explicit</em> <code>connect()</code> calls (using new-style syntax), then you would not have been stymied!</p>
]]></description><link>https://forum.qt.io/post/730508</link><guid isPermaLink="true">https://forum.qt.io/post/730508</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Wed, 28 Sep 2022 09:47:35 GMT</pubDate></item><item><title><![CDATA[Reply to QTableView clicked() versus doubleClicked() on Wed, 28 Sep 2022 09:38:34 GMT]]></title><description><![CDATA[<p dir="auto">I added an entry to public slots in addition to the customContextMenuRequested one:</p>
<pre><code>public slots:
		void on_tableView_customContextMenuRequested(const QPoint&amp; pos);
		void on_tableView_currentChanged(const QModelIndex&amp; index, const QModelIndex&amp; last);
</code></pre>
<p dir="auto">and added an implementation for it</p>
<p dir="auto">But when I run the code I get:</p>
<pre><code>QMetaObject::connectSlotsByName: No matching signal for on_tableView_currentChanged(QModelIndex,QModelIndex)
</code></pre>
<p dir="auto">I don't think I got the signature wrong as the docs for QItemSelectionModel::currentChanged signal says:</p>
<pre><code>void currentChanged(const QModelIndex &amp;current, const QModelIndex &amp;previous)
</code></pre>
<p dir="auto">However connectSlotsByName() seems to disagree!</p>
<p dir="auto">Puzzled<br />
David</p>
]]></description><link>https://forum.qt.io/post/730507</link><guid isPermaLink="true">https://forum.qt.io/post/730507</guid><dc:creator><![CDATA[Perdrix]]></dc:creator><pubDate>Wed, 28 Sep 2022 09:38:34 GMT</pubDate></item><item><title><![CDATA[Reply to QTableView clicked() versus doubleClicked() on Wed, 28 Sep 2022 09:03:03 GMT]]></title><description><![CDATA[<p dir="auto">I will try that.</p>
]]></description><link>https://forum.qt.io/post/730501</link><guid isPermaLink="true">https://forum.qt.io/post/730501</guid><dc:creator><![CDATA[Perdrix]]></dc:creator><pubDate>Wed, 28 Sep 2022 09:03:03 GMT</pubDate></item><item><title><![CDATA[Reply to QTableView clicked() versus doubleClicked() on Wed, 28 Sep 2022 07:44:09 GMT]]></title><description><![CDATA[<p dir="auto">I would rather use the <a href="https://doc.qt.io/qt-6/qitemselectionmodel.html#currentChanged" target="_blank" rel="noopener noreferrer nofollow ugc">currentChanged signal</a> of the selection model to handle the data loading.</p>
]]></description><link>https://forum.qt.io/post/730472</link><guid isPermaLink="true">https://forum.qt.io/post/730472</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Wed, 28 Sep 2022 07:44:09 GMT</pubDate></item><item><title><![CDATA[Reply to QTableView clicked() versus doubleClicked() on Wed, 28 Sep 2022 05:19:40 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/perdrix">@<bdi>Perdrix</bdi></a> For double-click there is <a href="https://doc.qt.io/qt-6/qabstractitemview.html#doubleClicked" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qt-6/qabstractitemview.html#doubleClicked</a></p>
]]></description><link>https://forum.qt.io/post/730442</link><guid isPermaLink="true">https://forum.qt.io/post/730442</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Wed, 28 Sep 2022 05:19:40 GMT</pubDate></item></channel></rss>