Important: Please read the Qt Code of Conduct -

Could QTime used like this kind of timer?

  • There are some device that need record they working time .So I need QTime to record the time.

    const QString TIME_FORMAT = "hh:mm:ss";
    qDebug()<<"Work Time:"<<deviceWok_Time.toString(TIME_FORMAT);  

    The programme will tell user "Work Time:1:31:40";
    In fact,the device will work continue for a few days , so I hope QTime can show like
    "Work Time: 121:20:40"
    Now user can know the device had work 121hours and 20 minutes and 40 second.But if the time more than 24 hours,the QTme will show the time is "0:00:00"...

  • @qazaq408
    No, QTime only uses a "24-hour clock time". It will not return a number of elapsed hours greater than 24.

  • @JonB
    Do you have some better idea that's can recod this format time?

  • Moderators

    hi @qazaq408

    IIRC QTime only works for 0 to 86399, aka 23h 59m and 59 sec
    you can call start() on a QTime object and it will start counting the seconds, (starting with 00:00:00)

    to recorde more than 24 hours, you'll have to use a QDateTime object, or monitor it yourself.

  • @J.Hilk

Log in to reply