I'm trying to build a Python GUI app that adds information to a list with pyqt5 but I'm getting errors.the application should be able to display items that are entered into the lineedit inside the listwidget.
Below is the code:
from PyQt5 import QtWidgets, uic
app = QtWidgets.QApplication([])
form2 = uic.loadUi("login2.ui")
def add_item():
if not form2.LineEdit_item.text() == "":
form2.ListWidget.addItem(form2.LineEdit_item.text())
form2.LineEdit_item.setText("")
form2.PushButton_addItem.clicked.connect(add_item)
form2.show()
app.exec()
and below is the error I'm getting:
Traceback (most recent call last):
File "C:/Users/Windows 10/PycharmProjects/mygui2.py", line 11, in <module>
form2.PushButton_addItem.clicked.connect(add_item)
AttributeError: 'QMainWindow' object has no attribute 'PushButton_addItem'
Process finished with exit code 1
How do i get this sorted out.



PushButton_addItemdefined in your ui file ?