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. What happened to QtSingleApplication?

What happened to QtSingleApplication?

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 5 Posters 6.4k Views
  • 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.
  • C Offline
    C Offline
    Crag_Hack
    wrote on last edited by
    #1

    I'd like to know how to pass command line arguments to an already open program. So the user runs "backup.exe -job awef" and backup.exe recognizes there is an already open process and passes the argument to the already open process so users can command the program to do what they wish from the command line or a shortcut in windows.

    I did a lot of research and found QtSingleApplication is deprecated...
    Anybody know anything about the alternatives below? Are they reliable? Any other information to know?

    https://github.com/itay-grudev/SingleApplication
    https://github.com/qtproject/qt-solutions/tree/master/qtsingleapplication

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by
      #2

      You can do it using QLocalSocket and QLocalServer. when you start the application use a QLocalSocket and try to connect to an existing server if returns an error of type QLocalSocket::ServerNotFoundError then start the server.
      If another instance of application will start it will try and succeed in the connection, you can then use the socket to transmit data between the two applications and, once done, make the second application quit

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

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

        Hi,

        It's available here and has been updated to work with Qt 5.

        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
        2
        • C Offline
          C Offline
          Crag_Hack
          wrote on last edited by Crag_Hack
          #4

          Thanks for the help guys. @SGaist where can I find the header file for the class? Is there any documentation? Also just curious is qt-solutions officially part of The QT Company?

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

            Just clone the QtSolutions repository, you have everything there. The documentation will be same as the one you can find online but you can also build it when you build the module.

            It's a module provided by The Qt Company.

            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
            1
            • VRoninV VRonin

              You can do it using QLocalSocket and QLocalServer. when you start the application use a QLocalSocket and try to connect to an existing server if returns an error of type QLocalSocket::ServerNotFoundError then start the server.
              If another instance of application will start it will try and succeed in the connection, you can then use the socket to transmit data between the two applications and, once done, make the second application quit

              ssokolowS Offline
              ssokolowS Offline
              ssokolow
              wrote on last edited by ssokolow
              #6

              @VRonin Not an ideal solution since it's on you to reinvent appropriate scoping.

              For example, for a desktop Linux/BSD application, the proper solution would be to claim a static name on the session bus via QtDBus (Something like com.you.YourApplication), which has the added benefit of giving you a ready-made place to offer automation RPC to the rest of the desktop, such as raise(). (Not to mention the pre-defined namespaces, like MPRIS.)

              At the very least, I'd incorporate the username or user ID into the server name when using QLocalSocket and QLocalServer.

              kshegunovK 1 Reply Last reply
              0
              • ssokolowS ssokolow

                @VRonin Not an ideal solution since it's on you to reinvent appropriate scoping.

                For example, for a desktop Linux/BSD application, the proper solution would be to claim a static name on the session bus via QtDBus (Something like com.you.YourApplication), which has the added benefit of giving you a ready-made place to offer automation RPC to the rest of the desktop, such as raise(). (Not to mention the pre-defined namespaces, like MPRIS.)

                At the very least, I'd incorporate the username or user ID into the server name when using QLocalSocket and QLocalServer.

                kshegunovK Offline
                kshegunovK Offline
                kshegunov
                Moderators
                wrote on last edited by
                #7

                @ssokolow said in What happened to QtSingleApplication?:

                @VRonin Not an ideal solution since it's on you to reinvent appropriate scoping.

                Perhaps, but rather simple and I'm pretty sure QtSingleApplication does it this way, too.

                Read and abide by the Qt Code of Conduct

                ssokolowS 1 Reply Last reply
                1
                • kshegunovK kshegunov

                  @ssokolow said in What happened to QtSingleApplication?:

                  @VRonin Not an ideal solution since it's on you to reinvent appropriate scoping.

                  Perhaps, but rather simple and I'm pretty sure QtSingleApplication does it this way, too.

                  ssokolowS Offline
                  ssokolowS Offline
                  ssokolow
                  wrote on last edited by
                  #8

                  @kshegunov

                  Actually, I took at quick look at the source code and it looked like it was using a lockfile in the user profile, which means that it would be user-scoped rather than session-scoped.

                  (ie. Two separate sessions under the same account would interfere with each other.)

                  kshegunovK 1 Reply Last reply
                  0
                  • ssokolowS ssokolow

                    @kshegunov

                    Actually, I took at quick look at the source code and it looked like it was using a lockfile in the user profile, which means that it would be user-scoped rather than session-scoped.

                    (ie. Two separate sessions under the same account would interfere with each other.)

                    kshegunovK Offline
                    kshegunovK Offline
                    kshegunov
                    Moderators
                    wrote on last edited by
                    #9

                    @ssokolow said in What happened to QtSingleApplication?:

                    Actually, I took at quick look at the source code and it looked like it was using a lockfile in the user profile, which means that it would be user-scoped rather than session-scoped.

                    I believe this is correct, yes.

                    Read and abide by the Qt Code of Conduct

                    1 Reply Last reply
                    0
                    • C Offline
                      C Offline
                      Crag_Hack
                      wrote on last edited by
                      #10

                      A quick follow up question that's been nagging me... what's the reason for the Qt Company providing a separate QT Solutions module that's not part of the main api?

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

                        Quote from the old days:
                        Trolltech provides platform- and industry-specific components and tools, as well as cutting-edge components too new to include directly in Qt.

                        That's what the Qt Solutions were originally.

                        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
                        1

                        • Login

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