久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

使用 QProcess 管道(或命令鏈)

Piping (or command chaining) with QProcess(使用 QProcess 管道(或命令鏈))
本文介紹了使用 QProcess 管道(或命令鏈)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在使用 Qt 并對其進行 bash,需要執行如下操作:

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

bash: cat file | grep string

在 Qt 中:

QString cmd = "cat file | grep string";
QProcess *process = new QProcess;
process->start(cmd);
process->waitForBytesWritten();
process->waitForFinished();
qDebug() << process->readAll();

問題出在管道(|")中,進程沒有返回任何內容.如果沒有(|"),比如

The problem is in pipe ("|"), and process returs nothing. If there is no ("|"), like

"cat file" 

一切正常.我試過了.喜歡

everything is ok. I tried smth. like

"cat file \| grep string", 
"cat file | grep string" 

但結果是一樣的.如果我復制命令并在 bash 中運行它,一切正常.

but result is the same. If I copy the command and run it in bash everything is ok.

QString::toAscii().data()

和其他轉換也有不好的結果.

and other transforms also have bad result.

推薦答案

問題是您不能使用 QProcess 運行系統命令,而只能運行單個進程.因此,解決方法是將您的命令作為參數傳遞給 bash:

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");

這篇關于使用 QProcess 管道(或命令鏈)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How can I read and manipulate CSV file data in C++?(如何在 C++ 中讀取和操作 CSV 文件數據?)
In C++ why can#39;t I write a for() loop like this: for( int i = 1, double i2 = 0; (在 C++ 中,為什么我不能像這樣編寫 for() 循環: for( int i = 1, double i2 = 0;)
How does OpenMP handle nested loops?(OpenMP 如何處理嵌套循環?)
Reusing thread in loop c++(在循環 C++ 中重用線程)
Precise thread sleep needed. Max 1ms error(需要精確的線程睡眠.最大 1ms 誤差)
Is there ever a need for a quot;do {...} while ( )quot; loop?(是否需要“do {...} while ()?環形?)
主站蜘蛛池模板: 伊人av综合| 黄色片免费网站 | 国产无遮挡 | 男男成人高潮片免费网站 | 青青草免费在线 | 亚洲h视频 | 久久久久久久综合 | 日韩毛片视频 | 久久精品播放 | 亚洲第一av | 美女免费视频网站 | 日本黄色免费视频 | 日韩精品极品 | 22精品一区二区三区 | 成人欧美激情 | 啪啪小视频 | 狠狠干美女 | 国产精品一品二区三区的使用体验 | 精品国产一二三 | 午夜视频| 国产一二三 | 在线成人小视频 | 国产91av视频 | 91色网站 | 日韩黄色一级 | a毛片免费看 | 国产精品久久一区二区三区 | 国产精品一区二区久久 | 亚洲精品999| 久久久久久久综合 | www99热| 精品国产三级 | 久久久夜色精品 | 亚洲激情网站 | 黄色天堂 | 在线国产小视频 | 亚洲欧美国产毛片在线 | 日日干天天干 | 国产三级在线播放 | 91超碰人人 | 久久久久久久久久久国产 |