c++ - QTime add seconds to new object -


i using qt5.51. why t1 invalid?:

qtime t1 = qtime().addsecs(122); qdebug() << t1.isvalid() << t1.tostring("hh:mm:ss"); 

i expected "00:02:02" , false "".

a newly default-constructed qtime object starts in invalid state. adding seconds invalid time leaves invalid - after all, it's invalid time point, not midnight seem expect. it's pretty nan-type behavior.

http://doc.qt.io/qt-5/qtime.html#qtime

constructs null time object. null time can qtime(0, 0, 0, 0) (i.e., midnight) object, except isnull() returns true , isvalid() returns false.

http://doc.qt.io/qt-5/qtime.html#addsecs

returns null time if time invalid.


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -