QTime time(15, 30, 0); // create a time with hour 15, minute 30 and second 0 if (time.isValid()) { // do something if the time is valid }
QTime time(25, 0, 0); // create an invalid time with hour 25, minute 0 and second 0 if (!time.isValid()) { // do something if the time is not valid }In this example, the time is invalid because it exceeds the range of a 24-hour clock format. Package/library: Qt, specifically the QtCore package.