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

讀取 QProcess 輸出到字符串

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

問題描述

我有一個像這樣使用 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"

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

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 實例化:

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)形?)
主站蜘蛛池模板: 国产激情精品 | 久久国产精彩视频 | 成人羞羞国产免费视频 | 精品区 | 久久国产成人 | 日韩精品极品视频在线观看免费 | 久久精品视频12 | 成人福利在线视频 | 黄色一级大片在线免费看产 | 国产最好的av国产大片 | 中文字幕一级毛片 | 色偷偷噜噜噜亚洲男人 | 国产精品欧美精品 | 久热久热 | 免费在线观看一区二区 | 欧美精品中文 | 91精品国产乱码久久久 | 在线播放中文字幕 | 亚洲男人天堂 | 久久这里只有精品首页 | 91麻豆精品国产91久久久久久 | 国产亚洲成av人在线观看导航 | 成人区精品一区二区婷婷 | 日韩av手机在线观看 | 成人激情免费视频 | 毛片链接 | 黄视频免费 | 免费艹逼视频 | www.欧美.com| 午夜黄色 | 国产精品一区二区三区在线 | www.久久久久久久久久久 | 国产日韩欧美一区 | 男人的天堂亚洲 | 成人小视频在线观看 | 青草久久免费视频 | 一呦二呦三呦国产精品 | 日韩欧美在线观看 | 亚洲一区| 黄色片大全在线观看 | 日韩美女一区二区三区在线观看 |