Results 1 to 17 of 17

Thread: Start application when OS starts

Hybrid View

Previous Post Previous Post   Next Post Next Post
  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 15:28.

Similar Threads

  1. Start Qt application as Windows Service
    By ^NyAw^ in forum Qt Programming
    Replies: 12
    Last Post: 10th May 2008, 17:23
  2. Selecting screen on the application starts
    By ^NyAw^ in forum Qt Programming
    Replies: 6
    Last Post: 11th March 2008, 23:20
  3. Replies: 10
    Last Post: 10th March 2008, 12: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, 15:22
  5. Replies: 2
    Last Post: 20th November 2007, 20: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.