std::cout calls are eaten by Qt (nothing printed)
-
Hi,
I am experimenting with VulkanSceneGraph (a graphical library based on VulkanSDK ) and found a nice example with Qt integration. However, in the application, std::cout calls don't print anything at all. Maybe std::cout and std::cerr are redirected to somewhere by Qt, I don't know.
How can I activate std::cout calls in Qt?
All solutions that I found so far suggest enabling a flag in qmake file: CONFIG += console, but this project is CMake project.VulkanSDK Qt example repo:
https://github.com/vsg-dev/vsgQt
Related issue:
https://github.com/vsg-dev/vsgQt/issues/35Thanks.
-
@JonB
Yes it is a GUI program but before creatingQApplication,std:coutshould print to the console, right?For example I am adding a
std::coutat this line: https://github.com/vsg-dev/vsgQt/blob/master/examples/vsgqtviewer/main.cpp#L76Even after creating
QApplicationuntilreturn application.exec();it should print to console?When I run the program without any parameter, the error text at line https://github.com/vsg-dev/vsgQt/blob/master/examples/vsgqtviewer/main.cpp#L117 should print the error, right?
@Mubin said in std::cout calls are eaten by Qt (nothing printed):
Even after creating QApplication until return application.exec(); it should print to console?
No, that's a property (WIN32) of the executable and has nothing to do with Qt
-
Hi,
I am experimenting with VulkanSceneGraph (a graphical library based on VulkanSDK ) and found a nice example with Qt integration. However, in the application, std::cout calls don't print anything at all. Maybe std::cout and std::cerr are redirected to somewhere by Qt, I don't know.
How can I activate std::cout calls in Qt?
All solutions that I found so far suggest enabling a flag in qmake file: CONFIG += console, but this project is CMake project.VulkanSDK Qt example repo:
https://github.com/vsg-dev/vsgQt
Related issue:
https://github.com/vsg-dev/vsgQt/issues/35Thanks.
@Mubin
Where do youm expectstd::coutoutput to go, since I presume you have a GUI program? You might find them in Creator's "Output" window, but they are not going to go anywhere the user can see. If you want that you will want a "console" application, not a GUI one. -
@Mubin
Where do youm expectstd::coutoutput to go, since I presume you have a GUI program? You might find them in Creator's "Output" window, but they are not going to go anywhere the user can see. If you want that you will want a "console" application, not a GUI one.@JonB
Yes it is a GUI program but before creatingQApplication,std:coutshould print to the console, right?For example I am adding a
std::coutat this line: https://github.com/vsg-dev/vsgQt/blob/master/examples/vsgqtviewer/main.cpp#L76Even after creating
QApplicationuntilreturn application.exec();it should print to console?When I run the program without any parameter, the error text at line https://github.com/vsg-dev/vsgQt/blob/master/examples/vsgqtviewer/main.cpp#L117 should print the error, right?
-
@JonB
Yes it is a GUI program but before creatingQApplication,std:coutshould print to the console, right?For example I am adding a
std::coutat this line: https://github.com/vsg-dev/vsgQt/blob/master/examples/vsgqtviewer/main.cpp#L76Even after creating
QApplicationuntilreturn application.exec();it should print to console?When I run the program without any parameter, the error text at line https://github.com/vsg-dev/vsgQt/blob/master/examples/vsgqtviewer/main.cpp#L117 should print the error, right?
@Mubin said in std::cout calls are eaten by Qt (nothing printed):
Even after creating QApplication until return application.exec(); it should print to console?
No, that's a property (WIN32) of the executable and has nothing to do with Qt
-
Ok, I solved the problem.
In Visual Studio, I changed the properties of the project.
Properties -> Linker -> System -> SubSystem was set to Windows /SUBSYSTEM:WINDOWS), I set it to Console (/SUBSYSTEM:CONSOLE). It prints cout to the console now.
Windows /SUBSYSTEM:WINDOWS) expectsWinMain()instead ofmain(). -
M Mubin has marked this topic as solved on
-
Ok, I solved the problem.
In Visual Studio, I changed the properties of the project.
Properties -> Linker -> System -> SubSystem was set to Windows /SUBSYSTEM:WINDOWS), I set it to Console (/SUBSYSTEM:CONSOLE). It prints cout to the console now.
Windows /SUBSYSTEM:WINDOWS) expectsWinMain()instead ofmain().@Mubin That's whats the cmake property I linked is doing, yes.