在单击确定按钮时,在接受对话框之前,我需要检查是否有任何lineEdits为空。我试图覆盖这样的buttonBox接受的插槽:
#self.buttonBox.accepted.connect(Dialog.accept)
self.buttonBox.rejected.connect(Dialog.reject)
QtCore.QMetaObject.connectSlotsByName(Dialog)
self.buttonBox.accepted.connect(self.validate)
def validate(self, Dialog):
if (self.lineEdit.text() == '' or self.lineEdit_2.text() == '' or self.lineEdit_3.text() == '' or self.lineEdit_4.text() == '' or self.lineEdit_5.text() == ''):
QtWidgets.QMessageBox.about(QtWidgets.QMessageBox(), 'Error', 'All fields are mandatory!')
else:
Dialog.accept()
但是我得到了错误:
TypeError: validate() missing 1 required positional argument: 'Dialog'