0

I was just following this topic "How to print to console when using Qt" in order to make my application work. I started to wonder- Is it possible to subscribe more outputs to a single QTextStream? For example, lets say when I wrote something to my QTextStream object, I want the string to be printed to stdout and a specified file as well. Would this be possible? I would appreciate all help.

Edit: To be more exact, I am trying to find an optimal way to send a stream either to stdout, file or file + stdout. I dont want to copy data more times that I need to. Sany hints of how to achieve this?

Community
  • 1
  • 1
Łukasz Przeniosło
  • 2,725
  • 5
  • 38
  • 74

1 Answers1

1

One could, theoratically, write a QIODevice derived class that delegates its writes to multiple other QDIODevice objects and then use an object of that class as the device the QTextStream works on.

However, what you are likely actually looking for is a logging framework.

Kevin Krammer
  • 5,159
  • 2
  • 9
  • 22