QDateTime with invalid QTime
-
Hi,
With Qt4 I was using QDateTime as a structure to store a QDate and a QTime with sometime an invalid QTime like this :
@QDateTime dt;
dt->setDate(2000,1,1);
dt->setTime(QTime());
dt->time().isValid() // == false@In Qt5 this code does not behave the same and always force the time part of the QDateTime to 00:00:00
@QDateTime dt;
dt->setDate(2000,1,1);
dt->setTime(QTime());
dt->time().isValid() // == true@Is this behavior a regression ? or the QDateTime is not meant to be used like this ?
-
It is otherway round. They have corrected the issue which was existing Qt 4.x.
Both 4.x and 5.x documentation says time is invalid if you create QTime() with no arg constructor. i.e isValid() is supposed to return false and which is logical also.
-
Hi,
Which version of Qt are you using ? With the latest 5 and 4 I have the same correct result.
-
Hi,
I am using Qt 5.2.1 and Qt 4.8.4
What is the correct result ?
-
According to me 5.2.1 is correct behaviour.
-
Currently running the latest 5.3 and 4.8.6 and getting false in both case, which is correct since you are setting an invalid QTime.
Since your code snippet contains code that can't be compiled, are you sure you are not doing something funky in your original work ?