<?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[Unable to load UI]]></title><description><![CDATA[<p dir="auto">I have the code below:</p>
<pre><code>class type_select(QDialog):
    def __init__(self):
        super(type_select, self).__init__()
        loadUi('UI_1.ui', self)
        global t
        if self.HO.isChecked()==True:
            t=1
        elif self.Multi.isChecked()==True:
            t=2
        elif self.VT.isChecked()==True:
            t=3
        elif self.Fix.isChecked()==True:
            t=4
        else:
            t=0
        if t!=0:
            self.config.clicked.connect(self.config_func)
    
    def config_func(self):
        config_window=configuration_ui(t)
        widget.setFixedWidth(640)
        widget.setFixedHeight(600)
        widget.addWidget(config_window)
        widget.setCurrentIndex(widget.currentIndex()+1)

class configuration_ui(QDialog):
    def __init__(self, te):
        super(configuration_ui, self).__init__()
        loadUi('configuration.ui', self)
        tau=te

if __name__=='__main__':
    app=QApplication(sys.argv)
    type_selection=type_select()
    widget=QtWidgets.QStackedWidget()
    widget.addWidget(type_selection)
    widget.setFixedWidth(240)
    widget.setFixedHeight(320)
    widget.show()
    sys.exit(app.exec_())
</code></pre>
<p dir="auto">it  doesn't load the configuration ui.<br />
what is the coding issue here?</p>
]]></description><link>https://forum.qt.io/topic/157864/unable-to-load-ui</link><generator>RSS for Node</generator><lastBuildDate>Sat, 07 Nov 2026 06:02:31 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/157864.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 24 Jul 2024 04:46:37 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Unable to load UI on Wed, 21 Aug 2024 09:15:08 GMT]]></title><description><![CDATA[<p dir="auto">(Try to avoid loadUi at all cost, and rely on generating a Python file out of it <a href="https://doc.qt.io/qtforpython-6/tutorials/basictutorial/uifiles.html#option-a-generating-a-python-class" target="_blank" rel="noopener noreferrer nofollow ugc">https://doc.qt.io/qtforpython-6/tutorials/basictutorial/uifiles.html#option-a-generating-a-python-class</a> )</p>
]]></description><link>https://forum.qt.io/post/807757</link><guid isPermaLink="true">https://forum.qt.io/post/807757</guid><dc:creator><![CDATA[CristianMaureira]]></dc:creator><pubDate>Wed, 21 Aug 2024 09:15:08 GMT</pubDate></item><item><title><![CDATA[Reply to Unable to load UI on Wed, 24 Jul 2024 13:02:32 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/vidyul">@<bdi>vidyul</bdi></a> said in <a href="/post/805597">Unable to load UI</a>:</p>
<blockquote>
<p dir="auto">The file is in the same directory as other ui and files used in the code</p>
</blockquote>
<p dir="auto">Doesn't change anything I wrote before.<br />
Again: 'UI_1.ui' is a RELATIVE path - relative to current working directory.<br />
Construct correct path to load the file...</p>
]]></description><link>https://forum.qt.io/post/805611</link><guid isPermaLink="true">https://forum.qt.io/post/805611</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Wed, 24 Jul 2024 13:02:32 GMT</pubDate></item><item><title><![CDATA[Reply to Unable to load UI on Wed, 24 Jul 2024 12:05:14 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/vidyul">@<bdi>vidyul</bdi></a> said in <a href="/post/805597">Unable to load UI</a>:</p>
<blockquote>
<p dir="auto">The file is in the same directory as other ui and files used in the code</p>
</blockquote>
<p dir="auto">So what?  <code>loadUi('UI_1.ui', self)</code> tries to open a file named <code>UI_1.ui</code> in the process's <em>current working directory</em>.  Have you checked what that is when your Python code is run?  What does <code>QFile.exists('UI_1.ui')</code> return?  Can you start by establishing what <code>loadUi('UI_1.ui', self)</code> returns/does, as I cannot find a doc page for this by Googling.  Also --- and I may be mistaken about this --- I <em>thought</em> that <code>loadUi()</code> behaves differently between PyQt and PySide and I have not seen you mention which one you are using.</p>
]]></description><link>https://forum.qt.io/post/805601</link><guid isPermaLink="true">https://forum.qt.io/post/805601</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Wed, 24 Jul 2024 12:05:14 GMT</pubDate></item><item><title><![CDATA[Reply to Unable to load UI on Wed, 24 Jul 2024 11:55:31 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jsulm">@<bdi>jsulm</bdi></a> The file is in the same directory as other ui and files used in the code. Another method I used (suggested by chatgpt), works fine but not this. I didn't understand why though.</p>
<pre><code>class type_select(QDialog):
    t=0
    def __init__(self, set_settings=None):
        super(type_select, self).__init__()
        loadUi('UI_1.ui', self)
        self.config.clicked.connect(self.config_func)
        self.HO.toggled.connect(self.update)
        self.Multi.toggled.connect(self.update)
        self.VT.toggled.connect(self.update)
        self.Fix.toggled.connect(self.update)
    
    def update(self):
        rb = self.sender()
        if rb.isChecked():
            self.config.setEnabled(True)
            if rb.text()=='HO':
                self.t=1
            elif rb.text()=="Multi":
                self.t=2
            elif rb.text()=="VT":
                self.t=3
            else:
                self.t=4
     def config_func(self):
            config_window=configuration_ui(self.t)
            widget.setFixedWidth(640)
            widget.setFixedHeight(640)
            widget.addWidget(config_window)
            widget.setCurrentIndex(widget.currentIndex()+1)
</code></pre>
]]></description><link>https://forum.qt.io/post/805597</link><guid isPermaLink="true">https://forum.qt.io/post/805597</guid><dc:creator><![CDATA[vidyul]]></dc:creator><pubDate>Wed, 24 Jul 2024 11:55:31 GMT</pubDate></item><item><title><![CDATA[Reply to Unable to load UI on Wed, 24 Jul 2024 05:11:29 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/vidyul">@<bdi>vidyul</bdi></a> said in <a href="/post/805552">Unable to load UI</a>:</p>
<blockquote>
<p dir="auto">what is the coding issue here?</p>
</blockquote>
<p dir="auto">Well, I guess it can't find the ui file since you're using a relative path, which by default is relative to the current working directory of the running process.<br />
Either put the ui file in a resource file or make sure it is deployed correctly together with your application and you're using a correct path to load it.</p>
]]></description><link>https://forum.qt.io/post/805553</link><guid isPermaLink="true">https://forum.qt.io/post/805553</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Wed, 24 Jul 2024 05:11:29 GMT</pubDate></item></channel></rss>