Results 1 to 3 of 3

Thread: System Current time

  1. #1
    Join Date
    Oct 2014
    Posts
    71
    Thanks
    13
    Qt products
    Qt5
    Platforms
    Windows

    Default System Current time

    Hello

    In my code I have to get system time and then add second to it and display in gui
    suppose I got system_time = 10:30:40
    second (from my code)= 40
    display = system_time+second;i.e 10:31:20
    I have added a code
    Qt Code:
    1. unsigned int Time_second_ecu2uss;
    2. QTime time = QTime::currentTime();
    3. QString timeString = time.toString();
    4. Time_second_ecu2uss = Time_ecu2uss/1000;(getting the second)
    5. qDebug()<<"timeString"<<timeString + Time_second_ecu2uss;
    To copy to clipboard, switch view to plain text mode 

    but my output is timeString "10:31:20t"

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: System Current time

    You are appending an integer to a string, that doesn't change the string.
    If you want to add seconds to a time object, use QTime::addSecs().

    Cheers,
    _

  3. #3
    Join Date
    Oct 2014
    Posts
    71
    Thanks
    13
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: System Current time

    Thanks for information

Similar Threads

  1. detect current system
    By timmu in forum Qt Programming
    Replies: 2
    Last Post: 13th August 2012, 08:38
  2. how to get the current system time ?
    By Petr_Kropotkin in forum General Programming
    Replies: 4
    Last Post: 10th February 2010, 19:21
  3. Current Time in msec accuracy in Qt for WinCE
    By funghy in forum Qt Programming
    Replies: 4
    Last Post: 22nd June 2009, 11:00
  4. How to display My Current System IP Address...???
    By maveric in forum Qt Programming
    Replies: 8
    Last Post: 4th August 2008, 18:22
  5. Current Time with microsecond precision on windows
    By Dwarf007 in forum General Programming
    Replies: 16
    Last Post: 5th April 2006, 12:42

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.