【发布时间】:2015-12-16 07:22:28
【问题描述】:
#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 命令,输出为:
QML debugging is enabled. Only use this in a safe environment.from here: make: Nothing to be done forfirst'.`
使用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 捕获和显示每个输出。
我现在该怎么办?
【问题讨论】: