QCommandLineParser print data to dos window
-
Hello everyone,
I am the beginner of Qt development, my Qt version is 6.6.3.I try to make my application to run batch.
The QCommandLineParser work well but cannot print any data to dos window. My code as below: qDebug print nothing but QMessageBox show normally. And the version, help command(-v , -h )will show the data in new window, not in dos window.Is there any advice to show the data in dos window? Thank a lot!
-
Hello everyone,
I am the beginner of Qt development, my Qt version is 6.6.3.I try to make my application to run batch.
The QCommandLineParser work well but cannot print any data to dos window. My code as below: qDebug print nothing but QMessageBox show normally. And the version, help command(-v , -h )will show the data in new window, not in dos window.Is there any advice to show the data in dos window? Thank a lot!
@gong In future please post code as text, not pictures.
Do you start your application from a terminal (cmd.exe) or from QtCreator?
You can also set "Run in terminal" checkbox in Run settings of your project in "Build & Run" in QtCreator. -
@gong gui application doesn't have console output by default on windows.
Try addwin32:CONFIG += console
in your .pro file.
If you uses cmake, I've searched what's the equivalent, seems if you create a gui project by qt creator wizard,WIN32_EXECUTABLE TRUE
is set inset_target_properties
automatically and it should be removed to have console feature. -
@gong gui application doesn't have console output by default on windows.
Try addwin32:CONFIG += console
in your .pro file.
If you uses cmake, I've searched what's the equivalent, seems if you create a gui project by qt creator wizard,WIN32_EXECUTABLE TRUE
is set inset_target_properties
automatically and it should be removed to have console feature.@Bonnie @jsulm Thank you very much for the help! The issue is solved.
After adding "CONFIG+=console", start application from cmd, qDebug will print in the dos window. But it print so many now, is it possilbe to control, for example, print qInfo only and ignore the others, I just want to show the key results(one or several line) in dos window. -
See https://doc.qt.io/qt-6/qtlogging.html#qInstallMessageHandler on how to filter and format the debug output.
-
@Bonnie @jsulm Thank you very much for the help! The issue is solved.
After adding "CONFIG+=console", start application from cmd, qDebug will print in the dos window. But it print so many now, is it possilbe to control, for example, print qInfo only and ignore the others, I just want to show the key results(one or several line) in dos window.