久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

使用Qt時(shí)如何打印到控制臺(tái)

How to print to console when using Qt(使用Qt時(shí)如何打印到控制臺(tái))
本文介紹了使用Qt時(shí)如何打印到控制臺(tái)的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

我正在使用 Qt4 和 C++ 來制作一些計(jì)算機(jī)圖形程序.我需要能夠在運(yùn)行時(shí)在我的控制臺(tái)中打印一些變量,而不是調(diào)試,但是即使我添加了庫,cout 似乎也不起作用.有沒有辦法做到這一點(diǎn)?

I'm using Qt4 and C++ for making some programs in computer graphics. I need to be able to print some variables in my console at run-time, not debugging, but cout doesn't seem to work even if I add the libraries. Is there a way to do this?

推薦答案

如果打印到 stderr 足夠好,您可以使用以下最初用于調(diào)試的流:

If it is good enough to print to stderr, you can use the following streams originally intended for debugging:

#include<QDebug>

//qInfo is qt5.5+ only.
qInfo() << "C++ Style Info Message";
qInfo( "C Style Info Message" );

qDebug() << "C++ Style Debug Message";
qDebug( "C Style Debug Message" );

qWarning() << "C++ Style Warning Message";
qWarning( "C Style Warning Message" );

qCritical() << "C++ Style Critical Error Message";
qCritical( "C Style Critical Error Message" );

// qFatal does not have a C++ style method.
qFatal( "C Style Fatal Error Message" );

盡管如評(píng)論中所指出的,請(qǐng)記住,如果定義了 QT_NO_DEBUG_OUTPUT,則會(huì)刪除 qDebug 消息

Though as pointed out in the comments, bear in mind qDebug messages are removed if QT_NO_DEBUG_OUTPUT is defined

如果你需要標(biāo)準(zhǔn)輸出,你可以嘗試這樣的事情(正如凱爾斯特蘭德指出的那樣):

If you need stdout you could try something like this (as Kyle Strand has pointed out):

QTextStream& qStdOut()
{
    static QTextStream ts( stdout );
    return ts;
}

然后您可以按如下方式調(diào)用:

You could then call as follows:

qStdOut() << "std out!";

這篇關(guān)于使用Qt時(shí)如何打印到控制臺(tái)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

How can I read and manipulate CSV file data in C++?(如何在 C++ 中讀取和操作 CSV 文件數(shù)據(jù)?)
In C++ why can#39;t I write a for() loop like this: for( int i = 1, double i2 = 0; (在 C++ 中,為什么我不能像這樣編寫 for() 循環(huán): for( int i = 1, double i2 = 0;)
How does OpenMP handle nested loops?(OpenMP 如何處理嵌套循環(huán)?)
Reusing thread in loop c++(在循環(huán) C++ 中重用線程)
Precise thread sleep needed. Max 1ms error(需要精確的線程睡眠.最大 1ms 誤差)
Is there ever a need for a quot;do {...} while ( )quot; loop?(是否需要“do {...} while ()?環(huán)形?)
主站蜘蛛池模板: 看羞羞视频 | 国产精品区二区三区日本 | 亚洲视频www| 精品免费国产视频 | 蜜桃av人人夜夜澡人人爽 | 国产成人精品一区二区三区在线 | 欧美.com | 一区二区三区国产 | 中文字幕在线一区 | 精品国产一区二区国模嫣然 | www.色.com| 亚洲精品99久久久久久 | 91精品国产色综合久久不卡蜜臀 | 天天爽天天操 | 91久久精品国产免费一区 | 男女在线网站 | 在线视频一区二区 | 国产美女精品视频 | 亚洲网站在线观看 | 久操亚洲 | 天天天天天操 | 免费国产一区二区视频 | www.亚洲一区二区三区 | 国产精品久久久久一区二区三区 | 亚洲一区二区三区免费在线 | 国产精品日韩欧美一区二区三区 | 久久九九色 | 日韩欧美精品 | 四虎在线观看 | 欧美天堂 | 国产精品久久网 | 亚洲精品在线播放 | 欧美视频三区 | 91影院在线观看 | 国产一区二区三区欧美 | 中文字幕一区二区三区四区五区 | 伊人超碰在线 | 一级中国毛片 | 国产精品久久久久久久三级 | 91精品久久久久久久久久入口 | 欧美一级大片 |