Piping (or command chaining) with QProcess

后端 未结 4 1415
轻奢々
轻奢々 2020-12-01 16:21

I\'m using Qt and bash over it, need to execute something like:

bash: cat file | grep string

in Qt:

QString cmd = \"cat fil         


        
4条回答
  •  北海茫月
    2020-12-01 16:55

    The problem is you cannot run a system command with QProcess, but only a single process. So the workaround will be to pass your command as an argument to bash:

    process.start("bash", QStringList() << "-c" << "cat file | grep string");
    

提交回复
热议问题