GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Mon Jul 28, 2014 6:15 am

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
 Post subject: How to get data from TextView to ustring variable
PostPosted: Tue Dec 03, 2013 2:16 pm 
Offline

Joined: Thu Nov 14, 2013 9:52 pm
Posts: 3
Like in subject.

I got:
Gtk::TextView text;
Glib::ustring u_text;

How to copy data from text to u_text?
i'm following this instruction:
https://developer.gnome.org/gtkmm-tutor ... es.html.en

But I can't find solution.

Could you help me?

Regards


Top
 Profile  
 
 Post subject: Re: How to get data from TextView to ustring variable
PostPosted: Thu Dec 05, 2013 7:35 am 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 734
Location: UK
Hello,

The Gtk::TextView is based on the MVC (Model, View, Controller) system.

What you need to do is obtain the Gtk::TextBuffer that is associated with your Gtl::TextView. Once you have got the Gtk::TextBuffer you can then get or set your text.

Code:
  Gtk::TextView text;
  Glib::ustring u_text;

  Glib::RefPtr <Gtk::TextBuffer> tb = text.get_buffer();
  u_text = tb->get_text();


Here I obtained the text buffer using the member function Gtk::TextView::get_buffer(). This returns a reference pointer to the text buffer. The to get all the text I used the member function Gtk::TextBuffer::get_text().

The API for the Text View classes can be found at https://developer.gnome.org/gtkmm/unstable/group__TextView.html

_________________
E.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group