Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt service with gui
Forum Updated to NodeBB v4.3 + New Features

Qt service with gui

Scheduled Pinned Locked Moved Unsolved General and Desktop
25 Posts 7 Posters 3.9k Views 7 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • JonBJ JonB

    @artwaw
    You can "monitor" a process from a service, but I don't see how that relates to what the OP is wanting.

    The example for anti-virus just seems to be: the non-UI part of the AV runs as a service (with privileges), the user chooses to fire up a user-process UI which happens to communicate with it. The UI process is fully user-level, nothing special about it, so far as I know. I don't think that is what the OP is asking for. But we shall see.

    artwawA Offline
    artwawA Offline
    artwaw
    wrote on last edited by
    #11

    @JonB That's essentially what I wanted to say about the design, yes. And that would be my advice on how to implement functionality - using two processes: a monitor and a user-space gui. Unless Windows allows service to span a privileged process that a user can't interfere with but that's not a knowledge I possess.

    For more information please re-read.

    Kind Regards,
    Artur

    1 Reply Last reply
    0
    • JonBJ JonB

      @franco-amato
      Not particularly, no. A lot of posters here don't, in fact probably most. And if they do they usually say so and what they came across. You asked if it is possible to show a GUI from a Windows service, and I suggested it is not, so far as I know.

      franco.amatoF Offline
      franco.amatoF Offline
      franco.amato
      wrote on last edited by
      #12

      @JonB no is not what I asked. You should re read my first post.

      JonBJ 1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #13

        Hi,

        One possible cheat is that you use a QProcess to start a new instance of your application if somebody stops it.
        From a design point of view, you can forbid your user to close the application by handling the close event yourself. A starting point might be the QSystemTrayIcon example.
        Note that this does not protect your application from getting killed but you can still handle the usual interruption signals.
        The system service + client application combo is still worth exploring as you can have the service providing the core functionality and the application being merely a front-end.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        franco.amatoF 1 Reply Last reply
        2
        • franco.amatoF franco.amato

          @JonB no is not what I asked. You should re read my first post.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #14

          @franco-amato said in Qt service with gui:

          You should re read my first post.

          I have read it many times, thanks. Best of luck showing a UI from a Windows service.

          franco.amatoF 1 Reply Last reply
          1
          • JonBJ JonB

            @franco-amato said in Qt service with gui:

            You should re read my first post.

            I have read it many times, thanks. Best of luck showing a UI from a Windows service.

            franco.amatoF Offline
            franco.amatoF Offline
            franco.amato
            wrote on last edited by
            #15

            @JonB said in Qt service with gui:

            @franco-amato said in Qt service with gui:

            You should re read my first post.

            I have read it many times, thanks. Best of luck showing a UI from a Windows service.

            If you had read it you would have seen that I stated the following: "I know that a Windows service usually doesn't have a GUI and I'm not sure it can have one". What I asked is whether the path of service is the right path or if there are other solutions to achieve my need

            JonBJ 1 Reply Last reply
            0
            • franco.amatoF franco.amato

              @JonB said in Qt service with gui:

              @franco-amato said in Qt service with gui:

              You should re read my first post.

              I have read it many times, thanks. Best of luck showing a UI from a Windows service.

              If you had read it you would have seen that I stated the following: "I know that a Windows service usually doesn't have a GUI and I'm not sure it can have one". What I asked is whether the path of service is the right path or if there are other solutions to achieve my need

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #16

              @franco-amato said in Qt service with gui:

              If you had read it

              Thanks again. It's always nice to try to help people, just what we like to hear.

              I read your post carefully, as I said. All I ever answered was that I think you will find it difficult to run a UI from a service. You asked if that was the "right path", I suggested it is not. Sorry if you didn't want to hear that. Why don't you leave me out now, thanks.

              1 Reply Last reply
              1
              • SGaistS SGaist

                Hi,

                One possible cheat is that you use a QProcess to start a new instance of your application if somebody stops it.
                From a design point of view, you can forbid your user to close the application by handling the close event yourself. A starting point might be the QSystemTrayIcon example.
                Note that this does not protect your application from getting killed but you can still handle the usual interruption signals.
                The system service + client application combo is still worth exploring as you can have the service providing the core functionality and the application being merely a front-end.

                franco.amatoF Offline
                franco.amatoF Offline
                franco.amato
                wrote on last edited by
                #17

                @SGaist Can you help with a small example regarding this "One possible cheat is that you use a QProcess to start a new instance of your application if somebody stops it." ?

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #18
                  // rest of the code
                  int result = app.exec();
                  QProcess::startDetached("your_application");
                  return result;
                  

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  franco.amatoF 1 Reply Last reply
                  0
                  • SGaistS SGaist
                    // rest of the code
                    int result = app.exec();
                    QProcess::startDetached("your_application");
                    return result;
                    
                    franco.amatoF Offline
                    franco.amatoF Offline
                    franco.amato
                    wrote on last edited by
                    #19

                    @SGaist said in Qt service with gui:

                    // rest of the code
                    int result = app.exec();
                    QProcess::startDetached("your_application");
                    return result;
                    

                    It worked but now I am not able to stop it anymore :)) and I am the admin

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #20

                      You will have to implement some checks to determine who stopped the application.

                      Note that you also need to implement graceful shutdown for when you stop/restart your machine.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      franco.amatoF 1 Reply Last reply
                      1
                      • SGaistS SGaist

                        You will have to implement some checks to determine who stopped the application.

                        Note that you also need to implement graceful shutdown for when you stop/restart your machine.

                        franco.amatoF Offline
                        franco.amatoF Offline
                        franco.amato
                        wrote on last edited by
                        #21

                        @SGaist said in Qt service with gui:

                        You will have to implement some checks to determine who stopped the application.

                        Note that you also need to implement graceful shutdown for when you stop/restart your machine.

                        It's not clear what you mean with graceful shutdown. Can you give an example please?

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #22

                          Simply when you want to shutdown or reboot the machine for example when applying security fixes, kernel update, system updates, etc.

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          0
                          • S Offline
                            S Offline
                            Sikander Rafiq
                            wrote on last edited by
                            #23

                            @franco.amato Will you be able to make QT service with GUI or launch QT app with GUI from Qt service?

                            1 Reply Last reply
                            0
                            • franco.amatoF Offline
                              franco.amatoF Offline
                              franco.amato
                              wrote on last edited by
                              #24

                              Yes I am

                              1 Reply Last reply
                              0
                              • mrdebugM Offline
                                mrdebugM Offline
                                mrdebug
                                wrote on last edited by
                                #25

                                If you want to prevent that a user to close you app you shoud:

                                • implement the closeEvent() event to reply "no".
                                • work with machine criteria to disable task manager etc to normal users.

                                Hi, if you want to try to use your app (with gui) as windows service you can use this.
                                https://www.denisgottardello.it/InstallAsService/index.php
                                The gui will not be visible.

                                Need programmers to hire?
                                www.labcsp.com
                                www.denisgottardello.it
                                GMT+1
                                Skype: mrdebug

                                1 Reply Last reply
                                0

                                • Login

                                • Login or register to search.
                                • First post
                                  Last post
                                0
                                • Categories
                                • Recent
                                • Tags
                                • Popular
                                • Users
                                • Groups
                                • Search
                                • Get Qt Extensions
                                • Unsolved