PDA

View Full Version : date-time problem



aegis
11th February 2007, 17:34
hello to everyone,

i have the followign problem:

i need to get the system date-time {i think it is done like this--> QDate myDate(QDate::currentDate())} and then i

need a way to add minutes(!!) to this variable....

in particular i want to make a program{actually part of a another program} that will print on a label dates&times.

The problem is that i must print the date-time every hour.But also simulate an hour with 1 minute{i believe that i can do so with the Sleep() function}...

so a possible output could be:
Wed Feb 11 2007 22:09
Wed Feb 11 2007 23:09
Wed Feb 11 2007 00:09
Wed Feb 12 2007 01:09
....
....

thanks for your help

PS:: sorry for my english...

jpn
11th February 2007, 17:39
Is that a GUI application? You don't want to sleep() in a GUI application because that would freeze the whole application by blocking the applications event loop. You can use QTimer to perform periodic tasks.

aegis
11th February 2007, 17:48
Is that a GUI application? You don't want to sleep() in a GUI application because that would freeze the whole application by blocking the applications event loop. You can use QTimer to perform periodic tasks.
i forgot to say that i am rather new to gui designs...yes it is for gui application.In theory at least i am thinking of a button that when pressed the whole application would stop until the dates are outputed to a file or label....but the problem isn't there.

The problem is that i dont know what type to use to represent date and time so that i can have the ability to add minutes to an original time....

jpn
11th February 2007, 17:57
The problem is that i dont know what type to use to represent date and time so that i can have the ability to add minutes to an original time....
Take a look at QDateTime. It represents both date and time. It's basically a combination of QDate and QTime.



QDateTime dateTime = QDateTime::currentDateTime(); // get current date and time
dateTime.addSecs(60); // add minute
QString str = dateTime.toString(); // the date time as a textual representation

aegis
11th February 2007, 18:38
thanks jpn...now i am using the qt opensource edition is it possible to create an application that will use Qt4 but it wont require the client to install the library?

jpn
11th February 2007, 18:45
The subject has been discussed in here: Deploying Qt Applications (http://doc.trolltech.com/4.2/deployment.html).