Can not read stdout of the QT app
-
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. -
@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.
-
@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.
-
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.
-
@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. -
@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!