in your Main.cpp initialise function, just case in there on your command line params. If you want to show a GUI, set your mainWindow variable (mainWindow.reset(…)), else do what you need to do headless.
I would start a new project with the GUI Application template. That won’t have that _CONSOLE and other console related settings in the build.
If it is run from the Explorer/double click, there are no arguments and you open the GUI.
If it is run from the terminal and arguments are supplied, you simply don’t create a window like suggested before. All works as intended.
The settings you have now are trying to open a terminal if not started from a terminal IIRC. But when you get cmd arguments, there is already a terminal, so no need for the _CONSOLE switch.