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. Could QTime used like this kind of timer?
Forum Updated to NodeBB v4.3 + New Features

Could QTime used like this kind of timer?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 676 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.
  • qazaq408Q Offline
    qazaq408Q Offline
    qazaq408
    wrote on last edited by
    #1

    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";
    //......
    deviceWork_Time->addSec(100);
    deviceWork_Time->addSec(3600);
    deviceWork_Time->addSec(1800);
    //......
    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"...

    JonBJ J.HilkJ 2 Replies Last reply
    0
    • qazaq408Q qazaq408

      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";
      //......
      deviceWork_Time->addSec(100);
      deviceWork_Time->addSec(3600);
      deviceWork_Time->addSec(1800);
      //......
      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"...

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

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

      qazaq408Q 1 Reply Last reply
      1
      • JonBJ JonB

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

        qazaq408Q Offline
        qazaq408Q Offline
        qazaq408
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • qazaq408Q qazaq408

          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";
          //......
          deviceWork_Time->addSec(100);
          deviceWork_Time->addSec(3600);
          deviceWork_Time->addSec(1800);
          //......
          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"...

          J.HilkJ Offline
          J.HilkJ Offline
          J.Hilk
          Moderators
          wrote on last edited by J.Hilk
          #4

          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.


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          qazaq408Q 1 Reply Last reply
          3
          • J.HilkJ J.Hilk

            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.

            qazaq408Q Offline
            qazaq408Q Offline
            qazaq408
            wrote on last edited by
            #5

            @J.Hilk
            thanks

            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