Quote Originally Posted by arnaiz View Post
Again, you can hide() your main window, so there is no GUI showing up, and then you can use a QProcess to execute the command processor of your OS. You can use readData() and writeData() for your IO.

Now you can control your GUI, use objects already written, open a console if you need to, and read or write from that process. Is this an option to solve your problem?
I get the feeling that we are not understanding one another. As I said, everything works as I expect on Linux and Mac OS X (I have just checked), so let me explain a bit more what is 'wrong' with Windows.

Ok, say that you open a command prompt window. From there, if I enter the name of my application without any argument, then I want the GUI to show up (easy, since it's already the way it works):

C:\MyApplicationDirectory>MyApplication

C:\MyApplicationDirectory>
Now, say that I add some arguments. This time round, I want my application to behave as a pure console application, so that I can do whatever I want with it (e.g. redirect the output to a file):

C:\MyApplicationDirectory>MyApplication /i myInputFile
MyApplication is going to proceed using myInputFile as an input file
...

C:\MyApplicationDirectory>
Now, as I have said in a previous reply, I can use AttachConsole() and WriteConsole() to 'mimick' the above output, but 1) it's a hack and 2) I can't get the right kind of output (and I am not sure whether I could redirect to a file; I haven't tried) since when starting a GUI application from the command line, Windows goes back to the prompt straightaway, so if anything using AttachConsole() and WriteConsole() I could get:

C:\MyApplicationDirectory>MyApplication /i myInputFile
C:\MyApplicationDirectory>
MyApplication is going to proceed using myInputFile as an input file
...
which is clearly not professional...