在 Qt 4.7 中将标准输出通过管道传输到 QLabel

发布于 2024-10-12 01:55:20 字数 182 浏览 4 评论 0原文

我正在尝试将大学 C++ 代码包装在 Qt 小部件中。

但是,他的程序标准输出必然需要查看。截至目前,我假设我将构建一个 GUI 并打开一个 QProccess 来运行他的程序(然后通过该管道发送命令)。

所以我的问题是无论如何要读取该程序的标准输出并将其显示在 qlabel 或类似的东西中(即我应该研究哪些功能)?

I am trying to wrap a colleges c++ code in a Qt widget.

However, his programs std output necessarily needs to be viewed. As of now I am assuming I will build a GUI and open a QProccess that will run his program (then send commands over that pipe).

So my question is there anyway to read the standard output of that program and display it in a qlabel or something similar (i.e. what functions should I be looking into)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

り繁华旳梦境 2024-10-19 01:55:20

As the process runs, the QProcess object will emit the readyReadStandardOutput() signal as soon as there are data available on the standard output. You can subscribe to the signal, call readAllStandardOutput() from the connected slot and append (not replace) the data to your widget. If you don't need the data to be displayed as soon as it arrives, you can just wait until the process finishes and then read all the output as once.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文