Print out a txt file to text box
Hey there, another newbie question….
I would like to display the contents of a text file on screen. Not in console, though.
I can read in the file using QFile and hold the contents in QString. But i want to be able to see it on screen, so perhaps print it to a textbox.
Does anybody know how or what class i would use to do this?
Thanks in advance.
Sorry to be a total noob but what I am trying to do is to load in the content from a .txt file that will contain code and display it in my program.
And I am not sure sure what kind of textbox should I use because I want to keep all the tabs and code structure, also with the example by Eddy how would I put that content into the text box?
A QTextBrowser with a fixed size font would be a good start. To set the contents of a file to the text box, you can use:
You will have to add error checking (file open may fail).