[Qt-interest] How to use ostream << operator with Qt?

Mark Long mlong at weatherdata.com
Fri May 14 23:42:16 CEST 2010


You might take a look at this:

http://www.qtforum.org/article/678/redirecting-cout-cerr-to-qdebug.html

I've had this link in my "check this out sometime" pile for a while now, 
but haven't had time to evaluate it yet.

-Mark


On 05/14/2010 04:00 PM, K. Frank wrote:
> Hello All -
>
> I sometimes write an ostream "<<" operator for my classes, primarily for
> development and debugging purposes.
>
> Is there a common (and easy and lightweight) idiom for using iostream-style
> stuff to output diagnostic messages in Qt?
>
> For example, I can output simple strings through qDebug(), but, because
> qDebug returns a QDebug rather than a std::ostream, I face the nuisance
> of having to implement a QDebug version of "<<".
>
> (By the way, for those who are unaware, microsoft makes it a real PITA
> to use cout / cerr with windows applications.)
>
> Is there some slick way to use an ostream "<<" with Qt?  I was thinking
> perhaps to somehow wrap a stringsteam around QDebug, but I don't have
> in mind a clear scheme for doing so.
>
> (Another thing I was thinking of was making widget that is an ostream
> that I could drop onto my applications\'s gui to act as a log or debugging
> window  Has anyone tried anything like this or have tips for doing so?)
>
> Thanks in advance for any ideas.
>
>
> K. Frank
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
>
>    




More information about the Qt-interest-old mailing list