Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Efficiency between QProcess and "system"
Forum Updated to NodeBB v4.3 + New Features

Efficiency between QProcess and "system"

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 1.0k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mihan
    wrote on 3 Mar 2020, 02:42 last edited by
    #1

    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

    Regards
    Mihan

    1 Reply Last reply
    1
    • K Offline
      K Offline
      Kent-Dorfman
      wrote on 3 Mar 2020, 03:11 last edited by Kent-Dorfman 3 Mar 2020, 03:12
      #2

      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.

      M 1 Reply Last reply 3 Mar 2020, 03:24
      4
      • K Kent-Dorfman
        3 Mar 2020, 03:11

        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.

        M Offline
        M Offline
        Mihan
        wrote on 3 Mar 2020, 03:24 last edited by
        #3

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

        J 1 Reply Last reply 3 Mar 2020, 08:27
        0
        • M Mihan
          3 Mar 2020, 03:24

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

          J Offline
          J Offline
          JonB
          wrote on 3 Mar 2020, 08:27 last edited by
          #4

          @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 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 with popen(), Qt's QProcess offers pipe redirection on stdin/stdout/stderr in a convenient package.

          1 Reply Last reply
          2

          1/4

          3 Mar 2020, 02:42

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved