<?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[Runtime layout]]></title><description><![CDATA[<p dir="auto">Hi!</p>
<p dir="auto">In my application there is a QFrame, say F, and inside it there are 3 other QFrame objects, say A, B and C. F's layout is vertical, with A at the top, followed by B and C.<br />
In A there are two QRadionButton objects, and depending on the user choice, B or C should be visible. That does not seem hard to do, but the layout in F is broken when the Window is displayed, and is only fixed when I click one of the QRadionButton in A, as this code is executed:</p>
<pre><code>{
  if (ui-&gt;rdbA-&gt;isChecked()) {
    ui-&gt;fraB-&gt;setVisible(false);
    ui-&gt;fraA-&gt;setVisible(true);
    ui-&gt;fraF-&gt;layout()-&gt;removeWidget(ui-&gt;fraB);
    ui-&gt;fraF-&gt;layout()-&gt;addWidget(ui-&gt;fraA);
  } else {
    ui-&gt;fraB-&gt;setVisible(true);
    ui-&gt;fraA-&gt;setVisible(false);
    ui-&gt;fraF-&gt;layout()-&gt;addWidget(ui-&gt;fraB);
    ui-&gt;fraF-&gt;layout()-&gt;removeWidget(ui-&gt;fraA);
  }
  this-&gt;setGeometry(parentWidget()-&gt;x(),
                    parentWidget()-&gt;y(),
                    parentWidget()-&gt;width(),
                    parentWidget()-&gt;height());
}
</code></pre>
<p dir="auto">Could anyone, please, give me any idea, or reference, on how to do it?</p>
<p dir="auto">Thanks!</p>
]]></description><link>https://forum.qt.io/topic/105116/runtime-layout</link><generator>RSS for Node</generator><lastBuildDate>Thu, 16 Apr 2026 12:57:06 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/105116.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 18 Jul 2019 17:06:09 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Runtime layout on Thu, 18 Jul 2019 18:00:14 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/canellas">@<bdi>canellas</bdi></a><br />
What do you mean by "but the layout in F is broken when the Window is displayed"?</p>
<p dir="auto">It will only correctly show one frame when the code you show gets executed, as that sets up to view one frame, correctly. (Or is your question about a specific bit of the code?)  So that's reasonable, no?</p>
<p dir="auto">However, before you spend time on this, would using a <code>QStackedWidget</code> (<a href="https://doc.qt.io/qt-5/qstackedwidget.html" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qt-5/qstackedwidget.html</a>), which is designed for swapping between multiple widgets so only one is shown at a time (either of your <strong>B</strong> or <strong>C</strong>), be better for what you're trying to do here?</p>
]]></description><link>https://forum.qt.io/post/541623</link><guid isPermaLink="true">https://forum.qt.io/post/541623</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Thu, 18 Jul 2019 18:00:14 GMT</pubDate></item><item><title><![CDATA[Reply to Runtime layout on Fri, 19 Jul 2019 15:01:11 GMT]]></title><description><![CDATA[<p dir="auto">AFAIK, it's a know issue of the forum software. It might have been fixed since last time I saw the report but I haven't checked recently.</p>
]]></description><link>https://forum.qt.io/post/541824</link><guid isPermaLink="true">https://forum.qt.io/post/541824</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Fri, 19 Jul 2019 15:01:11 GMT</pubDate></item><item><title><![CDATA[Reply to Runtime layout on Thu, 18 Jul 2019 22:25:10 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/canellas">@<bdi>canellas</bdi></a><br />
Very kind of you.  Only Grand Wizards here know how to mark <em>someone else's</em> post as the solution, I have seen others do it in mysterious circumstances but have not graduated that far myself...</p>
]]></description><link>https://forum.qt.io/post/541652</link><guid isPermaLink="true">https://forum.qt.io/post/541652</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Thu, 18 Jul 2019 22:25:10 GMT</pubDate></item><item><title><![CDATA[Reply to Runtime layout on Thu, 18 Jul 2019 21:02:16 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a> ,</p>
<p dir="auto">I marked my reply to you comment as the best, but I meant to mark your comment as the best. Do you know how to change it?</p>
]]></description><link>https://forum.qt.io/post/541647</link><guid isPermaLink="true">https://forum.qt.io/post/541647</guid><dc:creator><![CDATA[canellas]]></dc:creator><pubDate>Thu, 18 Jul 2019 21:02:16 GMT</pubDate></item><item><title><![CDATA[Reply to Runtime layout on Thu, 18 Jul 2019 20:57:03 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/sgaist">@<bdi>SGaist</bdi></a> ,</p>
<p dir="auto">Not really. I just wanted to show a frame B or C, according to a QRadioButton, but the way I was trying to do, the layout was messed up. <a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a> was right by telling to use QStackWidget. I did not know it well, and I though the user would be able to switch between pages.<br />
So, thank you all for your help!</p>
]]></description><link>https://forum.qt.io/post/541645</link><guid isPermaLink="true">https://forum.qt.io/post/541645</guid><dc:creator><![CDATA[canellas]]></dc:creator><pubDate>Thu, 18 Jul 2019 20:57:03 GMT</pubDate></item><item><title><![CDATA[Reply to Runtime layout on Thu, 18 Jul 2019 20:26:53 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Are you trying to implement some sort of wizard ? If so, then <a href="https://doc.qt.io/qt-5/qwizard.html" target="_blank" rel="noopener noreferrer nofollow ugc">QWizard</a> is your friend.</p>
]]></description><link>https://forum.qt.io/post/541640</link><guid isPermaLink="true">https://forum.qt.io/post/541640</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Thu, 18 Jul 2019 20:26:53 GMT</pubDate></item><item><title><![CDATA[Reply to Runtime layout on Thu, 18 Jul 2019 20:58:55 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a> ,</p>
<p dir="auto">First of all, thanks for your time.</p>
<p dir="auto">I wrapped the code in a method, and called it in the constructor of the QMainWindow. I guess I should call in another moment, right? Maybe on some <code>show</code> event...</p>
<p dir="auto">I though of QStackWidget, but that would allow the controls (QWidget) in B and C to be used, so when the user clicked on the final OK, I would not know id I should consider the data in B or C. I mean, I would like to direct the user, making him/her to explicitly choose B or C data. (dummy edit)</p>
]]></description><link>https://forum.qt.io/post/541638</link><guid isPermaLink="true">https://forum.qt.io/post/541638</guid><dc:creator><![CDATA[canellas]]></dc:creator><pubDate>Thu, 18 Jul 2019 20:58:55 GMT</pubDate></item><item><title><![CDATA[Reply to Runtime layout on Thu, 18 Jul 2019 18:00:14 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/canellas">@<bdi>canellas</bdi></a><br />
What do you mean by "but the layout in F is broken when the Window is displayed"?</p>
<p dir="auto">It will only correctly show one frame when the code you show gets executed, as that sets up to view one frame, correctly. (Or is your question about a specific bit of the code?)  So that's reasonable, no?</p>
<p dir="auto">However, before you spend time on this, would using a <code>QStackedWidget</code> (<a href="https://doc.qt.io/qt-5/qstackedwidget.html" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qt-5/qstackedwidget.html</a>), which is designed for swapping between multiple widgets so only one is shown at a time (either of your <strong>B</strong> or <strong>C</strong>), be better for what you're trying to do here?</p>
]]></description><link>https://forum.qt.io/post/541623</link><guid isPermaLink="true">https://forum.qt.io/post/541623</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Thu, 18 Jul 2019 18:00:14 GMT</pubDate></item></channel></rss>