Important: Please read the Qt Code of Conduct -

"QProcess::startDetached" - child's console not showing up?

  • Is it really a normal thing that a child process that is a "console application" (SubSystem:CONSOLE) will not show up it's console when launched using "QProcess::startDetached"?

    MS documentation regarding "AllocConsole" says:
    "Console applications are initialized with a console, unless they are created as detached processes (by calling the CreateProcess function with the DETACHED_PROCESS flag)."

    I'm a bit confused, because I've tested this with two different Qt versions:
    x86 - - "QProcess::startDetached" - child process shows it's console.
    x64 - - "QProcess::startDetached" - child process will not show it's console.
    (I'm migrating from 5.7 to 5.10 and was really surprised not to see the console)

    I'm suspecting that this was cause by the Qt bugfix:

    In my child process (debug) I've ended up with:

    1. Allways using "SubSystem:WINDOWS"
    2. Creating the console by using "AllocConsole()". (I'f you're using "SubSystem:CONSOLE" be sure to call "FreeConsole()" before calling "AllocConsole()")
    3. Capturing output with: "freopen("CONOUT$", "w", stderr);" and "freopen("CONOUT$", "w", stdout);"

  • Lifetime Qt Champion


    From the looks of it, you need to use the new version of startDetached using CreateProcessArgumentModifier.

Log in to reply