<?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[How to get the effective icon size used in a QTreeView?]]></title><description><![CDATA[<p dir="auto">This seems like a really basic question, but I have been unable to find out how to do this: How do I retrieve the actual icon size that is used in a <code>QTreeView</code>? When I create a <code>QTreeView</code> and call <code>iconSize()</code> I get the default value of (-1, -1), which apparently indicates that the size will be based on the font metrics. However, it is unclear in what way. For instance, the actual size does not correspond to <code>tree_view-&gt;fontMetrics().height()</code>. Is there a reliable way to retrieve the icon size? All items are just icon+text and I call <code>setUniformRowHeights(true)</code> in case that makes any difference.<br />
The background ist that I want to dynamically generate bitmap icons at the right size, so they are not scaled when being used in the tree view.</p>
]]></description><link>https://forum.qt.io/topic/145924/how-to-get-the-effective-icon-size-used-in-a-qtreeview</link><generator>RSS for Node</generator><lastBuildDate>Thu, 30 Apr 2026 05:07:45 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/145924.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 21 Jun 2023 11:03:51 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to get the effective icon size used in a QTreeView? on Wed, 21 Jun 2023 13:42:04 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tempus_fugit">@<bdi>tempus_fugit</bdi></a><br />
There's a protected method:<br />
[protected] int QTreeView::rowHeight(const QModelIndex &amp;index) const</p>
]]></description><link>https://forum.qt.io/post/762208</link><guid isPermaLink="true">https://forum.qt.io/post/762208</guid><dc:creator><![CDATA[mpergand]]></dc:creator><pubDate>Wed, 21 Jun 2023 13:42:04 GMT</pubDate></item><item><title><![CDATA[Reply to How to get the effective icon size used in a QTreeView? on Wed, 21 Jun 2023 13:25:25 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/762204">How to get the effective icon size used in a QTreeView?</a>:</p>
<blockquote>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tempus_fugit">@<bdi>tempus_fugit</bdi></a> said in <a href="/post/762198">How to get the effective icon size used in a QTreeView?</a>:</p>
<blockquote>
<p dir="auto">The background ist that I want to dynamically generate bitmap icons at the right size, so they are not scaled when being used in the tree view.</p>
</blockquote>
<p dir="auto">You can return the height of a row according to the icon size you want in  Qt::SizeHintRole in your item model.</p>
</blockquote>
<p dir="auto">Thanks. Yes, that would work but that only shifts the problem. I do not really want the burden of controlling the row height, because that would mean that I would have to compute a suitable value for the row height. I would really prefer letting QTreeView work out the row height for me based on the natural height of the items.</p>
]]></description><link>https://forum.qt.io/post/762206</link><guid isPermaLink="true">https://forum.qt.io/post/762206</guid><dc:creator><![CDATA[tempus_fugit]]></dc:creator><pubDate>Wed, 21 Jun 2023 13:25:25 GMT</pubDate></item><item><title><![CDATA[Reply to How to get the effective icon size used in a QTreeView? on Wed, 21 Jun 2023 12:39:23 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/tempus_fugit">@<bdi>tempus_fugit</bdi></a> said in <a href="/post/762198">How to get the effective icon size used in a QTreeView?</a>:</p>
<blockquote>
<p dir="auto">The background ist that I want to dynamically generate bitmap icons at the right size, so they are not scaled when being used in the tree view.</p>
</blockquote>
<p dir="auto">You can return the height of a row according to the icon size you want in  Qt::SizeHintRole in your item model.</p>
]]></description><link>https://forum.qt.io/post/762204</link><guid isPermaLink="true">https://forum.qt.io/post/762204</guid><dc:creator><![CDATA[mpergand]]></dc:creator><pubDate>Wed, 21 Jun 2023 12:39:23 GMT</pubDate></item></channel></rss>