gpt4 book ai didi

c++ - 启动/运行外部可执行文件并查看其输出日志

转载 作者:行者123 更新时间:2023-11-28 01:25:41 25 4
gpt4 key购买 nike

我从我的 Qt 应用程序中运行名为 agent.exe 的外部可执行文件,如下所示:

// header
QProcess *m_agent;

// source
m_agent = new QProcess(this);

QString agentPath = QCoreApplication::applicationDirPath() + "/agent.exe";

if (QFileInfo::exists(agentPath) && QFileInfo(agentPath).isFile()) {
m_agent->start(agentPath);
} else {
qDebug() << __func__ << "Executable does NOT exist\n";
}

我的 agent.exeQProcess * 下运行良好,但问题是我看不到它的输出日志。有没有办法查看它的日志?

最佳答案

您可以将 QProcess 的信号 readyReadStandardOutput() 连接到您应用中的插槽,并使用函数 QProcess::readAllStandardOutput()将获取 QByteArray 形式的数据,您可以将其保存在 QFile 中或在 QTextBrowser

中显示给用户

关于c++ - 启动/运行外部可执行文件并查看其输出日志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53985965/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com