C++ Debugging Window

Hello Guys im fairly new to C++..
every Good Code need its debugging, so i was just wondering :
which method is best for debugging? Which Debugging Framework do you use?

ATM im using QT GUI, and develop in Visual Studio..i would like to have my GUI window open, and another Console Window which gives me debugging info like "button 1 pressed" or "input is : newkqeq "

Any Ideas ?
Thanks!
Write a "Console Application" with an int main(). And put your GUI code in that.

You would then have std::cout, std::cerr and std::clog .

1
2
3
4
5
6
7
8
9
10
11
12
#include <iostream>
#include <windows.h>

int main()
{
    std::cout << "hello world\n" ;
    
    auto result = MessageBoxA( 0, "hello world", "message", MB_OKCANCEL ) ;
    
    if( result == IDOK ) std::cout << "ok.\n" ;
    else std::cout << "cancel.\n" ;
}
hmm..i dont get it, so a simple QT Window looks like this :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <QApplication>
#include <QWidget>

int main(int argc, char *argv[])
{

    QApplication app(argc, argv);

    QWidget window;

    window.resize(250, 150);
    window.setWindowTitle("A QT Window");
    window.show();

    return app.exec();
}


that opens a simple GUI Window with nothing in it.

Now i want that i have a second window, only a Console window like i have when i do cout <<"some stuff"

Edit : with qDebug(" a String") i can write something to the Visual studio window..but i just want a normal console window :-/
Last edited on
In your .pro file, add the line CONFIG += console

Or in the file containing int main(int argc, char *argv[])
add the line #pragma comment( linker, "/SUBSYSTEM:console" )
yeah, thats it! thx!
Topic archived. No new replies allowed.