Important: Please read the Qt Code of Conduct -

Get large amounts of data from the command line.

  • Hi!
    How do I get large amounts of data from the command line?
    If I do this , I only get the last part of the data:

        process = new QProcess(this);
        connect(process, &QProcess::readyReadStandardOutput, this, &ParserApi::reply);
       process->start(" php gopack.php check_fines " + numberCar + " 0");
    void ParserApi::reply()
        QByteArray replyArray = process->readAllStandardOutput();    
            QJsonDocument doc = QJsonDocument::fromJson(replyArray);
            QJsonObject object1 = doc.object();    
            qDebug()<< doc;

  • Lifetime Qt Champion

    Since readyReadStandardOutput is called more than once you first have to collect the data in your internal buffer.

  • Lifetime Qt Champion

    you have your buffer as a local variable so for each "read" you only keeping the last data.
    Move QByteArray replyArray;
    to the class so its a member (ask if you dont know what that means)
    and do

    void ParserApi::reply()
    replyArray += process->readAllStandardOutput(); // add data to the member buffer

    and in ParserApi()
    replyArray.clear(); // so you alreays start with clean buffer

Log in to reply