Unsolved How to do something at some specified time
-
Hi i want do something at at some specified date & time like 2/15/2017 10:30:00 & 2/15/2017 11:30:00
I want call a function at this times -
Hi,
If you're on Linux then use a cron job to call your application/script/whatever you need.
-
@SGaist I want use cross platform way
-
like 2/15/2017 10:30:00
int msecTo(const QDateTime& fromdt,const QDateTime& todt){ return fromdt.time().mSecTo(todt.time())+( fromdt.date().daysTo(todt.date())*24*60*60*1000 ); } const QDateTime target(QDate(2017,2,15),QTime(10,30,0)); QTimer::singleShot(msecTo(QDateTime::currentDateTime(),target),[]()->void{qDebug("2/15/2017 10:30:00 and all's well!");});
-
Just keep in mind that with the solution of @VRonin you have to ensure that your application has to be running at the time you want your function to be executed.
-
@VRonin How about multi date & time? the count of date & time is dynamic
so i don't know how many event user enter to my app
Can i use only one QTimer? or i have to create a QTimer for each events ?