2

I am working on UI design which I am designing in qt desginer. In qt designer, there is a widget QDateTimeEdit through which we can select the date and time. I have added it and it looks like below:

enter image description here

I have added two widgets from start and end date time. I have also added calendar popup so for date, I can select using calendar. For time, I can adjust it by typing time on keyboard.

By default it comes with AM PM. Is there any way we can change this to 24hr clock format. ?

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
S Andrew
  • 5,592
  • 27
  • 115
  • 237

1 Answers1

3

You have to set the format of the QDateTimeEdit in the displayFormat property:

enter image description here

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
  • I noticed that if I remove `AP` from the display format, it then starts to accept time in 24hr format. Is that correct.? What does AP means.? AM/PM.? – S Andrew Sep 21 '20 at 04:20
  • @SAndrew Exactly, the time format is based on QTime: https://doc.qt.io/qt-5/qtime.html#toString, and the date format on QDateTime: https://doc.qt.io/qt-5/qdatetime.html#toString. Read the docs: https://doc.qt.io/qt-5/qdatetimeedit.html#displayFormat-prop – eyllanesc Sep 21 '20 at 04:22