Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Can not read stdout of the QT app
Forum Updated to NodeBB v4.3 + New Features

Can not read stdout of the QT app

Scheduled Pinned Locked Moved Solved Installation and Deployment
6 Posts 3 Posters 705 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.
  • L Offline
    L Offline
    latifuluman
    wrote on last edited by
    #1

    I have written an application which calls a subprocess, reads the stdout of the process and shows them in a ui. The user also interacts with the UI (selects, types...) and when clicks to the save button some text from the user's interaction is printed to the standart output. My final purpose is calling the qt application from my another application.
    Briefly, my other application will start the qt application, qt application will start a subprocess then the output of the subprocess will be shown in the UI of QT application. When user clicks to the save button a text will be printed to the stdout of the QT application and I will read the text from my other application. When I use the QT Creator, the final text is printed to the console perfectly. But when I try to run the deployed application from cmd, the app is closed immediately but the app works in background. The subprocess workes, UI occurs. Since it detached from cmd in Windows, I can not see the final text in the console. So when I start the QT app from my another app, it works but I can not read the standart output.
    What should I do in this case?
    Thanks.

    Christian EhrlicherC 1 Reply Last reply
    0
    • L latifuluman

      I have written an application which calls a subprocess, reads the stdout of the process and shows them in a ui. The user also interacts with the UI (selects, types...) and when clicks to the save button some text from the user's interaction is printed to the standart output. My final purpose is calling the qt application from my another application.
      Briefly, my other application will start the qt application, qt application will start a subprocess then the output of the subprocess will be shown in the UI of QT application. When user clicks to the save button a text will be printed to the stdout of the QT application and I will read the text from my other application. When I use the QT Creator, the final text is printed to the console perfectly. But when I try to run the deployed application from cmd, the app is closed immediately but the app works in background. The subprocess workes, UI occurs. Since it detached from cmd in Windows, I can not see the final text in the console. So when I start the QT app from my another app, it works but I can not read the standart output.
      What should I do in this case?
      Thanks.

      Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @latifuluman said in Can not read stdout of the QT app:

      What should I do in this case?

      Use a proper communication channel like e.g. QLocalSocket or QTcpSocket or let the Qt app write to a file which you can read afterwards.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      0
      • L Offline
        L Offline
        latifuluman
        wrote on last edited by latifuluman
        #3

        @Christian-Ehrlicher Thank you for the response. Is not it possible to communicate via stdout? I always used this method untill now. Yes, writing to a file and reading from it is a solution but I dont prefer it if reading from stdout is possible.

        1 Reply Last reply
        0
        • Christian EhrlicherC Online
          Christian EhrlicherC Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by Christian Ehrlicher
          #4

          Not when you create a windows application (/SUBSYSTEM:windows). You must create a console application but then a console is always opened when you execute the application.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          3
          • L Offline
            L Offline
            latifuluman
            wrote on last edited by
            #5

            @Christian-Ehrlicher I have solved by adding the following command into my .pro file
            CONFIG += console
            When I add it, I can run the QT application from cmd or external application and read the stdout of my QT app perfectly. Thanks you for your interes.

            Pablo J. RoginaP 1 Reply Last reply
            0
            • L latifuluman

              @Christian-Ehrlicher I have solved by adding the following command into my .pro file
              CONFIG += console
              When I add it, I can run the QT application from cmd or external application and read the stdout of my QT app perfectly. Thanks you for your interes.

              Pablo J. RoginaP Offline
              Pablo J. RoginaP Offline
              Pablo J. Rogina
              wrote on last edited by
              #6

              @latifuluman said in Can not read stdout of the QT app:

              I have solved

              great, and thank you for sharing the solution to your issue.
              Now don't forget to mark this post as solved!

              Upvote the answer(s) that helped you solve the issue
              Use "Topic Tools" button to mark your post as Solved
              Add screenshots via postimage.org
              Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

              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