PDA

View Full Version : Start application when OS starts



sophister
4th May 2009, 06:26
Hi, does QT provide a way to modify the Registry, and so that the application can start ifself then the OS starts.
Thanks in advance!
I'm using MS-XP.

spirit
4th May 2009, 06:35
you have to add you application in registry, like this


...
QSettings settings("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\ CurrentVersion\\Run", QSettings::NativeFormat);
settings.setValue("myApp", qApp->applicationFilePath());
...

sophister
4th May 2009, 06:41
you mean add this in constructor or destructor?? And if I have added it to the registry, how can user delete it from registry if they don't want the application to start automatically??
Thanks

spirit
4th May 2009, 06:43
you mean add this in constructor or destructor??

yes


And if I have added it to the registry, how can user delete it from registry if they don't want the application to start automatically??
Thanks

just add this functionality in your app :)
take a look at QSettings::remove, read about QSettings.

sophister
4th May 2009, 07:35
I have added it into the registry, but I have another problem, in the registry, other softwares' paths are using '\', while my application's path uses '/'. I wonder if the OS can recognize the path and run my application when it starts??

spirit
4th May 2009, 08:23
have a look at QDir::toNativeSeparators function.

sophister
4th May 2009, 08:23
I have solved it:
I use the QString::replace to replace all the "/" in the file path into with "\", so it is converted into the correct file path under Window.

zizoumgs
10th December 2009, 21:18
sorry for bad english..
my OS ubuntu , how to restart application in ubuntu?

squidge
10th December 2009, 22:47
Putting it in your profile is one way

tablebubble
11th April 2011, 17:33
Hello!
How can I do this in Linux OS running KDE4.0?
Please, I urgently needs a sample code(on that segment).
Thanks in advance.

squidge
11th April 2011, 17:58
Put the program into the Autostart folder and KDE will launch it once KDE is up and running.

tablebubble
12th April 2011, 15:23
Yes, am aware of that, but i need i way to do that in my code, I dont want to put the entire application in the ./kde4/Autostart/; I need user option like "Start when window start". Please help is needed urgently.
Thanks in Advance.

wysota
12th April 2011, 15:36
Place an appropriate .desktop file in the Autostart directory.

tablebubble
12th April 2011, 16:08
please, can i get a sample of what the .desktop file should contain, the ones on my system(Qt.desktop) dont do autostart.
Please help.
Thanks in Advance.

squidge
12th April 2011, 19:44
You would be better asking on a KDE forum rather than a Qt forum

wysota
12th April 2011, 20:13
http://standards.freedesktop.org/desktop-entry-spec/latest/

tablebubble
13th April 2011, 06:38
Thanks,
am working on that.