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. Qt equivalent of timeGetTime()
Forum Updated to NodeBB v4.3 + New Features

Qt equivalent of timeGetTime()

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 444 Views 2 Watching
  • 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.
  • UnitScanU Offline
    UnitScanU Offline
    UnitScan
    wrote on last edited by UnitScan
    #1

    Is there in the QT libraries an equivalent of the timeGetTime() function of the Windows.h header? I wish my code was as platform-independent as possible. I know the <chrono> header exists, but I would like something that returns the value in DWORD

    QWORD lastpos;
    DWORD lasttime;
    ...
    float AudioThread::br()
    {
        QTime tmp(0,0,0);
        DWORD time = tmp.msecsSinceStartOfDay();
        QWORD pos = BASS_StreamGetFilePosition(chan, BASS_FILEPOS_CURRENT);
            if (pos != lastpos) {
              lasttime = time;
              lastpos = pos;
            }
        }
        qDebug() << tmp.msecsSinceStartOfDay();
        return 8.0 * (pos - lastpos) / (time - lasttime);
    }
    

    Calling this function into a QTimer, tmp.msecsSinceStartOfDay() always returns 0

    Can you help me?

    Thanks in advance

    1 Reply Last reply
    -1
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      You are asking for contradictory things. You want a cross-platform solution yet you want the return type to be system specific. So either use the API provided by that platform or do the conversion to DWORD in your code for that platform.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      4
      • Chris KawaC Online
        Chris KawaC Online
        Chris Kawa
        Lifetime Qt Champion
        wrote on last edited by
        #3

        For measuring how much time passed use QElapsedTimer. As SGaist said DWORD is not platform-independent and it can be a little small for holding milliseconds so if you don't want a dedicated standard chrono types stick to either Qt's types like qint64 or standard ones like int64_t.

        1 Reply Last reply
        4

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved