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. The best way to establish conversation between applications and libraries

The best way to establish conversation between applications and libraries

Scheduled Pinned Locked Moved General and Desktop
8 Posts 4 Posters 2.5k Views 1 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.
  • napajejenunedk0N Offline
    napajejenunedk0N Offline
    napajejenunedk0
    wrote on last edited by
    #1

    I have 2 applications and 1 library. Both applications use the library and what the library does is that it informs each one of them about a progress of something that the library does. If both applications are started and one of the application tells the library to perform some action both applications should be informed about the progress of the task. The application should be able to talk to the library as well.

    Which is the best Qt technology - QSharedMemory, etc., that can be used to complete this conversational task?

    1 Reply Last reply
    0
    • R Offline
      R Offline
      rcari
      wrote on last edited by
      #2

      You should look into implementing this as some sort of a client server with sockets. The server is what you call the library, and the clients the applications. The clients would connect to that server and get informed of the events over a TCP connection for example.

      1 Reply Last reply
      0
      • T Offline
        T Offline
        toralf
        wrote on last edited by
        #3

        I'm a bit confused about your use of the word "library" here. I would normally take it to mean a collection of common functions or object definitions linked with the application. The answer to your question is then "just use function and method calls". I suspect you are talking about something else, though, and if you essentially mean a client-server type setup like the previous reply assumes, then, yes, you need a TCP connection or similar. Using some kind of an abstraction layer may be easier than setting up "raw" links, though. There are many ready-made protocols and software libraries (!) available these days. Which is most appropriate really depends on the application, but have a look at the "QtDBus Module" section of the Qt documentation for an option that's integrated with Qt, and is a bit of a standard for "desktop" uses.

        1 Reply Last reply
        0
        • napajejenunedk0N Offline
          napajejenunedk0N Offline
          napajejenunedk0
          wrote on last edited by
          #4

          I'll describe the case in greater detail:
          I have two applications that are currently running - application A1 and application A2.

          Each one of those two applications is linked with the library called L. The library L exposes a class called "Processor" which has a method called "process()" and a signal "progress(int)" that informs about the progress of the work being done by the "progress()" method.

          I want both applications (they are both started and running) to be informed about the progress, no matter which one of the applications has called "progress()".

          How to do that?

          1 Reply Last reply
          0
          • R Offline
            R Offline
            rcari
            wrote on last edited by
            #5

            Just because you use a shared library doesn't mean that your two program instances use the same instance of that library. Your shared library will be loaded in each process adress space independently. You will have two copies of your library: one in application A1 and one in application A2.
            What you want to do is interprocess communication which can be implemented in a OS independent manner using sockets as I explained in my previous post.

            1 Reply Last reply
            0
            • napajejenunedk0N Offline
              napajejenunedk0N Offline
              napajejenunedk0
              wrote on last edited by
              #6

              bq. Just because you use a shared library doesn’t mean that your two program instances use the same instance of that library. Your shared library will be loaded in each process adress space independently. You will have two copies of your library: one in application A1 and one in application A2.

              I was just about to mention exactly this in my previous post. I know that despite being a dynamic library it is kept separately in each process' memory space.

              So, it is better in the current case to use sockets than D-Bus?

              1 Reply Last reply
              0
              • R Offline
                R Offline
                rcari
                wrote on last edited by
                #7

                I am not fond of D-Bus for some reasons, one of them is that it is not cross-platform. It's a UNIX only technology. If your goal is to solely run in that environment, it is a possible choice, however I would not use it. You can do what you want fairly easily using sockets and QDataStream for object/struct serialization.

                1 Reply Last reply
                0
                • W Offline
                  W Offline
                  walteste
                  wrote on last edited by
                  #8

                  Have a look into QSharedMemory. This sounds perfect for your example and is cross platform too.

                  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