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

讀取 QProcess 輸出到字符串

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

問題描述

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

正如其他人提到的,我也加入他們,你不應該使用 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());

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

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權益,請聯(liá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)形?)
主站蜘蛛池模板: 日韩一区精品 | 国内毛片毛片毛片毛片 | 黄色一级大片视频 | 黄色毛片一级 | 亚洲一区二区在线视频 | 久久久久久久久99精品 | 蜜桃视频成人 | 九九久久这里只有精品 | 91免费观看 | 中文字幕加勒比 | 国产一级毛片精品完整视频版 | 红色av社区 | 亚洲欧美中文日韩在线 | 在线观看www视频 | 亚洲精品成人免费 | 欧美精品 在线观看 | 日韩影院在线 | 精品久久香蕉国产线看观看亚洲 | 久久99久久久久 | 色网站在线免费观看 | 成人精品一区二区三区中文字幕 | 九色91视频 | 99日韩| 一级欧美日韩 | 狠狠天天 | 欧美aaa级| 天天操夜夜操 | 亚洲香蕉 | 亚洲一区在线日韩在线深爱 | 天堂在线中文字幕 | 亚洲黄色片免费观看 | 欧美不卡一区 | 久免费视频 | 欧美区日韩区 | 精品国产伦一区二区三区观看方式 | 国产成人精品一区二区 | 黄免费观看视频 | 午夜在线影院 | 黄在线| 91久久精品国产91久久性色tv | 欧美一级特黄aaa大片在线观看 |