Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Does QProcess::startDetached() must open a cmd-window?



  • On Win7, I am running the following code:
    QProcess::startDetached(strCmd, QStringList(), ".", &m_nPid);

    the strCmd is a QString looks like "C:\Program Files\AutoDesk\Maya2014\bin\mayabatch.exe -file aFile -command aCommand".
    It does start the mayabatch.exe but it gives me a black nuisance cmd-window.
    How could I do to make it avoid showing the black cmd-window?



  • You usually write the program into the first argument, and then the args to your program (one after the other) into the list, like: QProcess::startDetached(path_to_exe,arguments_list,".",&m_nPid).

    But this has nothing to do with the black cmd-window. It always opens when you start a command-line program. It never opens if you start a "normal" windows program. It's a WINDOWS thing, nothing to do with Qt.


  • Moderators

    @m.sue said:

    It's a WINDOWS thing, nothing to do with Qt.

    not true: QTBUG-53833

    @DidaHarp
    you can try to apply the provided patch and recompile Qt yourself if you fell like it.



  • @raven-worx @m-sue Thanks a lot. Thank you for your responsible and thoughtful answer and such behavior is so rare in China.


  • Lifetime Qt Champion

    @raven-worx

    Hi nice info,
    so it seems from the message that
    QProcess::start() might not always create a cmd-window?

    it says "
    Instead, use the
    same rules for deducing whether to show an console window or not as
    QProcess::start()."

    Do we know what the rules are? ( besides looking in the code)


  • Moderators

    @mrjj said:

    Do we know what the rules are? ( besides looking in the code)

    i do not.
    But i think the code tells the most, since i expect it as pretty much platform specific.


Log in to reply