Please a solution of this problem in Qt?
-
QString MainWindow::cmd(const QString &command)
{
QProcess Proces;
Proces.start(command);
Proces.waitForFinished(-1);
Proces.setReadChannel(QProcess::StandardOutput);
QTextStream reade2(&Proces);
reade2.setCodec("UTF-8");
QString line2,line,Out;
while (reade2.readLineInto(&line2))
{
Out.append(line2 +'\n');
}
Proces.setReadChannel(QProcess::StandardError);
QTextStream reader(&Proces);
while (reader.readLineInto(&line))
{
Out.append(line +'\n');
}
Proces.close();
return Out.trimmed();
}extern QString MainWindow::Exec(const QString &command)
{
QFuture<QString> maeit = QtConcurrent::run(this ,cmd,command);
while (!maeit.isFinished()) {QApplication::processEvents();}
return maeit.result();
} -
Hi and welcome to devnet,
https://doc.qt.io/qt-5/qtconcurrentrun.html#using-member-functions
-
Hi and welcome to devnet,
https://doc.qt.io/qt-5/qtconcurrentrun.html#using-member-functions
@SGaist thank you.