PDA

View Full Version : How to use Windows console in a QT Widget Application?



robgeek
3rd May 2015, 03:43
Hi!

I making a GUI program using QtCreator3.4.0 and i would like to use the console to see some things(i would like to test some lists sizes and other simple things like check the value of a variable in some part of the code, i think is more fast then debug). I'm using Windows 8.1 and MinGw4.9.1.

I read here i have to add "CONFIG += console" in my .pro file and i did it, i added too "include <iostream> using namespace std;" in my .cpp file but when i try to use "cout << "test";" i get the following error message.


crt0_c.c:-1: error: undefined reference to `WinMain@16'
collect2.exe:-1: error: error: ld returned 1 exit status

How can i do that?

feiz
3rd May 2015, 04:09
I use Visual Studio write Qt Application.In vs,just set link--system--subsystem(CONSOLE).

ChrisW67
3rd May 2015, 09:58
Assuming that it built correctly before you changed the pro file... Did you rerun qmake after changing the pro file?

robgeek
3rd May 2015, 21:20
Didn't know i had to do this, ChrisW67. I did it, actually i went to sleep and now i started my system and reopened qtcreator is working!

d_stranz
3rd May 2015, 21:59
If you are using Qt Creator, you can simply #include <QDebug> and insert qDebug() statements in your code. When you run the program in debug mode, the debug statement output appears in the Application output window of Qt Creator. No need to mess up your application configuration for something as simple as printing diagnostics at runtime.