Console settings
-
QtCreator should write that line too.
Do you have
console
in your.pro
file?
(Something likeCONFIG += console
)Is the "Run in terminal" option checked in your kit / run & build settings?
https://doc.qt.io/qtcreator/creator-run-settings.html#specifying-run-settings-for-desktop-device-types -
@Rool This "Press enter to close the window" is not printed by your application, but Visual Studio console. You can verify that if you start your app manually from cmd.exe. If you want to have this in your app you have to do it by yourself, there is no magic. Use std::cout and std::cin for that.
-
@Rool
As @jsulm says for the messages (they are just being produced by the VS console, not your program).You also ask about the "exit code". I presume the Russian states your program "exited with code 0". That corresponds to your
return 0
at the end of yourmain()
. If you write a Qt program which runs another program like the one you show, or any other program, it can retrieve the exit code of that program via, say,int exitCode = QProcess::execute("someprogram.exe", QStringList())
. -
@jsulm Yeah, I know, but I was thinking is there is an option to print this as Visual Studio console does. And also I've seen it is possible in Qt console:
@jsulm said in Console settings:@Rool This "Press enter to close the window" is not printed by your application, but Visual Studio console.
-
@JonB I'm sorry, maybe I didn't get what you want to say, but (=qtcreator_process_stub.exe it's not my custom program but the default Qt console. Yes, it's also the program, but I think I can manage it in another way.
@JonB said in Console settings:
@Rool
If you write a Qt program which runs another program like the one you show -
@Rool
You are getting hung up on what VS console is doing for you.qtcreator_process_stub.exe
is just VS's own wrapper for executing your Qt console application. None of this exists outside of running your program from VS. Forget about what it does.-
If you want to output the messages you see there, do e.g. your own
cout << "Message"
. Orcin
for reading characters. -
The only point of the "exit code" stuff you see there is if you run a sub-process from your Qt program, and you want to get its return code. (Which is how the VS console is acting in this case.) For that I showed you how to do that from a Qt program. If you don't have that situation, then the return code is of no interest.
-
-
I think, @Rool' s question is about QtCreator settings and not the program code as such.
I can confirm:
- Console project, with Qt in QtCreator (MinGW) -> no message.
- Raw C++ console project, no Qt (MinGW) -> "Press <Enter>... " message
Raw C++ pro - file
TEMPLATE = app CONFIG += console c++11 CONFIG -= app_bundle CONFIG -= qt SOURCES += \ main.cpp
Qt console .pro - file
QT -= gui CONFIG += c++11 console CONFIG -= app_bundle # The following define makes your compiler emit warnings if you use # any feature of Qt which as been marked deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ main.cpp # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target
Cant say, if it's the pro - file or any other Run setting...