<?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 selection behavior]]></title><description><![CDATA[<p dir="auto">Hi all, how i can set selection behavior for QTableView like in Windows for files in folder when shift button is pressed?</p>
<p dir="auto">I found this:<br />
view-&gt;setSelectionBehavior(QAbstractItemView::SelectRows);</p>
<p dir="auto">but it can to change only for whole row/column selection behavior.</p>
<p dir="auto">Now:<br />
<img src="https://ddgobkiprc33d.cloudfront.net/cdc6accc-779e-4d40-a563-5afaea775fbe.png" alt="0_1552556946148_Untitled1.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">I need:<br />
<img src="https://ddgobkiprc33d.cloudfront.net/d6f81e57-cb17-4873-8546-3835d7ca0b65.png" alt="0_1552556953724_Untitled.png" class=" img-fluid img-markdown" /></p>
<p dir="auto">Thanks.!</p>
]]></description><link>https://forum.qt.io/topic/100692/qtableview-selection-behavior</link><generator>RSS for Node</generator><lastBuildDate>Mon, 14 Sep 2026 05:20:48 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/100692.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 13 Mar 2019 17:53:07 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QTableView selection behavior on Thu, 14 Mar 2019 11:04:00 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/anton-shelenkov">@<bdi>Anton-Shelenkov</bdi></a><br />
Per your selection picture now shown in your question (much better than your original textual description!)</p>
<p dir="auto">I think you certainly do <em>not</em> want <code>setSelectionBehavior(QAbstractItemView::SelectRows)</code>, that does what you show and by definition <em>only</em> selects whole rows.  I think you must try <code>setSelectionBehavior(QAbstractItemView::SelectItems)</code> to get anything other than whole rows/columns selected.  Then <em>combine</em> that with <code>setSelectionMode()</code>, passing <code>QAbstractItemView::ContiguousSelection</code> or (probably) <code>QAbstractItemView::ExtendedSelection</code>, and see how you go?</p>
]]></description><link>https://forum.qt.io/post/517441</link><guid isPermaLink="true">https://forum.qt.io/post/517441</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Thu, 14 Mar 2019 11:04:00 GMT</pubDate></item><item><title><![CDATA[Reply to QTableView selection behavior on Thu, 14 Mar 2019 10:00:47 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jon">@<bdi>Jon</bdi></a> I tried that, it's not what i need. I think with pix it will be clearer what i want to.</p>
]]></description><link>https://forum.qt.io/post/517433</link><guid isPermaLink="true">https://forum.qt.io/post/517433</guid><dc:creator><![CDATA[Anton Shelenkov]]></dc:creator><pubDate>Thu, 14 Mar 2019 10:00:47 GMT</pubDate></item><item><title><![CDATA[Reply to QTableView selection behavior on Wed, 13 Mar 2019 19:10:48 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a> said in <a href="/post/517342">QTableView selection behavior</a>:</p>
<blockquote>
<p dir="auto">QAbstractItemView::ExtendedSelection</p>
</blockquote>
<p dir="auto">My money is on that one :)</p>
]]></description><link>https://forum.qt.io/post/517355</link><guid isPermaLink="true">https://forum.qt.io/post/517355</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Wed, 13 Mar 2019 19:10:48 GMT</pubDate></item><item><title><![CDATA[Reply to QTableView selection behavior on Wed, 13 Mar 2019 18:33:55 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/anton-shelenkov">@<bdi>Anton-Shelenkov</bdi></a><br />
I'm afraid I don't get exactly what your example is showing, but look at <code>setSelectionMode(QAbstractItemView::SelectionMode mode)</code>, <a href="https://doc.qt.io/qt-5/qabstractitemview.html#SelectionMode-enum" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qt-5/qabstractitemview.html#SelectionMode-enum</a>.  <code>QAbstractItemView::ContiguousSelection</code> or <code>QAbstractItemView::ExtendedSelection</code> are what you are looking for?</p>
]]></description><link>https://forum.qt.io/post/517342</link><guid isPermaLink="true">https://forum.qt.io/post/517342</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Wed, 13 Mar 2019 18:33:55 GMT</pubDate></item></channel></rss>