📄 qdebugstream.h
字号:
#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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -