qt打印到终端 [英] qt printing to terminal
问题描述
在我的 QT 应用程序中,如果我从终端运行应用程序,我希望在终端中打印一些实时信息.
In my QT application, I want to have it so some real-time information prints in the terminal if I run the application from the terminal.
当我使用printf("print this")(无论是在主事件还是在paint事件中)时,直到我关闭gui时,它才打印.
When I use printf("print this") (either in main or during the paint event), it doesn't print until I close the gui.
这是为什么,如何让它实时打印信息?(我正在使用linux)
Why is this, and how can I have it print information in real-time? (I'm using linux)
谢谢!
推荐答案
要写入标准输出,您应该将此 CONFIG + = console
添加到项目文件配置中,并使用 cout 您喜欢的
printf
的code>.默认情况下, qDebug
打印到 stderr
.检查此主题以获取更多信息-如何在使用Qt时打印到控制台
To write to stdout, you should add this CONFIG += console
to your project file config and use cout
of printf
for your liking. qDebug
prints by default to stderr
. Check this topic for more info - How to print to console when using Qt
这篇关于qt打印到终端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!