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, exceptisnull()
returnstrue
,isvalid()
returnsfalse
.
http://doc.qt.io/qt-5/qtime.html#addsecs
returns null time if time invalid.
Comments
Post a Comment