Unsolved Validating a dateEdit and a Label
-
Hi,
I have written a function to validate a dateEdit and a Label which displays an image. I don't know what I'm doing wrong, I would appreciate assistance. Thank you. Below are my lines.self.ui.PushButton.clicked.connect(self.my_func) def my_func(self): dob = self.ui.Date_of_Birth_dateEdit.date().toString() pixmap = QPixmap(self.fname) self.ui.Display_label.setPixmap(QPixmap(pixmap)) if dob == '': QMessageBox.information(self, "Error", "Select Date Of Birth") self.ui.Date_of_Birth_dateEdit.setFocus() elif self.ui.Display_label.setPixmap(QPixmap(pixmap)) == ' ': self.ui.Display_label.setFocus() else: self.ui.stackedWidget.setCurrentWidget(self.ui.Page_one)
-
@LT-K101 said in Validating a dateEdit and a Label:
I don't know what I'm doing wrong
And I don't know what the problem is...
Also, what does "validate" mean here?
Can you please explain what you want to do and what does not work? -
@jsulm I want to prompt the user, if the user leave a field empty and want to move to the next page by clicking on a Qpushbutton. The App should display a message using a Qmessagebox and setfocus on the empty field so the user will know the exact field which is empty. I used same logic for QLineEdit and it works fine but for QdateEdit and QLabel it does not work.
-
@LT-K101 said in Validating a dateEdit and a Label:
dob = self.ui.Date_of_Birth_dateEdit.date().toString() ... if dob == '':
Did you check to see whether this can ever return the
''
empty string? I don't think it can.if the user leave a field empty
Could you explain how the user gets to leave a
QDateEdit
empty? I don't think he can.