i have 2 forms (form1.ui & form2.ui). form1 contains a list for products and a pushbutton of new product. the new product button opens a new form2 which has a editline and a insert button .the insert button calls a method from another class(AllMethods class) which inserts the content of editline content to the list in form1..... the error is allmethod instance has no attribute itemlist(name of Qlist)
import sys
from PyQt4 import QtGui, uic
class AllMethods:
def addListMethod(self,itm):
itemList.addItem(itm)
#_________FORM2____________
class Form2(QtGui.QMainWindow):
def __init__(self):
super(Form2,self).__init__()
uic.loadUi('Form2.ui',self)
self.show()
self.insertItem.clicked.connect(self.insertItem_clicked)
def insertItem_clicked(self):
obj = AllMethods()
obj.addListMethod(self.itemname.text())
#_________FORM1____________
class Form1(QtGui.QMainWindow):
def __init__(self):
super(Form1,self).__init__()
uic.loadUi('Form1.ui',self)
self.show()
self.newItem.clicked.connect(self.newItem_clicked)
def newItem_clicked(self):
self.form_second = Form2()
self.form_second.show()
#_________________MAIN____________________
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
window = Form1()
sys.exit(app.exec_())
i tried to call Form1 class like
mainF = Form1()
mainF.itemlist.addItem(itm)
but another form1 pops up and dissapear in a second and the opened form1 remains same empty.
actually this is the small program that illustrates my problem in the main program i have.