I have a c++ library that provides an object with complicated logic. So far, many objects print their output to std::cout
when one single library command is executed. I want to create a Qt GUI for this (output it in a text widget instead of console output), so std::cout
has to be changed for something more flexible. I have passed a reference to std::stringstream
parameter to the main object (and it passes it down to lower objects) and replaced all "std::cout << " with "stream << " (stream is std::stringstream).
It doesn't work, because I lose most of the output. When I want to fetch it from the stringstream, it's ridiculously small (just few characters). It seems that if I do stream << var1 << var2 << var3
only var3 will be available.
Don't know how to solve this problem. If I passed a reference to std::cout
as the main object parameter, everything would be ok under console, but it'd not work for the GUI application (I guess I cannot fetch output from std::cout).
Please tell me if I'm using streamstring in a bad way. Or let me know if there is a better way to fetch the output (use something else instead of stringstream). Many thanks in advance.