View Full Version : Log File Question

5th August 2009, 19:56

I'm new to the boards and look to be a contributing member for quite some time as I have just landed an entry level job as a programmer using C++/QT.

Anyways, my question is -- the program that I'm working on writes two different log files once programming has completed. I'm trying to develop a .ui inside the program that will enable the user to see the two logs in a widget screen where each tab on the screen will display the respected log?

Does anyone have any ideas on how to accomplish this feat?

Thanks so much

5th August 2009, 20:08
You could create a QTabWidget with two tabs and a QTextEdit in each tab. When you are ready to read in the files, you can load them into the QTextEdits.

You can set the QTextEdits to be read only, so that the user cannot type stuff into them. I think there are a few examples of QTextEdit linked from the QtAssitant help page.


5th August 2009, 20:29
Thanks Bill,

I created my .ui with the two tabs and the text edit, however, I can't find a feasible way to read the data from the log file that is created to the .ui

5th August 2009, 20:42
If the log file is short, you could just load the whole file into a string and use QTextEdit::append() to put it into the QTextEdit.

I have not used QTextEdit's much, but it looks like you could assing it a QTextDocument, which you would load with QTextDocument::loadResource(). The URL for QTextDocument::loadResource() be a file URL with the path to your log file.