qdebugstream.h
来自「QT4的utils库源码包.解压后运行./configure配置,然后make.」· C头文件 代码 · 共 49 行
H
49 行
#ifndef Q_DEBUGSTREAM_H#define Q_DEBUGSTREAM_H#include "myexport.h"#include <iostream>#include <streambuf>#include <string>#include <qglobal.h>/** A convenience class for wrapping the standard iostreams into objects, which will send the output to qdebug. It is faster, of course, to write directly to qDebug, but if you have existing code that uses iostream and want a cheap way of redirecting, this is it. Usage: QApplication app(argc, argv); // these redirect both cout/cerr QDebugStream qdsOut(std::cout); QDebugStream qdsErr(std::cerr); // now start using cout and cerr normally std::cerr << "Oops"; // this goes to your QDebug handler Original idea came from here: http://www.qtforum.org/thread.php?threadid=678 */class UTILS_EXPORT QDebugStream : public std::basic_streambuf<char> {public: QDebugStream(std::ostream &stream); ~QDebugStream();protected: virtual int_type overflow(int_type v); virtual std::streamsize xsputn(const char *p, std::streamsize n);private: std::ostream &m_Stream; std::streambuf *m_OldBuf; std::string m_String;};#endif
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?