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. C++ How to add 1 more day to QDateTimeEdit?
Forum Updated to NodeBB v4.3 + New Features

C++ How to add 1 more day to QDateTimeEdit?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 322 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.
  • T Offline
    T Offline
    TheCeylann
    wrote on last edited by
    #1

    I can print the current time in QDateTimeEdit.

    In addition, I want to add1 day more than the current time in the other QDateTime edit part, how can I do that?

    here is my code.

    ui->datetmestartedit->setDateTime(QDateTime::currentDateTime()); //example 26/11/2022 18:45:00
    
    ui->datetimeEndedit->setDateTime(QDateTime::currentDateTime()); //example 27/11/2022 18:45:00  here  I want add +1 day to current date time 
    

    how can I do that?

    Christian EhrlicherC 1 Reply Last reply
    0
    • T TheCeylann

      I can print the current time in QDateTimeEdit.

      In addition, I want to add1 day more than the current time in the other QDateTime edit part, how can I do that?

      here is my code.

      ui->datetmestartedit->setDateTime(QDateTime::currentDateTime()); //example 26/11/2022 18:45:00
      
      ui->datetimeEndedit->setDateTime(QDateTime::currentDateTime()); //example 27/11/2022 18:45:00  here  I want add +1 day to current date time 
      

      how can I do that?

      Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @TheCeylann said in C++ How to add 1 more day to QDateTimeEdit?:

      how can I do that?

      By simply looking into the documentation: https://doc.qt.io/qt-6/qdatetime.html#addDays

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      T 1 Reply Last reply
      2
      • Christian EhrlicherC Christian Ehrlicher

        @TheCeylann said in C++ How to add 1 more day to QDateTimeEdit?:

        how can I do that?

        By simply looking into the documentation: https://doc.qt.io/qt-6/qdatetime.html#addDays

        T Offline
        T Offline
        TheCeylann
        wrote on last edited by
        #3

        @Christian-Ehrlicher Thank you for answer.

        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