I've to admit to never having tested it myself, but can't you just allocate a console for your gui program and execute processes using it?
edit: here is some test code
#include <qtgui/qtgui>
#include <windows.h>
#pragma comment( lib, "shell32.lib" )
void showConsole( HWND parent ) {
FreeConsole();
AllocConsole();
if ( HWND console = GetConsoleWindow() ) {
RECT r;
GetWindowRect( console, &r );
SetParent( console, parent );
MoveWindow( console, 48, 48, r.right, r.bottom, TRUE );
SetConsoleOutputCP(CP_UTF8); // assuming "Lucida console" font was selected already
}
}
void run( wchar_t app[], wchar_t * cmd ) {
STARTUPINFOW si;
ZeroMemory( & si, sizeof( si ) );
si.cb = sizeof( si );
PROCESS_INFORMATION pi;
ZeroMemory( & pi, sizeof( pi ) );
if ( CreateProcessW( app, cmd, 0, 0, 0, 0, 0, 0, & si, & pi ) ) {
DWORD exit_code = 0;
do {
QCoreApplication::processEvents( QEventLoop::ExcludeUserInputEvents );
GetExitCodeProcess( pi.hProcess, &exit_code );
} while( exit_code == STILL_ACTIVE );
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
}
}
void run( wchar_t app[], QString const& cmd ) {
run( app, (wchar_t*)cmd.utf16() );
}
char utf16_test[] = { 0x22, 0x04, 0x40, 0x04, 0x30, 0x04, 0x32, 0x04, 0x43, 0x04, 0x48, 0x04, 0x3a, 0x04, 0x30, 0x04, 0x2e, 0x00, 0x77, 0x00, 0x61, 0x00, 0x76, 0x00, 0x00, 0x00 };
QString const file = QString("E:\\dev-privat\\testsongs\\%1").arg(QString::fromUtf16((ushort*)utf16_test).trimmed());
int main(int argc, char** args) {
QApplication app( argc, args );
QMainWindow win;
win.show();
showConsole( win.effectiveWinId() );
QString const cmd( "LAME.EXE --nohist -V0 --out-dir . \"%1\"" );
run( L"LAME.EXE", cmd.arg(file) );
run( L"LAME.EXE", cmd.arg("testcase.wav") );
run( L"LAME.EXE", cmd.arg("W:\\CD\\Duffy\\2008-Rockferry\\07 Mercy.wav") );
app.exec();
return 0;
}
and the snapshot:
[attachment=7435:console_test.png]