Representing more than 24 hours in Qt
-
Hi all,
This is my first post to the new Qt forum! It's been a long time that I worked with Qt, good that I have chance to pick it up again :) (btw Qt Creator is awesome!)
Anyway, I am writing an application that needs to manipulate time that possibly more than 24 hours (say a duration of a sound clip could be 1 day, 15 hours and 14 mins), AFAIK QTime can only support up to 24 hours (as it means time of day), and QDateTime is representing the actual calendar date and cannot be used for this purpose.
I can't find anywhere in the API document that this could be achieved at the moment. Is it possible in Qt, other than writing my own classes to do something like:
QDateTime +/- "duration"
2010-11-01 00:00:00 + "12:00:00" = 2010-11-01 12:00:00Thanks!
-
Q(Date)Time is a point in time, not a duration. So I would keep them separated and write a class Duration, with convenience methods converting to hh:mm:ss, total number of seconds, operator+, etc. Should be rather straightforward, as it's much simpler than points in time (which have to handle calendars, timezones, etc.).
-
Could you use some timer of Qt? "http://doc.qt.nokia.com/latest/qtimer.html":http://doc.qt.nokia.com/latest/qtimer.html
@QTimer::singleShot(length_in_milliseconds, this, SLOT(trackEnded())@
Though if you seriously need to represent some arbitrary length of time, and not really time it, writing own class for it would be best way out.
-
[quote author="Smar" date="1288698360"]Could you use some timer of Qt? http://doc.qt.nokia.com/latest/qtimer.html
@QTimer::singleShot(length_in_milliseconds, this, SLOT(trackEnded())@
Though if you seriously need to represent some arbitrary length of time, and not really time it, writing own class for it would be best way out.[/quote]
I think the original intention is to represent the duration, but not measure it.