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

讀取 QProcess 輸出到字符串

read QProcess output to string(讀取 QProcess 輸出到字符串)
本文介紹了讀取 QProcess 輸出到字符串的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我有一個(gè)像這樣使用 QProcess 的代碼.

I have a code that uses QProcess like this.

int main(int argc, char *argv[])
{
    int status=0;
    QProcess pingProcess;
    QString ba;
    QString exec = "snmpget";
    QStringList params;
     params << "-v" << "2c" << "-c" << "public" << "10.18.32.52" <<    ".1.3.6.1.4.1.30966.1.2.1.1.1.5.10";
    status=pingProcess.execute(exec, params);
    pingProcess.close();
}

這將輸出以下內(nèi)容.

SNMPv2-SMI::enterprises.30966.1.2.1.1.1.5.10 = STRING: "0.1"

我想將此輸出作為字符串讀取(讀取).我搜索了這個(gè),但找不到解決方案.提前致謝.

I want to take(read) this output as string. I searched for this and I cant find the solution. Thanks in advance.

推薦答案

Did you try QByteArray QProcess::readAllStandardOutput() docs - 這里

Did you try QByteArray QProcess::readAllStandardOutput() docs - here

QString 可以從 QByteArray 實(shí)例化:

QString output(pingProcess.readAllStandardOutput());

正如其他人提到的,我也加入他們,你不應(yīng)該使用 execute 方法并將其替換為:

As others mentioned, and I join to them, you should not use execute method and replace it with:

pingProcess.start(exec, params);
pingProcess.waitForFinished(); // sets current thread to sleep and waits for pingProcess end
QString output(pingProcess.readAllStandardOutput());

這篇關(guān)于讀取 QProcess 輸出到字符串的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

相關(guān)文檔推薦

How can I read and manipulate CSV file data in C++?(如何在 C++ 中讀取和操作 CSV 文件數(shù)據(jù)?)
In C++ why can#39;t I write a for() loop like this: for( int i = 1, double i2 = 0; (在 C++ 中,為什么我不能像這樣編寫 for() 循環(huán): for( int i = 1, double i2 = 0;)
How does OpenMP handle nested loops?(OpenMP 如何處理嵌套循環(huán)?)
Reusing thread in loop c++(在循環(huán) C++ 中重用線程)
Precise thread sleep needed. Max 1ms error(需要精確的線程睡眠.最大 1ms 誤差)
Is there ever a need for a quot;do {...} while ( )quot; loop?(是否需要“do {...} while ()?環(huán)形?)
主站蜘蛛池模板: av网址在线免费观看 | 91av在线看 | 成人免费看片在线观看 | 久久久久久免费 | 国产一区二区三区视频 | 欧美成人一级片 | 国产成人福利 | 黄色成人免费视频 | 综合色婷婷一区二区亚洲欧美国产 | 欧美日在线 | 成人av一区| 成人免费在线视频观看 | 黄色片在线播放 | 午夜在线观看视频网站 | 日韩欧美在线观看 | 久久精品一区二区三区不卡牛牛 | 久久久久久久久久国产 | 欧美成人三级 | 成人免费毛片入口 | 成年人午夜视频 | 久久久夜色精品 | 日韩黄色免费视频 | 在线观看黄色av | 日韩免费一级片 | 亚洲精品美女 | 午夜视频免费观看 | 毛片在线观看网站 | 春色导航| av一区二区三区在线观看 | 国产精品毛片久久久久久久 | 国产精品不卡视频 | 糖心vlog精品一区二区 | 日韩精品在线一区 | 欧美日韩视频在线 | 欧美顶级黄色大片免费 | 成人免费福利视频 | 黄色录像大片 | 日韩综合精品 | 激情五月综合网 | 国语对白做受欧美 | 欧美黄色一级视频 |