0

I am having a little problem with entering the date. The date should be entered in the format DD.MM.YYYY (e.g. 03.06.2021)

When I want to enter 31.05.2021 I have to jump to the month first, enter there 05 and then I can enter 31. June got 30 days and so I cannnot enter 31 initially. Any idea how to delay the date check until the field is left?

        self.f1 = QDateTimeEdit(QDate.currentDate())
        self.f1.setDisplayFormat("dd.MM.yyyy")
        self.f1.setFixedWidth(85)
        self.f1.setMinimumDate(QDate.fromString("01.01.2020", "dd.MM.yyyy"))
        self.f1.setMaximumDate(QDate(QDate.currentDate()))

Andy
  • 5
  • 1
  • Starting from a date in June, you actually ***can*** enter 31 initially - but it will of course display 30. However, when you enter 5 in the month field, the day will automatically jump forward to 31. Note that this *doesn't* happen if you type 30 in first. So the widget is seemingly smart enough to "know" what your intentions are. – ekhumoro Jun 04 '21 at 19:33
  • My widget is not that smart. As soon as I enter the 1 of 31, the 1 goes into the month field. The cursor jumped in that field automatically. If there would be a solution to prevent the auto jump, it would solve the problem. – Andy Jun 05 '21 at 05:38
  • I used the same widget as you and it works fine for me. – ekhumoro Jun 05 '21 at 18:12

0 Answers0