我正在尝试调用命令并执行它,但我无法理解如何输送它。我试图使用shell命令一次复制多个文件。
对于(源)中的%I,请复制%I (目标)
QString files = "for %I in (source) do copy %I (destination)"
QProcess copy ;
copy.start(files);我必须实施管道才能做到这一点。就像。
QProcess sh;
sh.start("sh", QStringList() << "-c" << "ifconfig | grep inet");
sh.waitForFinished();
QByteArray output = sh.readAll();
sh.close();如何为复制过程实现管道?
发布于 2017-08-11 10:14:39
试试这个例子:
QProcess sh;
sh.start( "sh", { "-c", "ifconfig | grep inet" } );
if ( !sh.waitForFinished( -1 ) )
{
qDebug() << "Error:" << sh.readAllStandardError();
return -1;
}
const auto output = sh.readAllStandardOutput();
// ...应该在阻塞模式下调用waitForFinished(),并且必须检查它是否成功。
https://stackoverflow.com/questions/45630768
复制相似问题