Efficiency between QProcess and "system"
-
Hi
I want to know the efficiency between usingQProcess
to runbash
to do some commands and usingsystem
orpopen
to do that( include getting content from stdout ).I think
QProcess
is convenient to do that but I have no idea whetherQProcess
is more efficient thansystem
or notRegards
Mihan -
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 prefersystem()
overQProcess
. Even @Kent-Dorfman's "stall the parent while the work is being done" can now be achieved with the one-liner conveniencestatic
function https://doc.qt.io/qt-5/qprocess.html#execute introduced a couple of releases ago if that's what you want. And unless you are doing something special withpopen()
, Qt'sQProcess
offers pipe redirection on stdin/stdout/stderr in a convenient package.