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. Output of QProcess is delayed

Output of QProcess is delayed

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 4 Posters 649 Views 1 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.
  • bleriot13B Offline
    bleriot13B Offline
    bleriot13
    wrote on last edited by
    #1

    Hi!

    I have developed a GUI application that launches a command line tool. Basically, it gets some data from the GUI, saves such data in a file, and then runs the command line tool passing the name of this file as its unique parameter.

    To do it, I use a QProcess, and connect the typical signals (for output, error, end of the process...) to my own slots. It works.

    HOWEVER: the output of the underlying command line is noticeably delayed. This tool takes some time to complete, and every now and then it issues a message stating what's the part of the problem it is working on. When I run the command line manually, I get these messages as soon as the tool reaches the point where the corresponding phase of the process is executed.

    However, when I embed it via QProcess, most of the messages are shown only when the command line tool has finished. This means that the user gets impatient about having no feedback...

    Is there anything I can do to at least alleviate this problem?

    Thanks!

    jsulmJ JonBJ 2 Replies Last reply
    0
    • bleriot13B bleriot13

      Hi!

      I have developed a GUI application that launches a command line tool. Basically, it gets some data from the GUI, saves such data in a file, and then runs the command line tool passing the name of this file as its unique parameter.

      To do it, I use a QProcess, and connect the typical signals (for output, error, end of the process...) to my own slots. It works.

      HOWEVER: the output of the underlying command line is noticeably delayed. This tool takes some time to complete, and every now and then it issues a message stating what's the part of the problem it is working on. When I run the command line manually, I get these messages as soon as the tool reaches the point where the corresponding phase of the process is executed.

      However, when I embed it via QProcess, most of the messages are shown only when the command line tool has finished. This means that the user gets impatient about having no feedback...

      Is there anything I can do to at least alleviate this problem?

      Thanks!

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @bleriot13 Please show how exactly you're using QProcess.
      Especially how your read stdout.
      Do you block the event loop somewhere?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #3

        And does your program properly flush it's output to stdout (std::endl/std::flush?)

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        bleriot13B 1 Reply Last reply
        2
        • bleriot13B bleriot13

          Hi!

          I have developed a GUI application that launches a command line tool. Basically, it gets some data from the GUI, saves such data in a file, and then runs the command line tool passing the name of this file as its unique parameter.

          To do it, I use a QProcess, and connect the typical signals (for output, error, end of the process...) to my own slots. It works.

          HOWEVER: the output of the underlying command line is noticeably delayed. This tool takes some time to complete, and every now and then it issues a message stating what's the part of the problem it is working on. When I run the command line manually, I get these messages as soon as the tool reaches the point where the corresponding phase of the process is executed.

          However, when I embed it via QProcess, most of the messages are shown only when the command line tool has finished. This means that the user gets impatient about having no feedback...

          Is there anything I can do to at least alleviate this problem?

          Thanks!

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #4

          @bleriot13
          As @Christian-Ehrlicher says, except I'm assuming the "other program" is not yours. Its output is likely to buffered when writing to a pipe rather than the terminal/command line. Try running something like other | cat from the command line and see how it behaves delay-wise.

          1 Reply Last reply
          0
          • Christian EhrlicherC Christian Ehrlicher

            And does your program properly flush it's output to stdout (std::endl/std::flush?)

            bleriot13B Offline
            bleriot13B Offline
            bleriot13
            wrote on last edited by bleriot13
            #5

            Dear @Christian-Ehrlicher, yours was the solution!

            I wrote not only the GUI but also the command line app. I only had to add a std::flush command at the end of every message in the command line one and the problem was solved.

            THANK YOU VERY MUCH!!!

            1 Reply Last reply
            3

            • Login

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