Results 1 to 13 of 13

Thread: Start Qt application as Windows Service

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Start Qt application as Windows Service

    Hi,

    The application try to read a config file but removing all this code and only setuping the gui with "ui.setupUi(this);" don't work.

    I have added a little code on main.cpp that writes "Hello" on a file. It works executing it but not starting by the service.

    Thanks,
    Òscar Llarch i Galán

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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 Qt application as Windows Service

    Try compiling and running a non-Qt app like this one:

    Qt Code:
    1. int main(){
    2. while(1);
    3. return 0;
    4. }
    To copy to clipboard, switch view to plain text mode 

    If it works, try adding a QCoreApplication and then a QApplication. Observe what happens in each.

  3. #3
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Start Qt application as Windows Service

    Hi,

    I compiled the simple application and it starts.
    Then I created a simple Qt console application that uses QCoreApplication and it is not started by the service.

    Thanks,
    Òscar Llarch i Galán

  4. #4
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Start Qt application as Windows Service

    Hi,

    I copied the Qt libs on the application dir and the QCoreApplication starts.
    Then I tryied to create a QApplication and it starts.
    Finally tryied my application and starts.
    So, I think that when start the application by a Windows Service, the libs must be on the "system32" dir or on the same dir of the application.

    Thanks wysota,
    Òscar Llarch i Galán

  5. #5
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Start Qt application as Windows Service

    Hi,

    The QTDIR path is set as User variable on Windows, so if the service is started as "LocalSystem" it don't have QTDIR path so when try to start my application don't work.

    So one solution could be to set the QTDIR on the Path of the system instead of the path of the current user.
    Second solution is to copy the Qt libs into the "system32" folder where are the system libs.
    Third solution is to copy the Qt libs on the application directory.

    Òscar Llarch i Galán

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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 Qt application as Windows Service

    As I said - a path problem. Your libs must be accessible, regardless of system configuration. The only safe place to put them is system32 directory.

  7. #7
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Start Qt application as Windows Service

    Hi,

    Thanks for help,
    Òscar Llarch i Galán

Similar Threads

  1. QSkinWindows Classes
    By kernel_panic in forum Qt-based Software
    Replies: 45
    Last Post: 20th April 2010, 12:35
  2. 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
  3. Porting Qt embedded application to windows.
    By vipin in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 14th January 2008, 16:08
  4. Replies: 2
    Last Post: 9th June 2007, 19:19
  5. Application plugin on windows
    By Eyee in forum Qt Programming
    Replies: 2
    Last Post: 22nd March 2006, 17:36

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.