I have noticed that there is a bug in QDateEdit widget, I am using Qt Designer 5.15.2 to design QPushButton, QDateEdit and QLineEdit with python 3.9.2:
Qt Code:
  1. from PyQt5.QtWidgets import *
  2. from PyQt5.uic import loadUiType
  3. import sys
  4. Ui_MainWindow,_ = loadUiType('tst.ui')
  5. class TEST(Ui_MainWindow, QMainWindow):
  6. def __init__(self):
  7. QMainWindow.__init__(self)
  8. self.setupUi(self)
  9. self.btn.clicked.connect(self.enterDATE) #QPushButton signal
  10. def enterDATE(self):
  11. Date_2021_03_26 = "{0}-{1}-{2}".format(self.deDateEdit.date().year(), self.deDateEdit.date().month(), self.deDateEdit.date().day()) #QDateEdit
  12. self.LineEdit.setText(Date_2021_03_26) #QLineEdit
  13. def main():
  14. app = QApplication(sys.argv)
  15. win = TEST()
  16. win.show()
  17. app.exec_()
  18. if __name__ == '__main__':
  19. main()
To copy to clipboard, switch view to plain text mode 
you will notice that when you try to type this specific date: 2021-03-26 by keyboard, it will be rejected (in my case it sat to 2021-03-01)
if you try other dates (try change the year, month and day) it will accept them. why this happened only for this date 2021-03-26?
note that: if you use the updown arrows to type(select) the date, it will accept the date 2021-03-26
I hope someone help me to understand the reason.