Skip to content

Instantly share code, notes, and snippets.

@studiofuga
Created September 5, 2018 18:23
Show Gist options
  • Save studiofuga/8c894b0c3127c611fced62764948499f to your computer and use it in GitHub Desktop.
Save studiofuga/8c894b0c3127c611fced62764948499f to your computer and use it in GitHub Desktop.
Open std Console (cout/cerr) on Qt GUI Application
#include <QApplication>
#ifdef _WIN32
#include <Windows.h>
#endif
int main(int argc, char *argv[])
{
#ifdef _WIN32
if (AttachConsole(ATTACH_PARENT_PROCESS)) {
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
}
#endif
QApplication app (argc, argv);
// etc..
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment