-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被捕获和显示。
我现在应该做什么?