Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 4

Qt-interest Archive, June 2007
append text in the QTextEdit


Message 1 in thread

I use the QTextEdit widget as the log window in my program, all the run-time
info will be output to this window by calling the function append(const
QString&), but the window's content only be refreshed  after the program
back to the main-thread, but my expection is the window can be refreshed at
once when the function append() is called. Anybody can give me some
information how to implement it?

Thanks.

Brian

Message 2 in thread

On 19.06.07 17:02:52, ææå wrote:
> I use the QTextEdit widget as the log window in my program, all the run-time
> info will be output to this window by calling the function append(const
> QString&), but the window's content only be refreshed  after the program
> back to the main-thread, but my expection is the window can be refreshed at
> once when the function append() is called. Anybody can give me some
> information how to implement it?

I guess the main work of your program is done continously and thus the
event loop (which apart from other things causes repaints to happen) is
not run in between. You have to put your workload code into a thread or
call QApplication::processEvents (not this second may have side-effects because
all pending events are delivered). I suggest to use the thread-way, have
a look at the Qt documentation for QThread for starters. Note you then
have to use queued signal/slots (with Qt4) or you need to post events
between the work-thread and the gui thread, to update gui elements.

Andreas

-- 
 [ signature omitted ] 

Message 3 in thread

Done! Called QApplication::processEvents() is working, fortunately, there's
no other event is pended in the code running.

I try the 1st solution before, but the effect is not good. most of time, the
screen  be refreshed only when my working thread completed.

Thanks!


On 6/19/07, Andreas Pakulat <apaku@xxxxxx> wrote:
>
> On 19.06.07 17:02:52, 李晓国 wrote:
> > I use the QTextEdit widget as the log window in my program, all the
> run-time
> > info will be output to this window by calling the function append(const
> > QString&), but the window's content only be refreshed  after the program
> > back to the main-thread, but my expection is the window can be refreshed
> at
> > once when the function append() is called. Anybody can give me some
> > information how to implement it?
>
> I guess the main work of your program is done continously and thus the
> event loop (which apart from other things causes repaints to happen) is
> not run in between. You have to put your workload code into a thread or
> call QApplication::processEvents (not this second may have side-effects
> because
> all pending events are delivered). I suggest to use the thread-way, have
> a look at the Qt documentation for QThread for starters. Note you then
> have to use queued signal/slots (with Qt4) or you need to post events
> between the work-thread and the gui thread, to update gui elements.
>
> Andreas
>
> --
> You are fighting for survival in your own sweet and gentle way.
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>

Message 4 in thread

On 19.06.07 18:46:36, ææå wrote:
> I try the 1st solution before, but the effect is not good. most of time, the
> screen  be refreshed only when my working thread completed.

The you did something wrong when implementing this.

-- 
 [ signature omitted ]