Results 1 to 17 of 17

Thread: Start application when OS starts

  1. #1
    Join Date
    Apr 2009
    Location
    China
    Posts
    127
    Thanks
    30
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Start application when OS starts

    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.

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Start application when OS starts

    you have to add you application in registry, like this
    Qt Code:
    1. ...
    2. QSettings settings("HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion\\Run", QSettings::NativeFormat);
    3. settings.setValue("myApp", qApp->applicationFilePath());
    4. ...
    To copy to clipboard, switch view to plain text mode 
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Apr 2009
    Location
    China
    Posts
    127
    Thanks
    30
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Start application when OS starts

    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

  4. #4
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Start application when OS starts

    Quote Originally Posted by sophister View Post
    you mean add this in constructor or destructor??
    yes
    Quote Originally Posted by sophister View Post
    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.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  5. #5
    Join Date
    Apr 2009
    Location
    China
    Posts
    127
    Thanks
    30
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Start application when OS starts

    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??

  6. #6
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Start application when OS starts

    have a look at QDir::toNativeSeparators function.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  7. #7
    Join Date
    Apr 2009
    Location
    China
    Posts
    127
    Thanks
    30
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Start application when OS starts

    I have solved it:
    I use the QString::replaceto replace all the "/" in the file path into with "\", so it is converted into the correct file path under Window.

  8. #8
    Join Date
    Apr 2009
    Location
    Indonesia
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Start application when OS starts

    sorry for bad english..
    my OS ubuntu , how to restart application in ubuntu?

  9. #9
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Start application when OS starts

    Putting it in your profile is one way

  10. #10
    Join Date
    Jul 2010
    Location
    Lagos, Nigeria
    Posts
    7
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Start application when OS starts

    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.

  11. #11
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Start application when OS starts

    Put the program into the Autostart folder and KDE will launch it once KDE is up and running.

  12. #12
    Join Date
    Jul 2010
    Location
    Lagos, Nigeria
    Posts
    7
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Start application when OS starts

    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.
    Last edited by tablebubble; 12th April 2011 at 16:28.

  13. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Start application when OS starts

    Place an appropriate .desktop file in the Autostart directory.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  14. #14
    Join Date
    Jul 2010
    Location
    Lagos, Nigeria
    Posts
    7
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Start application when OS starts

    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.
    Last edited by tablebubble; 12th April 2011 at 17:17.

  15. #15
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Start application when OS starts

    You would be better asking on a KDE forum rather than a Qt forum

  16. #16
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Start application when OS starts

    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  17. The following user says thank you to wysota for this useful post:

    tablebubble (13th April 2011)

  18. #17
    Join Date
    Jul 2010
    Location
    Lagos, Nigeria
    Posts
    7
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Start application when OS starts

    Thanks,
    am working on that.

Similar Threads

  1. Start Qt application as Windows Service
    By ^NyAw^ in forum Qt Programming
    Replies: 12
    Last Post: 10th May 2008, 18:23
  2. Selecting screen on the application starts
    By ^NyAw^ in forum Qt Programming
    Replies: 6
    Last Post: 12th March 2008, 00:20
  3. Replies: 10
    Last Post: 10th March 2008, 13:28
  4. start application: Why this error and how to solve it?
    By Colx007 in forum Qt Programming
    Replies: 1
    Last Post: 21st January 2008, 16:22
  5. Replies: 2
    Last Post: 20th November 2007, 21:00

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.