I looked at various options for working with the console, but did not find the right one. It is necessary to bring the execution command to the console as if I entered it there myself. The fact is that most programs I can run with only one parameter using QProcess. Please show the working version of this solution.
process.start("mutt", QStringList << "param"); if( !process.waitForStarted() || !process.waitForFinished() ) { return; }
More deployed:
void transport_mail () { QString buf; QProcess process; buf = "mutt -s "; buf += '"'; buf += "tema1"; buf +='"'; buf += " mail@gmail.com"; buf += " < /home/alexandr/1.txt"; qDebug () << buf; process.start(buf); if( !process.waitForStarted() || !process.waitForFinished() ) { return; } qDebug() << process.readAllStandardError(); qDebug() << process.readAllStandardOutput(); }
Displays in console:
"mutt -s "tema1" mail@gmail.com < /home/alexandr/1.txt" QProcess: Destroyed while process ("mutt") is still running.
But if there is one parameter, then everything is ok. If you type in the console yourself, then everything works too. UbuntuSDK - Qt5, C ++