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. [Solved] Problem Regarding Data reading from QProcess::readAll

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

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

    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.....

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Swinetha
      wrote on last edited by
      #2

      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

      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