开发者

How to print invalid QTime?

开发者 https://www.devze.com 2023-02-01 02:10 出处:网络
I want to do something like this QTime time (25,0,0); qDebug() << time.toString(); But that wi开发者_StackOverflow中文版ll be invalid QTime and outputs \"\"

I want to do something like this

QTime time (25,0,0);
qDebug() << time.toString();

But that wi开发者_StackOverflow中文版ll be invalid QTime and outputs ""

Can it be done in some way other then converting QTime to seconds, seconds to string?


QTime is time of day, and thus 25:0:0 is invalid. What you seem to want is not time-of-day, but a duration. Qt doesn't ship a QDuration class. It's quite simple though to roll your own (durations are much simpler than dates and times, no timezones etc.).

0

精彩评论

暂无评论...
验证码 换一张
取 消