LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-30-2010, 04:41 PM   #1
carlos22
LQ Newbie
 
Registered: Oct 2004
Location: Algeria
Distribution: Debian Jessie+GNOME32 bits+ Fedora 23-x86_64 /P4 3.2 Ghz 2 GB(Ram)+nVIDIA
Posts: 22

Rep: Reputation: 0
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.
 
Old 10-31-2010, 12:55 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Moved: This thread is more suitable in <PROGRAMMING> and has been moved accordingly to help your thread/question get the exposure it deserves.



That said: what is this post about? Style? Are you getting errors? What? :}
 
Old 10-31-2010, 06:37 PM   #3
carlos22
LQ Newbie
 
Registered: Oct 2004
Location: Algeria
Distribution: Debian Jessie+GNOME32 bits+ Fedora 23-x86_64 /P4 3.2 Ghz 2 GB(Ram)+nVIDIA
Posts: 22

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Tinkster View Post
Moved: This thread is more suitable in <PROGRAMMING> and has been moved accordingly to help your thread/question get the exposure it deserves.



That said: what is this post about? Style? Are you getting errors? What? :}
Yes you are right.
The problem is that the testbox doesn't display the text stored in the file which is in the same folder.

Last edited by carlos22; 10-31-2010 at 06:42 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] PyGTK: Send output from a file descriptor to a textview? tonyfreeman Programming 3 07-26-2010 08:26 AM
text match pipe to file then delete from original text file create new dir automatic tr1px Linux - Newbie 6 09-10-2008 09:40 PM
How to parse text file to a set text column width and output to new text file? jsstevenson Programming 12 04-23-2008 02:36 PM
Loading Image From File with Gtkmm/GDK Sava Programming 1 09-11-2006 04:10 AM
Scrolling to mark in TextView (Gtkmm) rubiks Programming 0 04-03-2005 10:42 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:54 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration