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. put "readAllStandardOutput()" result in Qstring variable
Forum Updated to NodeBB v4.3 + New Features

put "readAllStandardOutput()" result in Qstring variable

Scheduled Pinned Locked Moved Solved General and Desktop
string
3 Posts 2 Posters 517 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.
  • J Offline
    J Offline
    jawad_soft
    wrote on 26 Jul 2021, 10:11 last edited by
    #1

    Hi I'm using Qprocess to lunch some bash script, and i get the response with the command "readAllStandardOutput()".

    My code :

            QString program_wifi  = "/home/root/IHM/ssid_wifi.sh";
            myProcess_wifi.setProcessChannelMode(QProcess::MergedChannels);
            myProcess_wifi.start(program_wifi);
            myProcess_wifi.waitForFinished();
    
            QTextStream(stdout) << "raw : " <<myProcess_wifi.readAllStandardOutput() <<endl; // display the good SSID
            QString response =  QString(myProcess_wifi.readAllStandardOutput()); // empty data, can't convert
            QTextStream(stdout) << "QString : " << response <<endl;
    

    The next step is to get the data to QSTRING and work with every char of the Qstring, but when i convert the QBytearray output of myProcess_wifi.readAllStandardOutput() , any data are stored, and i don't know how use this output like simplechar array.

    Can somme one help ? thanks.

    J 1 Reply Last reply 26 Jul 2021, 10:16
    0
    • J jawad_soft
      26 Jul 2021, 10:11

      Hi I'm using Qprocess to lunch some bash script, and i get the response with the command "readAllStandardOutput()".

      My code :

              QString program_wifi  = "/home/root/IHM/ssid_wifi.sh";
              myProcess_wifi.setProcessChannelMode(QProcess::MergedChannels);
              myProcess_wifi.start(program_wifi);
              myProcess_wifi.waitForFinished();
      
              QTextStream(stdout) << "raw : " <<myProcess_wifi.readAllStandardOutput() <<endl; // display the good SSID
              QString response =  QString(myProcess_wifi.readAllStandardOutput()); // empty data, can't convert
              QTextStream(stdout) << "QString : " << response <<endl;
      

      The next step is to get the data to QSTRING and work with every char of the Qstring, but when i convert the QBytearray output of myProcess_wifi.readAllStandardOutput() , any data are stored, and i don't know how use this output like simplechar array.

      Can somme one help ? thanks.

      J Offline
      J Offline
      JonB
      wrote on 26 Jul 2021, 10:16 last edited by JonB
      #2

      @jawad_soft said in put "readAllStandardOutput()" result in Qstring variable:

      // empty data, can't convert

      You call myProcess_wifi.readAllStandardOutput() twice. Unless I'm mistaken, the first read reads all data and clears what remains, so nothing left for the second call? Transfer it to a QByteArray/QString on first read?

      1 Reply Last reply
      2
      • J Offline
        J Offline
        jawad_soft
        wrote on 26 Jul 2021, 10:18 last edited by
        #3

        right ! my mistake !thanks

        1 Reply Last reply
        0

        3/3

        26 Jul 2021, 10:18

        • Login

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