简体   繁体   中英

QTime Buffer Overflow?

I am writing a program that asks the user for a large number of seconds and waits that many seconds. The issue is that as soon as waitSecs is larger 9999 seconds, launchTime seems to become a random number. I've outputted waitSecs using qDebug and it is the correct number (even when the number is larger than 9999). Any help?

QTime launchTime = QTime::currentTime().addSecs(waitSecs);

Here is the code + output:

在此处输入图片说明

From Qt documentation http://qt-project.org/doc/qt-4.8/qtime.html#addSecs :

QTime QTime::addSecs ( int s ) const

Returns a QTime object containing a time s seconds later than the time of this object (or earlier if s is negative).

Note that the time will wrap if it passes midnight.

Consider using QDateTime instead...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM