<?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[Span cells in QTableView from model]]></title><description><![CDATA[<p dir="auto">I want to achieve something like this (image from the web):</p>
<p dir="auto"><img src="http://help.infragistics.com/Help/Doc/Reporting/2014.2/CLR4.0/html/images/How_to_Group_Data_3.png" alt="alt text" class=" img-fluid img-markdown" /></p>
<p dir="auto">where each "section" spans over all the columns. This should be accomplished by using the <code>void QTableView::setSpan(int row, int column, int rowSpanCount, int columnSpanCount)</code> method. But the UI has no way to know which rows are section. The model knows, i.e. I have an hidden column that allows me to distinguish if the current row is either a section row or data one.</p>
<p dir="auto"><strong>So, what is the best way to  bring up this information to the UI in order to set the span?</strong></p>
<p dir="auto">My (ugly*) thought: whenever the model changes, first clear all the spans, then cycle the rows one by one, get the model data, check the hidden field and set the span according.</p>
<p dir="auto">*ugly, but it actually works!</p>
]]></description><link>https://forum.qt.io/topic/97703/span-cells-in-qtableview-from-model</link><generator>RSS for Node</generator><lastBuildDate>Wed, 06 May 2026 12:21:25 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/97703.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 17 Dec 2018 08:02:17 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Span cells in QTableView from model on Mon, 17 Dec 2018 10:16:15 GMT]]></title><description><![CDATA[<p dir="auto">The KDE API has a very similar functionality using <code>KCategorizedSortFilterProxyModel</code>/<code>KCategorizedView</code>/<code>KCategoryDrawer</code>: <a href="https://api.kde.org/frameworks/kitemviews/html/annotated.html" target="_blank" rel="noopener noreferrer nofollow ugc">https://api.kde.org/frameworks/kitemviews/html/annotated.html</a> but it implements only a list view, not a table.<br />
The alternative is to use a tree model/view, set the categories as top items and the rest as leaves of the tree</p>
]]></description><link>https://forum.qt.io/post/499671</link><guid isPermaLink="true">https://forum.qt.io/post/499671</guid><dc:creator><![CDATA[VRonin]]></dc:creator><pubDate>Mon, 17 Dec 2018 10:16:15 GMT</pubDate></item><item><title><![CDATA[Reply to Span cells in QTableView from model on Mon, 17 Dec 2018 08:20:51 GMT]]></title><description><![CDATA[<p dir="auto">Hi<br />
I mean to flag a row if should be a section type.<br />
Would be less convoluted than having a hidden col. (IMHO)</p>
]]></description><link>https://forum.qt.io/post/499640</link><guid isPermaLink="true">https://forum.qt.io/post/499640</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Mon, 17 Dec 2018 08:20:51 GMT</pubDate></item><item><title><![CDATA[Reply to Span cells in QTableView from model on Mon, 17 Dec 2018 08:15:39 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mrjj">@<bdi>mrjj</bdi></a> said in <a href="/post/499637">Span cells in QTableView from model</a>:</p>
<blockquote>
<p dir="auto">HI<br />
It's not possible to use UserRole for this? (custom role)<br />
So so it's like EditROle and Decoration role and a view can choose to honor it.</p>
</blockquote>
<p dir="auto">As far as I know with DecorationRole and the other display ones (i.e. BackgroundRole) you can easily change the appearance in terms of colors and icons. I don't know if you can also suppress the cell borders as well.</p>
]]></description><link>https://forum.qt.io/post/499639</link><guid isPermaLink="true">https://forum.qt.io/post/499639</guid><dc:creator><![CDATA[Mark81]]></dc:creator><pubDate>Mon, 17 Dec 2018 08:15:39 GMT</pubDate></item><item><title><![CDATA[Reply to Span cells in QTableView from model on Mon, 17 Dec 2018 08:10:47 GMT]]></title><description><![CDATA[<p dir="auto">HI<br />
It's not possible to use UserRole for this? (custom role)<br />
So so it's like EditROle and Decoration role and a view can choose to honor it.</p>
]]></description><link>https://forum.qt.io/post/499637</link><guid isPermaLink="true">https://forum.qt.io/post/499637</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Mon, 17 Dec 2018 08:10:47 GMT</pubDate></item></channel></rss>