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 Communication between Qt GUI using qt creator and separate C++ program in visual studio ?
Forum Update on Monday, May 27th 2025

How to Communication between Qt GUI using qt creator and separate C++ program in visual studio ?

Scheduled Pinned Locked Moved Unsolved General and Desktop
8 Posts 5 Posters 888 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.
  • N Offline
    N Offline
    Nada Azab
    wrote on 10 May 2023, 08:18 last edited by
    #1

    Hello every ,
    I want to know how to connect between Qt GUI creator and separate C++ program in visual studio ?

    S S 2 Replies Last reply 10 May 2023, 08:49
    0
    • N Nada Azab
      10 May 2023, 08:18

      Hello every ,
      I want to know how to connect between Qt GUI creator and separate C++ program in visual studio ?

      S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 10 May 2023, 08:49 last edited by
      #2

      Use any IPC you prefer:

      • local socket
      • D-Bus (a bit hard to do on Windows but possible)
      • RPC
      • pipes
      • COM

      MS even has a special documentation page about this: https://learn.microsoft.com/en-us/windows/win32/ipc/interprocess-communications

      (Z(:^

      N 1 Reply Last reply 10 May 2023, 10:20
      2
      • S sierdzio
        10 May 2023, 08:49

        Use any IPC you prefer:

        • local socket
        • D-Bus (a bit hard to do on Windows but possible)
        • RPC
        • pipes
        • COM

        MS even has a special documentation page about this: https://learn.microsoft.com/en-us/windows/win32/ipc/interprocess-communications

        N Offline
        N Offline
        Nada Azab
        wrote on 10 May 2023, 10:20 last edited by
        #3

        @sierdzio
        please can you simplify what ipc do ?
        as i want to make my code which in visuals studio (it console app)connect with gui I made in qt creator .

        S 1 Reply Last reply 10 May 2023, 10:24
        0
        • N Nada Azab
          10 May 2023, 10:20

          @sierdzio
          please can you simplify what ipc do ?
          as i want to make my code which in visuals studio (it console app)connect with gui I made in qt creator .

          S Offline
          S Offline
          sierdzio
          Moderators
          wrote on 10 May 2023, 10:24 last edited by
          #4

          @Nada-Azab said in How to Communication between Qt GUI using qt creator and separate C++ program in visual studio ?:

          @sierdzio
          please can you simplify what ipc do ?

          It allows you to connect 2 separate applications (separate executables) so that they can talk with each other. There is a plethora of solutions (I listed just a few) and it's hard to say which one is best, it depends on situation.

          For many (most?) use cases, and especially for a beginner, I'd recommend going with local sockets, they are probably the simplest.

          as i want to make my code which in visuals studio (it console app)connect with gui I made in qt creator .

          For IPC it does not matter at all which IDE you are using to create the apps.

          (Z(:^

          1 Reply Last reply
          2
          • N Nada Azab
            10 May 2023, 08:18

            Hello every ,
            I want to know how to connect between Qt GUI creator and separate C++ program in visual studio ?

            S Offline
            S Offline
            SimonSchroeder
            wrote on 11 May 2023, 07:57 last edited by
            #5

            @Nada-Azab said in How to Communication between Qt GUI using qt creator and separate C++ program in visual studio ?:

            I want to know how to connect between Qt GUI creator and separate C++ program in visual studio ?

            If you want this to be one single program first try to join them into a single project. Create either a VS project or a qmake project. Even better today: create a CMake project which can be use simultaneously by Qt Creator and Visual Studio.

            Another solution is to make your Visual Studio project a library. A single program can only have a single main function. And this has to be the Qt main function! Hence, the VS project needs to be the one without the main. Your Qt project can then call any functions from the VS library project.

            If you truly want communication between two programs IPC is a good choice. Maybe you are thinking of your VS project as terminal application. In that case it is also possible to use QProcess on the Qt side and launch the C++ program. You can connect to its input and output and communicate using strings. This solution is quick to implement, but not really scalable. Communication using strings is a hassle. If your terminal program is only called from your Qt program you could also just send bytes directly. Still, this is not the best solution.

            N 1 Reply Last reply 19 May 2023, 03:51
            1
            • S SimonSchroeder
              11 May 2023, 07:57

              @Nada-Azab said in How to Communication between Qt GUI using qt creator and separate C++ program in visual studio ?:

              I want to know how to connect between Qt GUI creator and separate C++ program in visual studio ?

              If you want this to be one single program first try to join them into a single project. Create either a VS project or a qmake project. Even better today: create a CMake project which can be use simultaneously by Qt Creator and Visual Studio.

              Another solution is to make your Visual Studio project a library. A single program can only have a single main function. And this has to be the Qt main function! Hence, the VS project needs to be the one without the main. Your Qt project can then call any functions from the VS library project.

              If you truly want communication between two programs IPC is a good choice. Maybe you are thinking of your VS project as terminal application. In that case it is also possible to use QProcess on the Qt side and launch the C++ program. You can connect to its input and output and communicate using strings. This solution is quick to implement, but not really scalable. Communication using strings is a hassle. If your terminal program is only called from your Qt program you could also just send bytes directly. Still, this is not the best solution.

              N Offline
              N Offline
              Nada Azab
              wrote on 19 May 2023, 03:51 last edited by Nada Azab
              #6

              @sierdzio
              @SimonSchroeder
              Thanks for your help.

              1 Reply Last reply
              0
              • K Offline
                K Offline
                Kent-Dorfman
                wrote on 19 May 2023, 04:19 last edited by
                #7

                IPC is a generic term for interprocess communications. It is a suite of technologies for message passing between processes that don't share the same memory space.

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  goldenhawking
                  wrote on 19 May 2023, 14:38 last edited by goldenhawking
                  #8

                  A funny way to pass messages between processes is the STD pipes, stdin, stdout. You can design a stdin/stdout proxy using QProcess's QIODevice interfaces. This proxy will fork your Qt app and VS app together as child processes, and read data from one's stdin, pass data to another's stdout.

                  In Win32, text data can be passed directly, while BIN data should be enabled with setmode:

                  #include <stdio.h>
                  #include <fcntl.h>
                  #include <io.h>
                  int main( )
                  {
                     // Set "stdin" to have binary mode:
                    _setmode( _fileno( stdin ), _O_BINARY );
                     //...
                  }
                  

                  This method enables you to direct use scanf, printf , fread, fwrite for cross-process communication.

                  Qt is the best C++ framework I've ever met.

                  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