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. QProcess Real-time acquisition of output
Forum Updated to NodeBB v4.3 + New Features

QProcess Real-time acquisition of output

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 335 Views
  • 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.
  • Z Offline
    Z Offline
    zhiyuan_song
    wrote on last edited by
    #1

    I want to call external programs through QProcess in QT and get the output in real time。
    The core code is as follows:
    ota = new QProcess(this);
    connect(ota, &QProcess::readyReadStandardOutput, this, &Process::result);
    ota->start("./Process.exe");
    slots:
    void Process::result()
    {
    qDebug() << "start";
    qDebug() << ota->readAllStandardOutput();
    }
    The content in Process is as follows:
    printf("aaa");

    printf("bbb\n");
    
    printf("ccc");
    
    fflush(stdout);
    

    My expected output is:
    start
    aaabbb
    start
    ccc
    But my actual output is:
    start
    "aaabbb\r\nccc"
    Why is that?
    How can I get the output of the process in real time?
    Thank you!

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

      @zhiyuan_song said in QProcess Real-time acquisition of output:

      How can I get the output of the process in real time?

      What do you mean by 'real-time'? The output is exactly what you print out.

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

      1 Reply Last reply
      0

      • Login

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