gtkmm textview and text file
Hi,
Using gtkmm I am trying to display a text file in a textview as follows but i am disappointed with my code!
Any help please?
Thanks in advance.
std::ifstream myFile;//("mfile.txt");
myFile.open("mfile.txt", std::ios::in);
while (!myFile.eof())
{
std::string tmpStr;
std::getline(myFile, tmpStr);
std::cout << tmpStr << std::endl; //This is to see my text on std out
m_refTextBuffer1 = Gtk::TextBuffer::create();
m_refTextBuffer1->set_text(tmpStr);
m_TextView.set_buffer(m_refTextBuffer1);
}
myFile.close();
and my "mfile.txt" contains 2 lines, they are:
linux
is better.
I am still newb in c++, maybe more newbee when using libraries.
Last edited by carlos22; 10-30-2010 at 05:36 PM.
|