<?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[Adjust dialog size to size of data in child QTableView works for width but not height]]></title><description><![CDATA[<p dir="auto">I have a dialog with the following object hiearchy</p>
<pre><code>QDialog layout QVBoxLayout
   QWidget layout QHBoxLayout
       QTableViewItem
  QPushButton
</code></pre>
<p dir="auto">Hence fairly simple. The table view shall display a matrix. The size of this matrix may vary. Hence I wish to adjust the the size of the dialog to the data. This I've done by inserting</p>
<pre><code>resize(1,1);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
</code></pre>
<p dir="auto">in the dialog constructor. This works fine for width but the dialog height only becomes enough for a single row. I've tested different layouts and scrutinized all size proprties of the table view and the first child widget. They are the same for both horizontal and vertical and I've tested with both "preferred" and "expanding". Scrollbar settings for the tableview are the same for both horizontal and vertical. Header settings too. But still the dialog doesn't adjust height to number of rows in table.</p>
<p dir="auto">Why does width and height behaves differently and how can I get the dialog to the right height?</p>
]]></description><link>https://forum.qt.io/topic/139382/adjust-dialog-size-to-size-of-data-in-child-qtableview-works-for-width-but-not-height</link><generator>RSS for Node</generator><lastBuildDate>Thu, 05 Nov 2026 07:24:04 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/139382.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 17 Sep 2022 05:19:56 GMT</pubDate><ttl>60</ttl></channel></rss>