⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qdebugstream.h

📁 QT4的utils库源码包.解压后运行./configure配置,然后make.使用时在.pro文件中加入两行:LIBS+=-L$$(CPPLIBS)-lutils及INCLUDEPATH+=$$(C
💻 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 + -