I'm trying to print the process output of downloading a website using wget
in a widget (textEdit) , but it prints nothing , however in terminal it works.
Example
Command :
wget --no-clobber --convert-links --random-wait -r -p -E -e robots=off -U mozilla http://site/path`
Output :
Resolving ******... 54.239.26.173
Connecting to *****|54.239.26.173|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘/index.html’
...
My code :
void downloadWebsite::on_pushButton_clicked()
{
input = ui->lineEdit->text();
if(input.isEmpty())
QMessageBox::information(this,"Error","Not an url / webpage !");
else{
QProcess *getDownload = new QProcess(this);
getDownload->setProcessChannelMode(QProcess::MergedChannels); //it prints everything , even errors
QString command = "wget --no-clobber --convert-links --random-wait -r -p -E -e robots=off -U mozilla " + input;
getDownload->start("sh",QStringList() << "-c" <<"cd ;"+command);
QByteArray outputLog = getDownload->readAllStandardOutput();
getDownload->waitForFinished();
getDownload->close();
QString outputToString(outputLog);
ui->textEdit->setText(outputToString);
}
}
What am I doing wrong ?
Thank you.