1.from two import Ui_Form as t1
class atwo(QtWidgets.QWidget,t1):
def init(self):
super(atwo,self).init()
self.setupUi(self)
class mainone(QMainWindow,Ui_MainWindow):
def init(self):
super(mainone,self).init()
self.setupUi(self)
self.atwo1=atwo()
self.pushButton_8.clicked.connect(self.twoshow)
def twoshow(self):
self.gridLayout.addWidget(self.atwo1)
self.atwo1.show()
if name == 'main':
app = QApplication(sys.argv)
mainWindow = QMainWindow()
mainWindow=mainone()
ui = Ui_MainWindow()
ui.setupUi(mainWindow)
mainWindow.show()
sys.exit(app.exec_())
在two窗体上有一个lineEdit控件,想修改其内容
在two有按钮pushButton
self.pushButton.clicked.connect(command.begin)
command文件中
def begin(self):
self.t1.lineEdit_2.setText("显示")
当执行时这时出错,请教各位怎么改?
2.from two import Ui_Form as t1
class atwo(QtWidgets.QWidget,t1):
def init(self):
super(atwo,self).init()
self.setupUi(self)
class mainone(QMainWindow,Ui_MainWindow):
def init(self):
super(mainone,self).init()
self.setupUi(self)
self.atwo1=atwo()
self.pushButton_8.clicked.connect(self.twoshow)
def twoshow(self):
self.gridLayout.addWidget(self.atwo1)
self.atwo1.show()
if name == 'main':
app = QApplication(sys.argv)
mainWindow = QMainWindow()
mainWindow=mainone()
ui = Ui_MainWindow()
ui.setupUi(mainWindow)
mainWindow.show()
sys.exit(app.exec_())
在two窗体上有一个lineEdit控件,想修改其内容
在two有按钮pushButton
self.pushButton.clicked.connect(command.begin)
command文件中
def begin(self):
self.t1.lineEdit_2.setText("显示")
当执行时这时出错,请教各位怎么改?
self.t1.lineEdit_2.setText("显示")出错
或者应怎么写?
方法就应该写在类里面,否则self是不会自动加上的,你可以试试用xxx.connect(partial(comand.begin, self)),,不过不推荐使用这种写法,,from functools import partial
举个例子:
,不过还是劝你老实把begin放到two类里面去
3.