On 11-Jul-14 14:14, Joerg Bornemann wrote: > Here's the code. Maybe I missed something.
Ossi showed me what I missed. We cannot just change stdout unconditionally. So no reason to not do this, as long as the application call is prefixed with "start /wait" to run it in the foreground. ---snip--- #include <QApplication> #include <qt_windows.h> #include <cstdio> #include <fcntl.h> #include <io.h> int main(int argc, char *argv[]) { QApplication a(argc, argv); HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE); if (h == INVALID_HANDLE_VALUE || h == NULL) { if (!AttachConsole(ATTACH_PARENT_PROCESS)) return 1; h = GetStdHandle(STD_OUTPUT_HANDLE); int fd = _open_osfhandle((intptr_t)h, _O_TEXT); if (fd <= 0) return 2; *stdout = *_fdopen(fd, "w"); setvbuf(stdout, NULL, _IONBF, 0 ); } printf("Hello World from GUI app!\n"); QMetaObject::invokeMethod(&a, "quit", Qt::QueuedConnection); return a.exec(); } ---snap--- Joerg _______________________________________________ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development