Hi All,
How can I create single exe for Console and Gui mode in Qt ???
Thanks in advance.
Hi All,
How can I create single exe for Console and Gui mode in Qt ???
Thanks in advance.
interpreted argv and if the user gives you a console flag, don't call show() on your mainwindow.
Hi ,
Thanks for your reply.
Can you please elaborate it with small example ,I searched a lot in net, but didn't get much help.
My requirement is just by setting some flag in config file(which is outside the application) application should be able to change the mode(GUI/Console) dynamically.
Once again thanks.
PS: I am using Qt4.3.2.
Last edited by summer_of_69; 10th June 2009 at 14:07.
E.g.:
Qt Code:
void main(int argc, char *argv[]) { bool isConsole = false for(int i=0;i<argc;i++) if ("console" == argv[i]) isConsole = true; MainWindow mainWin; if (!isConsole) { mainWin.setupGui(); mainWin.show(); } return app.exec(); }To copy to clipboard, switch view to plain text mode
./myapp console
Or you can change... Switch from Gui to console application, just hide the mainwindow.
This will possibly not work and GUI thread will block the Console window, because my program Linker>>system>>subsystem has Windows (/SUBSYSTEM:WINDOWS) value not "Console". I want to do this dynamically with progam.
I think I am not clear.
When you create one Qt Core application and try to print any thing using operator Cout or fgets() it sends the output to Console window(command prompt) and you can see the output there, but if you use Qt(GUI) mode you can't see command prompt .This is because GUI thread blocks it .
I know this can be invoked using QProcess::startdetached("Cmd.exe"),but by using this I need to change the whole code ,I mean I can't simply send/recieve the output to console using cout/fgets() and all this can be done if I use console mode of Qt (Qt-Core).That's the reason I want two mode in my single executable so that user can operate on either mode just by some configuration settings.
I hope I have explain the problem domain.
I have gone through various links about this but nothing works for me
http://stackoverflow.com/questions/4...le-and-gui-app
Bookmarks