Important: Please read the Qt Code of Conduct -

Efficiency between QProcess and "system"

  • Hi
    I want to know the efficiency between using QProcess to run bash to do some commands and using system or popen to do that( include getting content from stdout ).

    I think QProcess is convenient to do that but I have no idea whether QProcess is more efficient than system or not


  • If you want to manage the process asynchronously then you use QProcess. If you want to subshell process and stall the parent while the work is being done then system() works. QProcess is the "Qt" way of doing things. They both can be used for the same purpose but QProcess is more robust.

    Efficiency is irrelevant since they both probably use much of the same underlying code.

  • Thanks, @Kent-Dorfman
    I think I know how to improve my project.

  • @Mihan
    When using Qt there is no reason to prefer system() over QProcess. Even @Kent-Dorfman's "stall the parent while the work is being done" can now be achieved with the one-liner convenience static function introduced a couple of releases ago if that's what you want. And unless you are doing something special with popen(), Qt's QProcess offers pipe redirection on stdin/stdout/stderr in a convenient package.

Log in to reply