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. How to communicate to Qt UI application from different process using QProcess
Forum Updated to NodeBB v4.3 + New Features

How to communicate to Qt UI application from different process using QProcess

Scheduled Pinned Locked Moved General and Desktop
9 Posts 3 Posters 6.4k 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.
  • A Offline
    A Offline
    aashish.lg
    wrote on last edited by
    #1

    Hi,

    I wrote one QT UI application which just has one push button on it.
    I have written one dll using QT, which will be get loaded by third party application. From this dll using QProcess
    I wanted to launch my QT UI application and wanted to send some data to it, whenever my dll exported functions get called by third party app.

    Any idea how can we achieve this..???Will stdin, stdout work in case of QT UI project.?

    Regards
    Ashish

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      You can use IPC, shared memory, local sockets, regular network connections or stdin/stdout. All of those work, all have their own advantages and drawbacks.

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Chris H
        wrote on last edited by
        #3

        Does [[Doc:QLocalSocket]] fit your needs? It looks like you need a solution that works on Windows, so QtDBus is out (AFAIK).

        1 Reply Last reply
        0
        • A Offline
          A Offline
          aashish.lg
          wrote on last edited by
          #4

          Hi,

          Thanks for the suggestions, I tried to use QLocalSocket() , created a cient in my dll which is getting launched by third party app, and crated a server in my QtUI application.

          I am not able to connect to server from my dll.
          if returns error code as "QLocalSocket::ServerNotFoundError QAbstractSocket::HostNotFoundError The local socket name was not found."

          However for testing purpose I wrote another sample UI app making it as a client and it is connecting properly.

          Please advice even if I will go for Shared Memory approach , in that case how I will send signal from my dll to UI app to read from shared memory.???

          I am targeting both windows and linux machine.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            aashish.lg
            wrote on last edited by
            #5

            Hi volker,

            As solution proposed by you above doing IPC using stdin and stdout, just for sake of info , I am asking that is it possible to have stdin for UI based App.
            If so would you please give some more idea on how we can achieve this?
            I believe that will be the simplest way to achieve IPC.

            I just wanted to pass two long and one string varaible b/w process.

            1 Reply Last reply
            0
            • A Offline
              A Offline
              aashish.lg
              wrote on last edited by
              #6

              I have used QProcess to launch my qt UI app from dll.
              I can see some functions in QProcess class itself to write data.
              In this case would you please advice how my qt UI app can read the data.

              1 Reply Last reply
              0
              • G Offline
                G Offline
                goetz
                wrote on last edited by
                #7

                "QFile::open() ":/doc/qt-4.8/qfile.html#open-4 has an example for opening stdin.

                If you do not have a running event loop (eg. no Q(Core)Application running) you may run into trouble, dont rely on signals sent out in this case.

                As a last resort you can fall back to standard C++ streaming API or the C file handle API. There's plenty of examples in the interwebs out there, your favorite search engine will be happy to help you here.

                http://www.catb.org/~esr/faqs/smart-questions.html

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  aashish.lg
                  wrote on last edited by
                  #8

                  Thaks a lot Volker for your suggestion. I am going to write shared memory in a plattform dependent manner, but do we have something in qt that will notify another process, to start reading on shared memory. My objective is to use plattform dependent code as least as possible.

                  As per best of my knowledge QSystemSemaphore only is visible out of proc.
                  How can a separet process on system semaphore , since QWaitCondition doesnt take semaphore.
                  I am looking for something similar to HEVENT and waitforsingleobject

                  Please advice.

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    goetz
                    wrote on last edited by
                    #9

                    Sorry, I never used that stuff in my projects, I could only guess. I would advice to create a minimal test project an play around with the classes.

                    http://www.catb.org/~esr/faqs/smart-questions.html

                    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