<?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[Python has stopped working &#x2F; AttributeError: &#x27;Ui_Form&#x27; object has no attribute &#x27;lineEdit&#x27;]]></title><description><![CDATA[<p dir="auto">I want to set the label in <a href="http://B.py" target="_blank" rel="noopener noreferrer nofollow ugc">B.py</a> to whatever the user typed in <a href="http://A.py" target="_blank" rel="noopener noreferrer nofollow ugc">A.py</a> self.lineEdit. However, when I clicked the button in <a href="http://A.py" target="_blank" rel="noopener noreferrer nofollow ugc">A.py</a>, the application crashed and display this message: Python has stopped working. Then I ran <a href="http://B.py" target="_blank" rel="noopener noreferrer nofollow ugc">B.py</a> to see what is the problem and this error shows: AttributeError: 'Ui_Form' object has no attribute 'lineEdit'.</p>
<pre><code>A.py

from PyQt6 import QtCore, QtGui, QtWidgets
import B

class Ui_Form(object):
    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(203, 146)
        self.verticalLayout = QtWidgets.QVBoxLayout(Form)
        self.verticalLayout.setContentsMargins(0, 0, 0, 0)
        self.verticalLayout.setSpacing(0)
        self.verticalLayout.setObjectName("verticalLayout")
        self.lineEdit = QtWidgets.QLineEdit(Form)
        self.lineEdit.setObjectName("lineEdit")
        self.verticalLayout.addWidget(self.lineEdit)
        self.pushButton = QtWidgets.QPushButton(Form)
        self.pushButton.setObjectName("pushButton")
        self.verticalLayout.addWidget(self.pushButton)

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)

        self.pushButton.clicked.connect(self.enter)
        self.pushButton.clicked.connect(Form.close)

    def retranslateUi(self, Form):
        _translate = QtCore.QCoreApplication.translate
        Form.setWindowTitle(_translate("Form", "Form"))
        self.pushButton.setText(_translate("Form", "Enter"))

    def enter(self):
        self.lineedit_txt = self.lineEdit.text()

        self.window_login1 = QtWidgets.QWidget()
        self.ui_login1 = B.Ui_Form()
        self.ui_login1.setupUi2(self.window_login1)
        self.window_login1.show()

if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    Form = QtWidgets.QWidget()
    ui = Ui_Form()
    ui.setupUi(Form)
    Form.show()
    sys.exit(app.exec())

B.py

from PyQt6 import QtCore, QtGui, QtWidgets


class Ui_Form(object):
    def setupUi2(self, Form):
        Form.setObjectName("Form")
        Form.resize(400, 300)
        self.verticalLayout = QtWidgets.QVBoxLayout(Form)
        self.verticalLayout.setObjectName("verticalLayout")
        self.label = QtWidgets.QLabel(Form)
        self.label.setText("")
        self.label.setObjectName("label")
        self.verticalLayout.addWidget(self.label)

        self.retranslateUi(Form)
        QtCore.QMetaObject.connectSlotsByName(Form)

        self.output()

    def retranslateUi(self, Form):
        _translate = QtCore.QCoreApplication.translate
        Form.setWindowTitle(_translate("Form", "Form"))
      
    def output(self):
        import A
        obj = A.Ui_Form()
        obj.enter()

        txt_for_label = obj.lineedit_txt
        self.label.setText(txt_for_label)

if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    Form = QtWidgets.QWidget()
    ui = Ui_Form()
    ui.setupUi2(Form)
    Form.show()
    sys.exit(app.exec())

</code></pre>
]]></description><link>https://forum.qt.io/topic/139208/python-has-stopped-working-attributeerror-ui_form-object-has-no-attribute-lineedit</link><generator>RSS for Node</generator><lastBuildDate>Fri, 30 Oct 2026 02:01:09 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/139208.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 10 Sep 2022 07:33:59 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Python has stopped working &#x2F; AttributeError: &#x27;Ui_Form&#x27; object has no attribute &#x27;lineEdit&#x27; on Sun, 11 Sep 2022 14:39:39 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jerap">@<bdi>jerap</bdi></a><br />
You need to start by sorting out your architecture before that.  How are A and B related?  Which one shows which one?  Is only one at a time supposed to be visible, are they both supposed to be visible all the time?  I suggest you don't worry about the label till you have that sorted out.</p>
<p dir="auto">Then they way to pass information between one and the other will be clearer.</p>
]]></description><link>https://forum.qt.io/post/728217</link><guid isPermaLink="true">https://forum.qt.io/post/728217</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Sun, 11 Sep 2022 14:39:39 GMT</pubDate></item><item><title><![CDATA[Reply to Python has stopped working &#x2F; AttributeError: &#x27;Ui_Form&#x27; object has no attribute &#x27;lineEdit&#x27; on Sun, 11 Sep 2022 13:50:14 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jonb">@<bdi>JonB</bdi></a><br />
What I want to do is to set the text of <code>B.self.label</code> to whatever the user inputs in <code> A.self.lineEdit</code>.</p>
]]></description><link>https://forum.qt.io/post/728211</link><guid isPermaLink="true">https://forum.qt.io/post/728211</guid><dc:creator><![CDATA[jerap]]></dc:creator><pubDate>Sun, 11 Sep 2022 13:50:14 GMT</pubDate></item><item><title><![CDATA[Reply to Python has stopped working &#x2F; AttributeError: &#x27;Ui_Form&#x27; object has no attribute &#x27;lineEdit&#x27; on Sat, 10 Sep 2022 08:49:35 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jerap">@<bdi>jerap</bdi></a><br />
Let's start with:</p>
<pre><code># In `A.enter()`
self.ui_login1 = B.Ui_Form()

# In `B.output()`
        import A
        obj = A.Ui_Form()
        obj.enter()
</code></pre>
<p dir="auto">That does not look very promising, crash-wise....</p>
<p dir="auto">Next: when as above in <code>B.output()</code> you do go</p>
<pre><code>        import A
        obj = A.Ui_Form()
        obj.enter()
</code></pre>
<p dir="auto">you have never gone <code>A.Ui_Form.setupUi()</code> so your <code>A.Form</code> does not have any <code>self.lineEdit</code>, doubtless hence the error message.</p>
<p dir="auto">Don't know what you're trying to do with this convolution, but you'd better sort your instances of <code>A</code> &amp; <code>B</code> out because I suspect you're failing to understand correctly accessing existing instances and creating new ones afresh without understanding.</p>
]]></description><link>https://forum.qt.io/post/728133</link><guid isPermaLink="true">https://forum.qt.io/post/728133</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Sat, 10 Sep 2022 08:49:35 GMT</pubDate></item></channel></rss>