Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QDateTimeEdit bad format
Forum Update on Monday, May 27th 2025

QDateTimeEdit bad format

Scheduled Pinned Locked Moved Solved General and Desktop
qdatetimeedit
7 Posts 4 Posters 1.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    apic
    wrote on 20 Jun 2017, 08:39 last edited by
    #1

    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

    K 1 Reply Last reply 20 Jun 2017, 08:55
    0
    • A apic
      20 Jun 2017, 08:39

      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

      K Offline
      K Offline
      koahnig
      wrote on 20 Jun 2017, 08:55 last edited by
      #2

      @apic

      Are you missing out one 'y' in the format?

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      1
      • A Offline
        A Offline
        apic
        wrote on 20 Jun 2017, 08:58 last edited by
        #3

        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

        1 Reply Last reply
        0
        • V Offline
          V Offline
          VRonin
          wrote on 20 Jun 2017, 09:01 last edited by
          #4

          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();
          }
          

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          1 Reply Last reply
          3
          • P Offline
            P Offline
            Pradeep Kumar
            wrote on 20 Jun 2017, 09:10 last edited by Pradeep Kumar
            #5

            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

            Thanks,

            Pradeep Kumar
            Qt,QML Developer

            1 Reply Last reply
            0
            • A Offline
              A Offline
              apic
              wrote on 21 Jun 2017, 13:01 last edited by
              #6

              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

              1 Reply Last reply
              1
              • P Offline
                P Offline
                Pradeep Kumar
                wrote on 21 Jun 2017, 13:02 last edited by
                #7

                @apic

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

                Thanks,

                Pradeep Kumar
                Qt,QML Developer

                1 Reply Last reply
                0

                5/7

                20 Jun 2017, 09:10

                • Login

                • Login or register to search.
                5 out of 7
                • First post
                  5/7
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved