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

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 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
    0
    • A apic

      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 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 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
        • VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on 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
          • Pradeep KumarP Offline
            Pradeep KumarP Offline
            Pradeep Kumar
            wrote on 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 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
              • Pradeep KumarP Offline
                Pradeep KumarP Offline
                Pradeep Kumar
                wrote on 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

                • Login

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