<?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[Beginner question - Simple &quot;hello world&quot; using QMainWindow and dynamically loaded .ui from Widget Designer]]></title><description><![CDATA[<p dir="auto">Apologies if this is the wrong forum for beginner questions, please let me know where to post.</p>
<p dir="auto">I thought this would be simple, but web searches seem to turn up lots of non-working hallucinations.</p>
<p dir="auto">I created a simple Main Window ui in Widgets Designer.  One Google suggestion resulted in a small completely empty window.  A different code template displays the window, containing the controls, but much too small.  It can be drag-expanded to show everything, but I was under the impression that it was supposed to size itself to contain its members.</p>
<p dir="auto">When I Ctrl+R in Designer the window displays as expected, but not from my Python code, so I know I'm doing something wrong.</p>
<p dir="auto">Question: Is there a canonical example of how to accomplish this with a Desinger-generated .ui dynamically loaded, and QMainWIndow?  Or, is that just the wrong approach?</p>
<h2>Designer:</h2>
<p dir="auto"><img src="https://ddgobkiprc33d.cloudfront.net/82db0340-ab1b-489a-90f8-32d20233c414.PNG" alt="2026-09-03_13-36-14.PNG" class=" img-fluid img-markdown" /></p>
<h2>Initial display:</h2>
<p dir="auto"><img src="https://ddgobkiprc33d.cloudfront.net/4ace4755-697e-4dcf-bf04-6d3e06d932af.PNG" alt="2026-09-03_13-37-28.PNG" class=" img-fluid img-markdown" /></p>
<h2>After manual resizing:</h2>
<p dir="auto"><img src="https://ddgobkiprc33d.cloudfront.net/3530598a-b65a-4238-a718-f712d73d2a89.PNG" alt="2026-09-03_13-37-58.PNG" class=" img-fluid img-markdown" /></p>
<h2>.ui file</h2>
<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;ui version="4.0"&gt;
 &lt;class&gt;MainWindow&lt;/class&gt;
 &lt;widget class="QMainWindow" name="MainWindow"&gt;
  &lt;property name="geometry"&gt;
   &lt;rect&gt;
    &lt;x&gt;0&lt;/x&gt;
    &lt;y&gt;0&lt;/y&gt;
    &lt;width&gt;360&lt;/width&gt;
    &lt;height&gt;293&lt;/height&gt;
   &lt;/rect&gt;
  &lt;/property&gt;
  &lt;property name="windowTitle"&gt;
   &lt;string&gt;MainWindow&lt;/string&gt;
  &lt;/property&gt;
  &lt;widget class="QWidget" name="centralwidget"&gt;
   &lt;widget class="QWidget" name=""&gt;
    &lt;property name="geometry"&gt;
     &lt;rect&gt;
      &lt;x&gt;10&lt;/x&gt;
      &lt;y&gt;10&lt;/y&gt;
      &lt;width&gt;331&lt;/width&gt;
      &lt;height&gt;211&lt;/height&gt;
     &lt;/rect&gt;
    &lt;/property&gt;
    &lt;layout class="QVBoxLayout" name="verticalLayout"&gt;
     &lt;item&gt;
      &lt;layout class="QHBoxLayout" name="horizontalLayout"&gt;
       &lt;property name="sizeConstraint"&gt;
        &lt;enum&gt;QLayout::SizeConstraint::SetDefaultConstraint&lt;/enum&gt;
       &lt;/property&gt;
       &lt;item&gt;
        &lt;widget class="QLabel" name="Label1"&gt;
         &lt;property name="font"&gt;
          &lt;font&gt;
           &lt;pointsize&gt;12&lt;/pointsize&gt;
          &lt;/font&gt;
         &lt;/property&gt;
         &lt;property name="text"&gt;
          &lt;string&gt;TextLabel&lt;/string&gt;
         &lt;/property&gt;
        &lt;/widget&gt;
       &lt;/item&gt;
       &lt;item&gt;
        &lt;widget class="QLineEdit" name="lineEdit"/&gt;
       &lt;/item&gt;
      &lt;/layout&gt;
     &lt;/item&gt;
     &lt;item&gt;
      &lt;layout class="QHBoxLayout" name="horizontalLayout_2"&gt;
       &lt;item&gt;
        &lt;widget class="QComboBox" name="comboBox"/&gt;
       &lt;/item&gt;
       &lt;item&gt;
        &lt;widget class="QPushButton" name="pushButton"&gt;
         &lt;property name="text"&gt;
          &lt;string&gt;PushButton&lt;/string&gt;
         &lt;/property&gt;
        &lt;/widget&gt;
       &lt;/item&gt;
      &lt;/layout&gt;
     &lt;/item&gt;
     &lt;item&gt;
      &lt;widget class="QGroupBox" name="groupBox"&gt;
       &lt;property name="sizePolicy"&gt;
        &lt;sizepolicy hsizetype="Preferred" vsizetype="Preferred"&gt;
         &lt;horstretch&gt;0&lt;/horstretch&gt;
         &lt;verstretch&gt;1&lt;/verstretch&gt;
        &lt;/sizepolicy&gt;
       &lt;/property&gt;
       &lt;property name="title"&gt;
        &lt;string&gt;GroupBox&lt;/string&gt;
       &lt;/property&gt;
       &lt;widget class="QRadioButton" name="radioButton"&gt;
        &lt;property name="geometry"&gt;
         &lt;rect&gt;
          &lt;x&gt;20&lt;/x&gt;
          &lt;y&gt;30&lt;/y&gt;
          &lt;width&gt;98&lt;/width&gt;
          &lt;height&gt;24&lt;/height&gt;
         &lt;/rect&gt;
        &lt;/property&gt;
        &lt;property name="text"&gt;
         &lt;string&gt;RadioButton1&lt;/string&gt;
        &lt;/property&gt;
       &lt;/widget&gt;
       &lt;widget class="QRadioButton" name="radioButton_2"&gt;
        &lt;property name="geometry"&gt;
         &lt;rect&gt;
          &lt;x&gt;20&lt;/x&gt;
          &lt;y&gt;60&lt;/y&gt;
          &lt;width&gt;98&lt;/width&gt;
          &lt;height&gt;24&lt;/height&gt;
         &lt;/rect&gt;
        &lt;/property&gt;
        &lt;property name="text"&gt;
         &lt;string&gt;RadioButton2&lt;/string&gt;
        &lt;/property&gt;
       &lt;/widget&gt;
       &lt;widget class="QRadioButton" name="radioButton_3"&gt;
        &lt;property name="geometry"&gt;
         &lt;rect&gt;
          &lt;x&gt;20&lt;/x&gt;
          &lt;y&gt;90&lt;/y&gt;
          &lt;width&gt;98&lt;/width&gt;
          &lt;height&gt;24&lt;/height&gt;
         &lt;/rect&gt;
        &lt;/property&gt;
        &lt;property name="text"&gt;
         &lt;string&gt;RadioButton 3&lt;/string&gt;
        &lt;/property&gt;
       &lt;/widget&gt;
      &lt;/widget&gt;
     &lt;/item&gt;
    &lt;/layout&gt;
   &lt;/widget&gt;
  &lt;/widget&gt;
  &lt;widget class="QMenuBar" name="menubar"&gt;
   &lt;property name="geometry"&gt;
    &lt;rect&gt;
     &lt;x&gt;0&lt;/x&gt;
     &lt;y&gt;0&lt;/y&gt;
     &lt;width&gt;360&lt;/width&gt;
     &lt;height&gt;33&lt;/height&gt;
    &lt;/rect&gt;
   &lt;/property&gt;
   &lt;widget class="QMenu" name="menuMain_Window"&gt;
    &lt;property name="title"&gt;
     &lt;string&gt;File&lt;/string&gt;
    &lt;/property&gt;
    &lt;addaction name="actionOpen"/&gt;
    &lt;addaction name="actionSave"/&gt;
    &lt;addaction name="actionSave_As"/&gt;
   &lt;/widget&gt;
   &lt;addaction name="menuMain_Window"/&gt;
  &lt;/widget&gt;
  &lt;widget class="QStatusBar" name="statusbar"/&gt;
  &lt;action name="actionOpen"&gt;
   &lt;property name="text"&gt;
    &lt;string&gt;Open...&lt;/string&gt;
   &lt;/property&gt;
  &lt;/action&gt;
  &lt;action name="actionSave"&gt;
   &lt;property name="text"&gt;
    &lt;string&gt;Save&lt;/string&gt;
   &lt;/property&gt;
  &lt;/action&gt;
  &lt;action name="actionSave_As"&gt;
   &lt;property name="text"&gt;
    &lt;string&gt;Save As&lt;/string&gt;
   &lt;/property&gt;
  &lt;/action&gt;
 &lt;/widget&gt;
 &lt;resources/&gt;
 &lt;connections/&gt;
&lt;/ui&gt;
</code></pre>
<h2>Python code</h2>
<pre><code>import sys
from PySide6.QtCore import QFile
from PySide6.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QWidget
from PySide6.QtUiTools import QUiLoader

class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        
        # 1. Setup the UI loader and open the UI file
        loader = QUiLoader()
        ui_file = QFile("../../../qtTest/test.ui")
        if not ui_file.open(QFile.ReadOnly):
            print("Cannot open ui file")
            sys.exit(-1)
        
        # 2. Load the UI layout directly into the window
        self.ui = loader.load(ui_file, self)
        ui_file.close()

        self.setWindowTitle("My Qt Designer App")
        self.setCentralWidget(self.ui)
        
        layout    = QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(self.ui)

        container = QWidget()
        container.setLayout(layout)
        self.setCentralWidget(container)
        
        # 4. Connect functional code to your UI components
        # (Assuming you have a button named 'submit_btn' in Qt Designer)
        self.ui.pushButton.clicked.connect(self.on_submit_clicked)

    def on_submit_clicked(self):
        print("The button was clicked!")

if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = MainWindow()
    window.show()
    sys.exit(app.exec())
</code></pre>
]]></description><link>https://forum.qt.io/topic/165058/beginner-question-simple-hello-world-using-qmainwindow-and-dynamically-loaded-.ui-from-widget-designer</link><generator>RSS for Node</generator><lastBuildDate>Sat, 05 Sep 2026 19:49:38 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/165058.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 03 Sep 2026 20:41:41 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Beginner question - Simple &quot;hello world&quot; using QMainWindow and dynamically loaded .ui from Widget Designer on Sat, 05 Sep 2026 10:50:04 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jim-g">@<bdi>Jim-G</bdi></a> Hi,  Kindly check this Qt Designer Tutorials from my channel, it is suitable for beginners like you <a href="https://www.youtube.com/watch?v=_31LgDG_HDE&amp;list=PLKvmdGUvITo1QlVWF5eDlye7VZaodvwFg" target="_blank" rel="noopener noreferrer nofollow ugc">https://www.youtube.com/watch?v=_31LgDG_HDE&amp;list=PLKvmdGUvITo1QlVWF5eDlye7VZaodvwFg</a></p>
]]></description><link>https://forum.qt.io/post/839992</link><guid isPermaLink="true">https://forum.qt.io/post/839992</guid><dc:creator><![CDATA[Ronel_qtmaster]]></dc:creator><pubDate>Sat, 05 Sep 2026 10:50:04 GMT</pubDate></item><item><title><![CDATA[Reply to Beginner question - Simple &quot;hello world&quot; using QMainWindow and dynamically loaded .ui from Widget Designer on Sat, 05 Sep 2026 10:02:29 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jim-g">@<bdi>Jim-G</bdi></a><br />
Revisiting what you are trying to do with <code>QUiLoader()</code>.  You should be following the example from <a href="https://doc.qt.io/qtforpython-6/tutorials/basictutorial/uifiles.html#option-b-loading-it-directly" target="_blank" rel="noopener noreferrer nofollow ugc">Option B: Loading it directly</a>.</p>
<p dir="auto">Note that there the <code>mainwindow.ui</code> file  --- same as your <code>test.ui</code> in that it has</p>
<pre><code> &lt;class&gt;MainWindow&lt;/class&gt;
 &lt;widget class="QMainWindow" name="MainWindow"&gt;
</code></pre>
<p dir="auto">--- is the <em>only</em> occurrence of any <code>QMainWindow</code> in that code.  It does not have <em>another</em> <code>QMainWindow</code> where you do and go <code>self.ui = loader.load("test.ui")</code>.  PySide6 <code>QUiLoader().load("test.ui")</code> creates and returns a complete, new <code>MainWindow</code>/<code>QMainWindow</code> widget.  So you won't want to create your own, separate <code>MainWindow</code>/<code>QMainWindow</code>.</p>
<p dir="auto">If you want to persist with this, I suggest you start from the linked code and modify as desired from there.</p>
]]></description><link>https://forum.qt.io/post/839990</link><guid isPermaLink="true">https://forum.qt.io/post/839990</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Sat, 05 Sep 2026 10:02:29 GMT</pubDate></item><item><title><![CDATA[Reply to Beginner question - Simple &quot;hello world&quot; using QMainWindow and dynamically loaded .ui from Widget Designer on Sat, 05 Sep 2026 10:21:34 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jim-g">@<bdi>Jim-G</bdi></a><br />
I don't know where you are really at now, because I do not get the same results as you do.  FWIW I am using Ubuntu 26.04, Qt 6.10.2, PySide 6.11.1.  But I am not expecting any difference for you from different versions or platform (e.g. Windows if that is what you are using).</p>
<ul>
<li>
<p dir="auto">If I copy and paste your original code I get a visual window.  It is a main window.  It opens "small", but I can drag-resize it and it looks similar to what you showed in both screenshots.  But note this whole code is quite wrong: you end up with two <code>QMainWindow</code>s, one is your <code>MainWindow</code> and the other is a <code>QMainWindow</code> from your <code>.ui</code> file which has been set as the central widget via <code>self.setCentralWidget(self.ui)</code>.  You do not want a <code>QMainWindow</code> as the type of the central widget of a <code>QMainWindow</code>!</p>
</li>
<li>
<p dir="auto">If I replace <em>just</em> <code>MainWindow</code>'s <code>def __init(self)</code> per your last post I get an <em>empty</em> <code>MainWindow</code> --- your title but no content.  And the same whether <code>loader.load(ui_file, self)</code> has <code>self</code> as parameter or not.  No "hang", no "no window displayed".</p>
</li>
</ul>
<p dir="auto">So if you really want to use, or have people investigate, you attempted use of <code>QUiLoader()</code>, I suggest you paste a new complete but minimal example of your code as it is, as I am guessing it is not just as you show/I have copied.</p>
<p dir="auto">(I still don't think the new code can be right: <code>self</code> is your <code>MainWindow</code>, which is a <code>QMainWindow</code>, and when your <code>__init()</code> goes <code>self.setLayout(layout)</code> that sets the whole layout of a <code>QMainWindow</code> which you would <em>never</em> want to do.  The point of a <code>QMainWindow</code> is that it already has its own layout with various widgets to produce menus and status bars.  It has one area in the "middle" which is the "central widget" and you should only be setting that and its layout and content.)</p>
<p dir="auto">(Also, if <code>self.ui = loader.load(ui_file)</code> or similar is used to create and load a <code>QMainWindow</code>, you would never want to call  <code>self.ui = loader.load(ui_file, something)</code>, whether <code>something</code> is <code>self</code> or any other <code>QWidget</code>.  That would be a <em>parent</em> widget for the created widget, and you should only use a <code>QMainWindow</code> as a top-level widget/window, it would never have a parent.)</p>
<p dir="auto"><em>Personally</em> I do not think you will gain much by persisting with <code>QUiLoader()</code>/<code>loader.load(ui_file)</code> since I don't think that is the best way to use Qt/Designer back-end code.  As I have said I would abandon that approach and use the class-generation one instead.  I have never used <code>QUiLoader()</code> so don't have much experience, but will look again at your code (if made to work) if you wish to continue with that.</p>
]]></description><link>https://forum.qt.io/post/839988</link><guid isPermaLink="true">https://forum.qt.io/post/839988</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Sat, 05 Sep 2026 10:21:34 GMT</pubDate></item><item><title><![CDATA[Reply to Beginner question - Simple &quot;hello world&quot; using QMainWindow and dynamically loaded .ui from Widget Designer on Fri, 04 Sep 2026 19:03:16 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a> Thanks for the detailed response.</p>
<p dir="auto">I'm using the .ui file approach only while I learn Qt and prototype my application, and will switch to generating code once the user interface is stable.</p>
<p dir="auto">There's a lot to digest in your response and I'll follow up on your reading suggestions.</p>
<p dir="auto">Clearly there's still a lot wrong in my mental model of how things work.  For example, since my last post I have whittled things down to this:</p>
<pre><code>    def __init__(self):
        super().__init__()
        
        loader = QUiLoader()
        ui_file = QFile("../../../qtTest/test.ui")
        if not ui_file.open(QFile.ReadOnly):
            print("Cannot open ui file")
            sys.exit(-1)
        
        self.ui = loader.load(ui_file)
        ui_file.close()

        layout = QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.addWidget(self.ui)
        self.setLayout(layout)
        self.setWindowTitle("My Qt Designer App")
</code></pre>
<p dir="auto">This works and produces the minimum-size window from my previous post.  Notice however <code>self.ui = loader.load(ui_file)</code>,  where <em>don't</em> specify the parent widget.  If I change the code to <code>self.ui = loader.load(ui_file, self)</code> then the code hangs at <code>app.exec()</code> with no window displayed.</p>
]]></description><link>https://forum.qt.io/post/839984</link><guid isPermaLink="true">https://forum.qt.io/post/839984</guid><dc:creator><![CDATA[Jim G]]></dc:creator><pubDate>Fri, 04 Sep 2026 19:03:16 GMT</pubDate></item><item><title><![CDATA[Reply to Beginner question - Simple &quot;hello world&quot; using QMainWindow and dynamically loaded .ui from Widget Designer on Fri, 04 Sep 2026 08:47:38 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jim-g">@<bdi>Jim-G</bdi></a><br />
I am a big fan of Qt, having used it for years, but not so much of the Designer part of Qt Creator.  It can be arcane.  But it is what it is, and if you want to design your UI visually you have to work with it.</p>
<p dir="auto">Unfortunately you picked to start your experience with a <code>QMainWindow</code> (which many people do) and that does have a wrinkle making it confusing/unintuitive.  You would indeed expect to place a layout on the <code>centralWidget</code> and that is what you do from code.  But for some inexplicable reason Designer forbids that and you are supposed to know/guess you need to do it there on the <code>MainWindow</code> rather than the <code>centralWidget</code>.  Even though it then applies that to the <code>centralWidget</code>.  I only discovered this recently where I was stuck on just this issue.  Read through my <a href="https://forum.qt.io/topic/164873/creator-cannot-set-layout-on-qmainwindow-centralwidget">https://forum.qt.io/topic/164873/creator-cannot-set-layout-on-qmainwindow-centralwidget</a> and you will see!  This particular problem only arises on a <code>QMainWindow</code> with its <code>centralWidget</code>.</p>
<p dir="auto">A couple of useful tips for Designer:</p>
<ul>
<li>
<p dir="auto">Look at the object hierarchy for "red no-entry" signs.  If you see one it means that widget does not have a layout.  It will need one, else you won't be able to position/resize properly etc.  (Don't be tempted to use absolute coordinates/positioning, unless you have a special case you always want to use layouts.)</p>
</li>
<li>
<p dir="auto">In general (say starting from a plain <code>QWidget</code>) you (I at least) would expect to place the widget, then add a layout, then add any child widgets.  Common-sense, right?  And how you would do it in code.  In Designer you have <em>first</em> place at least one child widget on the parent widget, only then can you go back and place a layout (which you need) on the parent widget.  You can even delete any child widgets afterwards if you wish and the layout will stay, but you need a child widget to place it initially.</p>
</li>
<li>
<p dir="auto">Don't be afraid to look at the generated <code>.ui</code> file.  It is XML and you can understand fairly intuitively where it puts what relating to your design.  (Don't edit it though as it will get overwritten).  For example, in your case of having to place the layout on the <code>QMainWindow</code> you would see that it actually places it on the <code>centralWidget</code> in the <code>.ui</code> file!</p>
</li>
</ul>
<blockquote>
<p dir="auto">Question: Is there a canonical example of how to accomplish this with a Desinger-generated .ui dynamically loaded, and QMainWIndow? Or, is that just the wrong approach?</p>
</blockquote>
<blockquote>
<p dir="auto"><code>loader = QUiLoader()</code><br />
<code>ui_file = QFile("../../../qtTest/test.ui")</code><br />
<code>self.ui = loader.load(ui_file, self)</code></p>
</blockquote>
<p dir="auto">My strongest recommendation would be <strong>NOT</strong> to do it this way.  Being able to load the <code>.ui</code> at runtime is really only useful in specific, unusual circumstances.  C++ does have this approach too, but it is even harder to use than from Python.</p>
<blockquote>
<pre><code>    # (Assuming you have a button named 'submit_btn' in Qt Designer)
    self.ui.pushButton.clicked.connect(self.on_submit_clicked)
</code></pre>
</blockquote>
<p dir="auto">Correct me if I am wrong, but when you type that line into your Python editor IDE you get no "help" at all on the <code>self.ui.pushButton</code>, right?  The editor does not know about it, cannot offer you completion and it would error at runtime if it turns out your <code>.ui</code> file does not have a push button named <code>pushButton</code>.  This is because at design-/edit-time it has no idea that you are loading a file into <code>ui</code> nor what that file contains.</p>
<p dir="auto">Read (again?) through <a href="https://doc.qt.io/qtforpython-6/tutorials/basictutorial/uifiles.html" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qtforpython-6/tutorials/basictutorial/uifiles.html</a>.  You have taken approach <strong>Option B: Loading it directly</strong>.  Don't :)  Get yourself working with <strong>Option A: Generating a Python class</strong> there.  That does mean you will need to run something like <code>pyside6-uic mainwindow.ui -o ui_mainwindow.py</code> each time you change the <code>.ui</code> file but I think you can have that done automatically from Creator for Python, you certainly do for C++.  Once you have a class for each <code>.ui</code> file you can work with it and its members/widgets fully at edit time.  You also do not need to distribute/have in existence your <code>.ui</code> files at runtime.  (You can also examine the generated <code>ui_....py</code> files and see/learn how the <code>.ui</code> content is turned into Python/PySide2 code which can be helpful.)</p>
<blockquote>
<p dir="auto">When I increase the running window height (by dragging the resize handle), the group box resizes and the radio buttons spread out, but at least I can see everything.</p>
</blockquote>
<p dir="auto">That means a <code>QGroupBox</code> is set by default to grow when the window/parent grows.  If you don't want this behaviour do something like set it to have a fixed size.</p>
]]></description><link>https://forum.qt.io/post/839977</link><guid isPermaLink="true">https://forum.qt.io/post/839977</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Fri, 04 Sep 2026 08:47:38 GMT</pubDate></item><item><title><![CDATA[Reply to Beginner question - Simple &quot;hello world&quot; using QMainWindow and dynamically loaded .ui from Widget Designer on Fri, 04 Sep 2026 00:12:51 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/nils-sjoberg">@<bdi>Nils-Sjoberg</bdi></a></p>
<p dir="auto">Thanks for your quick reply.  Sorry, but as a beginner with Qt, I'm not sure I understand your suggestions completely.</p>
<ul>
<li><em><strong>In designer activate "Lay Out Vertically" on the centralwidget</strong></em><br />
I don't see an option to "lay out vertically" (or just Lay Out) in the context menu nor in the property editor for <code>centralwidget</code>.  There's a "Layout" section at the bottom of the property editor called <code>verticalLayout_3</code> but it specifies only margins, spacing, stretch and size constraints.</li>
<li><em><strong>change the root of the .ui from QMainWindow to a regular QWidget</strong></em><br />
In Designer or in my code?  To clarify:
<ul>
<li><strong>Question</strong>: Are you saying my Python <code>MainWindow</code> class should inherit from <code>QWidget</code> instead of <code>QMainWIndow</code>?</li>
<li><strong>Question</strong>: Is it the case that since the Designer generates a <code>QMainWindow</code> in the .ui file, it is redundant to inherit from <code>QMainWindow</code> in the code?</li>
</ul>
</li>
</ul>
<p dir="auto">Meanwhile, I got it working, but by a different change.</p>
<p dir="auto">What I actually did was right-click in Designer on the <code>MainWindow</code> line in the object inspector, selected "Lay Out" and then clicked "Lay Out Vertically" (in <code>MainWindow</code>, not in the <code>centralwidget</code> object, which <em>didn't have a "Lay Out" context menu entry</em>).  I then ran my existing code with no changes other than the new .ui file.</p>
<p dir="auto">The result of that was a window containing all the controls, at the minimum possible size for those controls:</p>
<p dir="auto"><img src="https://ddgobkiprc33d.cloudfront.net/6bd07ecb-fe72-43a9-a955-d617be46ec78.PNG" alt="2026-09-03_16-50-49.PNG" class=" img-fluid img-markdown" /></p>
<p dir="auto">I still have a lot to learn... When I increase the running window height (by dragging the resize handle), the group box resizes and the radio buttons spread out, but at least I can see everything.</p>
<p dir="auto">I'll be curious to see your answers to my questions above.</p>
]]></description><link>https://forum.qt.io/post/839966</link><guid isPermaLink="true">https://forum.qt.io/post/839966</guid><dc:creator><![CDATA[Jim G]]></dc:creator><pubDate>Fri, 04 Sep 2026 00:12:51 GMT</pubDate></item><item><title><![CDATA[Reply to Beginner question - Simple &quot;hello world&quot; using QMainWindow and dynamically loaded .ui from Widget Designer on Thu, 03 Sep 2026 20:56:32 GMT]]></title><description><![CDATA[<p dir="auto">You can always, always use me.</p>
]]></description><link>https://forum.qt.io/post/839964</link><guid isPermaLink="true">https://forum.qt.io/post/839964</guid><dc:creator><![CDATA[Nils Sjoberg]]></dc:creator><pubDate>Thu, 03 Sep 2026 20:56:32 GMT</pubDate></item><item><title><![CDATA[Reply to Beginner question - Simple &quot;hello world&quot; using QMainWindow and dynamically loaded .ui from Widget Designer on Thu, 03 Sep 2026 20:56:00 GMT]]></title><description><![CDATA[<p dir="auto">In Designer, activate "Lay Out Vertically" on the centralwidget and the groupBox content (so that there is a real layout instead of a fixed geometry), and at the same time change the root of the .ui from QMainWindow to a regular QWidget and load it with loader.load(ui_file) without an additional container in the code.</p>
]]></description><link>https://forum.qt.io/post/839963</link><guid isPermaLink="true">https://forum.qt.io/post/839963</guid><dc:creator><![CDATA[Nils Sjoberg]]></dc:creator><pubDate>Thu, 03 Sep 2026 20:56:00 GMT</pubDate></item></channel></rss>