You are not logged in.

1

Saturday, December 10th 2011, 5:20pm

Continiously Update QTextBrowser

Hello all,

For an application I am working on, I have to have to visualize a .txt log file in my program. Because everything that happens is written directly into this file, the QTextBrowser has to be reloaded constantly. I am looking for the best way to do this.

Currently I have a QTimer that triggers a QTextBrowser::reload() event every 500ms. Every time this event triggers, a "busy" mouse-pointer pops up, which is really annoying. Also, the scrollbars are restored everytime, so I can't scroll through the file properly ...

I have tried using a QThread but I got some error, and I also think the scrolling problem would nog be solved (which is my biggest concern ATM). Can anyone point me in the right direction?

Thanks alot!

Pieter-Jan

2

Saturday, December 10th 2011, 6:00pm

sorry, that is a ridiculous design.

You should be changing the method of communication, not trying to force text file method to work.


If your data is internal to the program, there is no reason at all why this data cant be saved and updated in memory. Use what is in memory to update your gui.
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

3

Saturday, December 10th 2011, 6:34pm

I know that it is probably not the best way of programming these kind of things, but I really want to get this to work. I don't see another option for this particular application.

The data is not "internal" to the program. I am making use of a library that I have written some time ago. The objects of this library put their status updates etc. inside a Logging object te that writes that stuff to a .txt file. This means that the .txt file is the only link between my GUI program and my library-objects.

4

Saturday, December 10th 2011, 7:14pm

well, you can do the file reading/loading in another thread no problem. But when updating some gui components, You may still have the scroll bar problem.

If you want to solve your thread error, you will need to post the message and your code.
If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

5

Friday, December 16th 2011, 11:09am

Allright. I have thought about it a little further and was able to solve all my problems by redesigning everything.

I am now using a signal/slot implementation so that the logger sends a signal when an entry is added (signals are from the boost library as I couldn't use Qt in my library) and this is connected to a slot in my LogViewer class. Also by using the singleton design pattern I was able to use my logger everywhere without redesigning anything. Awesome.