I have a application *.exe which is a GUI applicaition. Now I need to convert it to work as both console and GUI i.e.
if any commandline args is entered like :
D:\Projects\TestProjects\TestQtConsole\Debug>TestQtConsole.exe fdsa
It should simply work as console application wherein application accepts the command args.
if no commandline args are entered it need to work as GUI application.
I did this way:
int main(int argc, char *argv[])
{
HWND hwndC = GetConsoleWindow();
QApplication::Type appType = QApplication::GuiClient;
if (argc > 1)
{
appType = QApplication::Tty;
}
QApplication a(argc, argv, appType);
if (a.type() != QApplication::Tty)
{
CSensoRescue *w = new CSensoRescue();
w->show();
if (hwndC)
{
ShowWindow(hwndC, SW_HIDE);
}
}
Two problems i'm facing is when i enter like :
D:\Projects\TestProjects\TestQtConsole\Debug>TestQtConsole.exe fdsa
i'm getting Invalid arg as output.
Second when i enter as
D:\Projects\TestProjects\TestQtConsole\Debug>TestQtConsole.exe
let me improve my Question:
When i start my .exe directly by double clicking , my console is also getting opened, that i don't want.
i just want GUI only.