(SOLVED)How To Change Date and Time in linux system based from Qt Based Application
I am trying to to change date and time of system from qt application but there is no effect from QDate and QTime class ;
when I am access currentDate() and currentTime() it access system time.
QDate and QTime are not used to change any system settings. They are just data formats to hold information about date and time.
What you need is a OS specific feature. For Windows it's a "SetLocalTime":http://msdn.microsoft.com/en-us/library/ms724936.aspx API. On Linux there's a "date":http://linux.die.net/man/1/date command which you can call with "QProcess":http://qt-project.org/doc/qt-5.1/qtcore/qprocess.html .
You might of course need to run your app with enough access privileges to be able to do that.
welcome to devnet
The static methods "currentDate":http://qt-project.org/doc/qt-5.0/qtcore/qdate.html#currentDate and "currentTime":http://qt-project.org/doc/qt-5.0/qtcore/qtime.html#currentTime read only
You may use "setDate":http://qt-project.org/doc/qt-5.0/qtcore/qdate.html#setDate and "setTime":http://qt-project.org/doc/qt-5.0/qtcore/qtime.html#setHMS but AFAIK those will not change the system clock permanently either.
I am using Linux environment Based device. Using @ setDate @ and @ setTime @ also I am i am not able to set my clock when I use @ currentTime @ and current date it is the system time not that what i have set through @ setTime and setDate @
If it can be done with Qprocess pls tell me how
Did I can make a object for the same to access or there is specific commands to set and read current time as per we have set.
i have gone through the link as per mentioned on http://www.qtcentre.org/archive/index.php/t-44384.html
but i want to access through program Qt application
As Chris confirmed it is not possible through Qt directly.
When using QProcess you basically use a standard command, a linux command in your case, to change the system clock. Like you would do on a terminal prompt. However, you will have to have the superuser rights.
With QProcess you can basically launch any command and application available on a system.
In addition to the links already provided, you may also check out the "QProcess documentation.":http://qt-project.org/doc/qt-5.0/qtcore/qprocess.html
If there is ubuntu system header and source file (API downloadable), this is still achievable. Right?
The question is where to get the header and source file.
Is there a method to input sudo password rather than wait for interactive command. is setuid, seteuid, setgid able to do the job.
Hello Frnds ,
Thanks for your replies ;
I am able to change the date and time as well :--) Yes thanks to koahhning for refering QProcess documentation it really helped ;
QProcess allow to access command line or terminal to change the Date and Time In my case the Embedded device I am working on having kernal 3.2 and from command line I can able to change the date and time ;
- System Clock;
- Hardware Clock;
it does require sudo command;
- System Clock;
I found command chmod u+s hello will give the app root access.