-1
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QProcess>
#include <QFile>
#include <QDebug>
#include <stdio.h>
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
FILE* file1 = popen ("make", "r");
char buff[5122];
while(fgets(buff, sizeof(buff), file1)!=NULL)
{
qDebug() << "from here: " << buff;
}
QQmlApplicationEngine engine;
engine.load(QUrl(QStringLiteral ("qrc:/main.qml")));
return app.exec();
}
的輸出隨着make
命令的輸出是:POPEN不捕獲所有的命令
QML debugging is enabled. Only use this in a safe environment.
from here: make: Nothing to be done for
first'.`
隨着ping
命令的輸出是:
QML debugging is enabled. Only use this in a safe environment.
Usage: ping [-aAbBdDfhLnOqrRUvV] [-c count] [-i interval] [-I interface]
[-m mark] [-M pmtudisc_option] [-l preload] [-p pattern] [-Q tos]
[-s packetsize] [-S sndbuf] [-t ttl] [-T timestamp_option]
[-w deadline] [-W timeout] [hop1 ...] destination
正如您所看到的,通過make
命令,輸出被捕獲並顯示qDebug
。 但是,ping
並非如此。
無論它是一個錯誤還是什麼,我希望每個輸出都可以通過我的程序通過qDebug被捕獲和顯示。
我現在應該做什麼?