[Solved] Problem Regarding Data reading from QProcess::readAll



  • hai,

    In my application, i am using combo box. In that combo box 8 channels will be their. So when we select a channel1 Qprocess will run C executable file and i will read data from that process.
    I am using this type of code for running the C code after selecting a channel.
    @
    program = "/home/Testing/test";
    arguments<<"0xff"<<"0xbb"<<"0xcc"<<"0xdd"<<"0xaa"<<"0xcd"<<"0xab"<<"0xdf";

        process =new QProcess(this);
        process->setReadChannel(QProcess::StandardOutput);
        process->start(program,arguments);
        process->waitForFinished();
       QByteArray  b1=process->readAllStandardOutput();
        ui1->textEdit->clear();
        QString command(b1);
        ui1->textEdit->setText(command);
        process->closeReadChannel(QProcess::StandardOutput);
        process->kill();
        b1.clear();
    

    @
    My problem is when i select channel1, channel 1 data is displayed in text edit.

    If i select channel 2, then both channel 1 and channel 2 is displaying. i.e.,

    QByteArray b1=process->readAllStandardOutput(); this function is reading both previous and present channel data.

    But i need only selected channel data. So how can i clear the previous channel data.

    Its very important to me. So please give your valuable suggestions for this post.

    Thank you.....



  • my problem was solved.....
    I said,

    bq. If i select channel 2, then both channel 1 and channel 2 is displaying. i.e.,

    QByteArray b1=process->readAllStandardOutput(); this function is reading both previous and present channel data.

    its not reading both previous and present data.

    the problem was I declare arguments as globally so it is passing the previous arguments only thats why i am getting previous data If I declare the arguments as local variable it's working fine


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.