Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QDateTimeEdit bad format
-
Hello, i have a simple QDateTimeEdit with format yyyy/MM/dd hh:mm
when i call dateTimeEdit->setDate(QDate::currentDate());
i see 17y/06/20, why year is badly formatted?
Thank you
-
Are you missing out one 'y' in the format?
-
Hello koahning, this is format from .ui
<property name="displayFormat">
<string>yyyy/MM/dd hh:mm</string>
</property>
Also in designer preview this is shown correct
-
Works for me...
#include <QDateTimeEdit> int main(int argc, char *argv[]) { QApplication app(argc,argv); QDateTimeEdit w; w.setDisplayFormat(QStringLiteral("yyyy/MM/dd hh:mm")); w.setDate(QDate::currentDate()); w.show(); return app.exec(); }
-
Hi,
@VRonin posted the sample code, which is working . as expected.
can u post ur @apic code,If u want complete year, u can go with format : yyyy/MM/dd hh:mm
or if u want two digits u can go with format : yy/MM/dd hh:mmThanks,
-
This was a stupid issue, i realized just now that format string was translated with wrong translation.
there was a missing "y".
thank you all
-