Unsolved Qt equivalent of timeGetTime()
-
Is there in the QT libraries an equivalent of the
timeGetTime()
function of theWindows.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 inDWORD
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 returns0
Can you help me?
Thanks in advance
-
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.
-
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 likeqint64
or standard ones likeint64_t
.