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

  • @apic

    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>
    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"));
        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:mm


  • 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

  • @apic

    is ur issue solved.
    if so can u mark it as solved in that case.


Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.