QLineEdit을 사용하고 있는데 PyQt에서 2 화면 후에 참조해야합니다. 내가QLineEdit가 두 자리 뒤에 삭제됨
Traceback (most recent call last): File "[filename]", line 227, in passwordmissing2ndscreenverify P1=self.entrypasswordmissingscreen1.text() RuntimeError: wrapped C/C++ object of type QLineEdit has been deleted
를 참조 할 때 나는 일관되게이 오류가 계속하지만이 이해할 수있을 것이다 사람이 그것을 도울 수 있다면 그렇게하기 전에 여러 화면에서 사물을 참조 복잡한 프로그램을 만들 Qt를 사용하여 내 처음이다 . Heres는
뿐만 아니라 그 부분에 대한 코드 :
우리가 passwordmissing1stscreen에서P1 = self.entrypasswordmissingscreen1.text()
을하는 대신 완벽하게 작동하는 솔루션 우연히 친구와 다른 동료 프로그래머 일부 논의 후, 그래서
def passwordmissing1stscreen(self):
#layouts
self.mainLayout=QtWidgets.QVBoxLayout()
self.secondaryLayout=QtWidgets.QHBoxLayout()
#Labels
self.passwordMissing1stScreenlabel= QtWidgets.QLabel("Please enter the new password")
#buttons
self.cancelbutton=QtWidgets.QPushButton("Cancel", self)
self.okButton=QtWidgets.QPushButton("OK", self)
#input
self.entrypasswordmissingscreen1 = QtWidgets.QLineEdit()
P1 = self.entrypasswordmissingscreen1.text()
#conections
self.cancelbutton.clicked.connect(self.exit)
self.okButton.clicked.connect(self.passwordmissing2ndscreen)
#add to layouts
self.mainLayout.addWidget(self.passwordMissing1stScreenlabel)
self.mainLayout.addWidget(self.entrypasswordmissingscreen1)
self.secondaryLayout.addWidget(self.okButton)
self.secondaryLayout.addWidget(self.cancelbutton)
self.mainLayout.addLayout(self.secondaryLayout)
#display screen#
self.mainViewWidget = QtWidgets.QWidget()
self.mainViewWidget.setLayout(self.mainLayout)
self.setCentralWidget(self.mainViewWidget)
def passwordmissing2ndscreen(self):
#layouts
self.mainLayout=QtWidgets.QVBoxLayout()
self.secondaryLayout=QtWidgets.QHBoxLayout()
#Labels
self.passwordMissing2ndScreenlabel= QtWidgets.QLabel("Please enter the new password again")
#buttons
self.cancelbutton=QtWidgets.QPushButton("Cancel", self)
self.okButton=QtWidgets.QPushButton("OK", self)
#input
self.entrypasswordmissingscreen2=QtWidgets.QLineEdit()
#add to layouts
self.mainLayout.addWidget(self.passwordMissing2ndScreenlabel)
self.mainLayout.addWidget(self.entrypasswordmissingscreen2)
self.secondaryLayout.addWidget(self.okButton)
self.secondaryLayout.addWidget(self.cancelbutton)
self.mainLayout.addLayout(self.secondaryLayout)
#conections
self.cancelbutton.clicked.connect(self.exit)
self.okButton.clicked.connect(self.passwordmissing2ndscreenverify)
#display screen#
self.mainViewWidget = QtWidgets.QWidget()
self.mainViewWidget.setLayout(self.mainLayout)
self.setCentralWidget(self.mainViewWidget)
def passwordmissing2ndscreenverify(self):
P1=self.entrypasswordmissingscreen1.text()
P2=self.entrypasswordmissingscreen2.text()
print (P1)
print (P2)