Important: Please read the Qt Code of Conduct -

QtService -or- how to run QCoreApplication as a service?

  • Hello,

    my console application should be run as a service. The executable is registered as a service by the WiX Toolset which works fine. When starting the service, I get an error that it took too long to start. This is expected behaviour but how do I implement this right in Qt 5.2.1?

    For 4.x there was "QtService"which is now part of Qt-Solutions.

  • I thought Qt-Solutions is just for 4.x but it also works with Qt 5.2.1.
    I successfully made my app start via service. I am not sure if it works right but the service started successfully.

    For all who are looking for the same:


    Unpack the archive. Copy the qtservice dir under a folder named libs (for example) inside the own project.

    Add this line to .pro:

    Create a new "Service" Class. I named mine "AgentService".
    @#ifndef AGENTSERVICE_H
    #define AGENTSERVICE_H

    #include <QApplication>
    #include <qtservice.h>

    class AgentService : public QtService<QApplication>
    AgentService(int argc, char **argv);

    void start();
    void stop();
    void pause();
    void resume();
    void processCommand(int code);

    #endif // AGENTSERVICE_H

    After this, follow the docs inside the lib examples:

    Maybe helpful when experimenting:

  • how you connect your app with qt service?

Log in to reply