Results 1 to 3 of 3

Thread: How do i get the number of hours

  1. #1
    Join Date
    Jul 2012
    Posts
    201
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    26
    Thanked 1 Time in 1 Post

    Default How do i get the number of hours

    I have two QTimeEdit objects and i want to calculate the number of hours between QTimeEdit1 and QTimeEdit2. How can i hdo that?

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    3
    Thanked 453 Times in 435 Posts
    Wiki edits
    15

    Default Re: How do i get the number of hours

    Qt Code:
    1. QTimeEdit *timeEdit1;
    2. QTimeEdit *timeEdit2;
    3.  
    4. QTime time1 = timeEdit1->time();
    5. QTime time2 = timeEdit2->time();
    6.  
    7. int hours = time2.secsTo(time1) / 60 / 60;
    8. // -24 < hours < 24
    To copy to clipboard, switch view to plain text mode 
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

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

    Default Re: How do i get the number of hours

    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.


Similar Threads

  1. lcd number set value
    By hezbon in forum Newbie
    Replies: 5
    Last Post: 18th July 2012, 09:58
  2. Replies: 1
    Last Post: 5th March 2012, 06:34
  3. Number PI
    By digog in forum Newbie
    Replies: 5
    Last Post: 25th April 2011, 01:50
  4. Replies: 6
    Last Post: 13th March 2011, 23:49
  5. Date and hours
    By kjiu in forum Qt Programming
    Replies: 9
    Last Post: 13th November 2009, 18:27

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
  •  
Qt is a trademark of The Qt Company.