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 fills buffer before emit readyRead()
Qt 6.11 is out! See what's new in the release blog

QProcess fills buffer before emit readyRead()

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 542 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.
  • M Offline
    M Offline
    Mark81
    wrote on last edited by
    #1

    I'm wokring on Linux (Raspbian) with Qt 5.9.2. Using QProcess to ready the output of some Linux commands (i.e. hcitool) leads to waits until the buffer (? about 4k) is filled before catch the readyRead signal in order to read out the data:

    QProcess process;
    _process.setProcessChannelMode(QProcess::MergedChannels);
    connect(&_process, &QProcess::readyRead, this, &Example::process_readyRead);
    
    process.start("hcitool", QStringList() << "lescan");
    
    // ...
    
    void Example::process_readyRead()
    {
        QByteArray line;
    
        while (!(line = _process.readLine()).isEmpty())
        {
            qDebug() << line;
        }
    }
    

    I also tried with the Unbuffered option or readAll function, but they don't change the behavior.
    Any idea what's going wrong here?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      Mark81
      wrote on last edited by
      #2

      Solved in this way:

      _process.start("stdbuf", QStringList() << "-o" << "0" << "hcitool" << "lescan");
      
      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