put "readAllStandardOutput()" result in Qstring variable
-
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.
-
@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 aQByteArray
/QString
on first read? -
right ! my mistake !thanks