简体   繁体   English

QtCreator std :: cout和输出窗格

[英]QtCreator std::cout and output pane

When I run console applications in QtCreator the output (and input - std::cout, std::cin) is done via xterm (my OS is debian). 当我在QtCreator中运行控制台应用程序时,输出(和输入-std :: cout,std :: cin)是通过xterm完成的(我的操作系统是debian)。 How can I make output to be shown in the QtCreator's output pane not in the xterm window? 如何使输出显示在QtCreator的输出窗格中而不是在xterm窗口中?

From the Qt Creator website: 从Qt Creator网站:

Application Output 应用输出

The Application Output pane displays the status of a program when it is executed, and the debug output. “应用程序输出”窗格显示程序执行时的状态以及调试输出。

http://doc.qt.digia.com/qtcreator/creator-quick-tour.html http://doc.qt.digia.com/qtcreator/creator-quick-tour.html

It does not look like the Application Output window is what you think it is. 您认为它看起来不像“应用程序输出”窗口。

You should use the QDebug() function for this. 您应该为此使用QDebug()函数。 It's usage is pretty much the same as std::cout. 它的用法与std :: cout几乎相同。 Look at the example below: 看下面的例子:

float coordinate = 3.41;
qDebug() << "Custom coordinate type:" << coordinate;

This will output, in your QtCreator's output pane: 这将在您的QtCreator的输出窗格中输出:

Custom coordinate type: 3.41 自定义坐标类型:3.41

Don't forget to include this statement, in your includes block: 不要忘记在您的include块中包含以下语句:

#include <QDebug>

For more information, check this link: http://doc.qt.io/qt-5/qdebug.html 有关更多信息,请检查此链接: http : //doc.qt.io/qt-5/qdebug.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM