Constructs a null time object. A null time can be a QTime(0, 0, 0, 0) (i.e., midnight) object, except that isNull() returns true and isValid() returns false.
Adding seconds to an invalid time leaves it as invalid - after all, it's an invalid time point, not midnight as you seem to expect. It's pretty much a NaN-type behavior.
A newly default-constructed
QTime
object starts in an invalid state.Adding seconds to an invalid time leaves it as invalid - after all, it's an invalid time point, not midnight as you seem to expect. It's pretty much a NaN-type behavior.
To create a
QTime
in a valid state you can either use the other constructorso a midnight-initialized
QTime
would beQTime(0, 0)
; OP code should thus be adjusted like this:You can also use several other helper static methods, depending on how you need to initialize it.