Qt app with both Console and GUI components
-
Hi.
I am developing a new application, which is to have both a console UI and a GUI for the user. At a high level, I have three folders in my file hierarchy, one with the core code, one with console UI code, and one with GUI code.
New to Qt, what would be the best way to set this up? Are there any tutorials which handle an app which has multiple front ends? I have only found ones which focus on either console UI, or graphical UI, but not one that gives the option for both. E.g., my pseudo-code in main would be:
int main (int argc, char **argv) { if (commandlineswitch=="--ui_console") { // CLI selected, launch console UI } elseif (commandlineswitch="--ui_gui") { // GUI selected, launch Qt GUI } else { std::cerr << "no UI specified; quiting."; return 1 } }
Any suggestions on how to set this up? Would have one project with three sections? Three projects (one for core code, one for console UI, one for GUI) that interact with each-other?
Thanks,
-10d -
Hi and welcome to devnet,
Will your GUI use your console application e.g. like mplayer's GUI frontend ? Or will it use the same core components ?
-
In that case you can use the subdirs template. Make a library from your common components that you build first and then the other two.
Something like:
TEMPLATE = subdirs SUBDIRS = myconsoleapp myguiapp corelib myconsoleapp.depends = corelib myguiapp.depends = corelib
-
By the way, in QApplication's detailed documentation, you have an example of how start an application in "no-gui" mode.