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
QtWS25 Last Chance

put "readAllStandardOutput()" result in Qstring variable

Scheduled Pinned Locked Moved Solved General and Desktop
string
3 Posts 2 Posters 494 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 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.

    JonBJ 1 Reply Last reply
    0
    • J jawad_soft

      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.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on 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 last edited by
        #3

        right ! my mistake !thanks

        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