0

I would like to use textview widget to display outputs throughout my program, there are bunch of cout and printf where I display particular information, now I would like to use a GUI in GTK+ to display the outputs that I see on command shell.

I read somewhere I need to use GIOchannel and in other places, somewhere else they just suggested to write to gtk_text_buffer_insert(), the problem is the latter function takes char pointer, and I display doubles and floats. Casting doesn't work and it shouldn't work really.

How do I do this?

unwind
  • 391,730
  • 64
  • 469
  • 606
Warrior4just
  • 119
  • 1
  • 1
  • 9
  • There is a way to take a double and float and represent them as char arrays. Look here: http://stackoverflow.com/questions/332111/how-do-i-convert-a-double-into-a-string-in-c. From there just pass the array variable as the pointer argument for the guy method. – ruthless Nov 28 '14 at 14:57

1 Answers1

0

You can create a stream buffer writing to your widget. You'd derive a class from std::streambuf send character strings to whatever widget function and use an std::ostream initialised with this stream buffer. You can replace std::cout's stream buffer (using std::cout.rdbuf(&sbuf)) if you can't pass a stream to functions where it is used. You'll need to get replace your printf()s, though, if you also want these output to go to your widget.

Dietmar Kühl
  • 150,225
  • 13
  • 225
  • 380