Results 1 to 3 of 3

Thread: Adding 2 Dates

  1. #1
    Join Date
    Jan 2009
    Posts
    6
    Thanks
    1

    Default Adding 2 Dates

    Holla, is there an easy way to add 2 QTimes? Example I have a startTime and a travelTime. I manually set the start and travel times. What I need to do is dif(startTime, travelTime) and then add this returned time to the startTime. I know in .net its just one line....dateTime.addDateTime(dateTime) pretty simple. Any help would be greatly appreciated.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Adding 2 Dates

    QTime is probably not the best class to do it as it doesn't support wrapping but here goes:
    Qt Code:
    1. QTime startTime = ..., travelTime = ...;
    2. startTime.addMSecs(travelTime.msec());
    To copy to clipboard, switch view to plain text mode 
    One line here as well...
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    bwindorski (3rd December 2009)

  4. #3
    Join Date
    Sep 2009
    Location
    Tashkent, Uzbekistan
    Posts
    107
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Adding 2 Dates

    I used qPair to solve the same problem. Something like qMakePair(startTime, endTime) where startTime is either QDateTime or QTime

Similar Threads

  1. Replies: 5
    Last Post: 17th February 2009, 05:35
  2. Adding QGraphicsProxyWidget items into QGraphicsScene
    By yagabey in forum Qt Programming
    Replies: 3
    Last Post: 21st November 2008, 07:33
  3. Adding JavaScript Obj to QWebView issues
    By bpetty in forum Newbie
    Replies: 2
    Last Post: 13th May 2008, 21:44
  4. Replies: 0
    Last Post: 7th April 2008, 15:27
  5. Adding buttons on the tab part of a tabwidget
    By forrestfsu in forum Qt Programming
    Replies: 2
    Last Post: 20th December 2006, 18:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.