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. [SOLVED] QDate QDate::addDays ( int ndays ) works....?
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] QDate QDate::addDays ( int ndays ) works....?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 8.3k Views 1 Watching
  • 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.
  • P Offline
    P Offline
    prabuqt
    wrote on last edited by
    #1

    Hi Everyone, I want to add 15 days to the current date. For that I wrote the code like this,

    @ QDate IssueDate, ReturnDate;
    QString IsDt= IssueDate.currentDate().toString(Qt::ISODate);
    ReturnDate = IssueDate.addDays(15);
    QString RtDt= ReturnDate.toString(Qt::ISODate);@

    But it is giving NULL. Can anyone tell me where is the problem...?

    Thank You.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      AcerExtensa
      wrote on last edited by
      #2

      because your dates are not initialized. Using static function on uninitialized object does not updates this object...

      @
      QDate issueDate = QDate::currentDate();
      QDate ReturnDate;
      QString IsDt= IssueDate.toString(Qt::ISODate);

      ReturnDate = IssueDate.addDays(15);
      QString RtDt= ReturnDate.toString(Qt::ISODate);
      @

      If it solves your problem, please add "[SOLVED]" prefix left to the topic subject. Thanks!

      God is Real unless explicitly declared as Integer.

      1 Reply Last reply
      1
      • P Offline
        P Offline
        prabuqt
        wrote on last edited by
        #3

        Thank you AcerExtensa. I got it.

        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