1
這裏是我的code.all工作正常但我想在MainWindow中的標籤中顯示名稱(在登錄對話框中輸入)。Pyqt:將名稱表單登錄對話框傳遞給MainWindow
import sys
from PyQt4 import QtGui,QtCore
from loginD import *
from mainwindow import Ui_MainWindow
class Login(QtGui.QDialog):
def __init__(self,parent=None):
QtGui.QDialog.__init__(self,parent)
self.ui=Ui_LoginD()
self.ui.setupUi(self)
self.ui.PasswordLE.setEchoMode(QtGui.QLineEdit.Password)
pilot=str(self.ui.PilotNameLE.text())
QtCore.QObject.connect(self.ui.LoginPB,QtCore.SIGNAL('clicked()'),
self.HandleLogin)
def HandleLogin(self):
if self.ui.PasswordLE.text()=="a":
self.accept()
else:
QtGui.QMessageBox.warning(
self,'Error;','bad')
class Main_Window(QtGui.QMainWindow):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self,parent)
self.ui=Ui_MainWindow()
self.ui.setupUi(self)
self.ui.PioltNameL.setText(str(pilot))
if __name__=='__main__':
app=QtGui.QApplication(sys.argv)
if Login().exec_()==QtGui.QDialog.Accepted:
window=Main_Window()
window.show()
sys.exit(app.exec_())
我想在對話框類傳遞(從pilotnamelinediet)試點pilotname標籤在主窗口class.how辦呢?
謝謝,但我如何分配導航名稱在mainwindow標籤? – 2014-11-04 12:47:59
對不起,我錯過了。看看**編輯**在我的回答 – Aleksandar 2014-11-04 13:45:38
我認爲你在這行中拼錯了標籤名稱:'self.ui.PioltNameL.setText(str(pilot))' – Aleksandar 2014-11-04 13:50:22