<?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[Clicking header of QTableView selects top row and causes QTAbleView to emit clicked]]></title><description><![CDATA[<p dir="auto">I have a QTableView. It has a header. I'm stuck using QT 4.something</p>
<p dir="auto">Clicking on the header changes the row selected.  So if I have row five selected, and I click a column in the header, the top row visible becomes selected. No sorting or anything.</p>
<p dir="auto">I don't want this.</p>
<p dir="auto">Also, I have connected the QTableView clicked signal to a function, and clicking on the header seems to make that signal fire. I also don't want this.</p>
<p dir="auto">I want clicking on the header to NOT change the selected row, and also to NOT cause QTableView to fire its clicked signal.</p>
<p dir="auto">How can I achieve this?</p>
]]></description><link>https://forum.qt.io/topic/78686/clicking-header-of-qtableview-selects-top-row-and-causes-qtableview-to-emit-clicked</link><generator>RSS for Node</generator><lastBuildDate>Wed, 08 Apr 2026 05:54:49 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/78686.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 27 Apr 2017 14:34:00 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Clicking header of QTableView selects top row and causes QTAbleView to emit clicked on Thu, 27 Apr 2017 15:49:57 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/moschopsredux">@<bdi>MoschopsRedux</bdi></a><br />
Hi<br />
The roles is part of the call<br />
bool QAbstractItemModel::setHeaderData(int section, Qt::Orientation orientation, const QVariant &amp;value, int role = Qt::EditRole)</p>
<p dir="auto">But as u can se its default Qt::EditRole so i thinki<br />
<a class="plugin-mentions-user plugin-mentions-a" href="/user/chris-hennes">@<bdi>Chris-Hennes</bdi></a>  ask if u set it as  Qt::DisplayRole instead.</p>
]]></description><link>https://forum.qt.io/post/390312</link><guid isPermaLink="true">https://forum.qt.io/post/390312</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Thu, 27 Apr 2017 15:49:57 GMT</pubDate></item><item><title><![CDATA[Reply to Clicking header of QTableView selects top row and causes QTAbleView to emit clicked on Thu, 27 Apr 2017 15:46:27 GMT]]></title><description><![CDATA[<p dir="auto">Yes, I believe setHeaderData is being used.</p>
<p dir="auto">However, I don't understand what you mean by "set the role of the header to Qt::DisplayRole". I thought that Qt::DisplayRole was the role of various data; I don't understand how an entire header's role can be Qt::DisplayRole.</p>
]]></description><link>https://forum.qt.io/post/390310</link><guid isPermaLink="true">https://forum.qt.io/post/390310</guid><dc:creator><![CDATA[MoschopsRedux]]></dc:creator><pubDate>Thu, 27 Apr 2017 15:46:27 GMT</pubDate></item><item><title><![CDATA[Reply to Clicking header of QTableView selects top row and causes QTAbleView to emit clicked on Thu, 27 Apr 2017 15:19:37 GMT]]></title><description><![CDATA[<p dir="auto">A little unfortunately, I'm maintaining some code in which what I'm working with is a view inherited from QTableView, and a header inherited from QHeaderView.</p>
<p dir="auto">That said, I think the answer to your first question must be yes, because I spent some time fixing sorting earlier and it does sort (i.e. click header section, and the rows rearrange themselves).</p>
<p dir="auto">The second; I do not know. I am looking.... The header sections have words in them, so something must be setting that.</p>
]]></description><link>https://forum.qt.io/post/390306</link><guid isPermaLink="true">https://forum.qt.io/post/390306</guid><dc:creator><![CDATA[MoschopsRedux]]></dc:creator><pubDate>Thu, 27 Apr 2017 15:19:37 GMT</pubDate></item><item><title><![CDATA[Reply to Clicking header of QTableView selects top row and causes QTAbleView to emit clicked on Thu, 27 Apr 2017 15:12:22 GMT]]></title><description><![CDATA[<p dir="auto">Two questions for you: have you called <code>setSortingEnabled</code> on your table? And are you using <code>setHeaderData</code> to set the role of the header to <code>Qt::DisplayRole</code>?</p>
]]></description><link>https://forum.qt.io/post/390303</link><guid isPermaLink="true">https://forum.qt.io/post/390303</guid><dc:creator><![CDATA[Chris Hennes]]></dc:creator><pubDate>Thu, 27 Apr 2017 15:12:22 GMT</pubDate></item></channel></rss>