[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: OT: Updating a GUI thread from another one
From:       Thiago Macieira <thiago.macieira () kdemail ! net>
Date:       2003-12-01 13:47:48
[Download RAW message or body]

[Attachment #2 (multipart/signed)]


Giuseppe Torelli wrote:
>Hi,
>
>I'm in the need of updating the QListView
>of the GUI thread from several others thread
>created by a server thread. When connections arrive,
>this server create a QThread for each connections to
>handle them. I red on QT web site I have to use
>QApplication:postEvent(); since the example is not
>so clear to me, could someone post a clearer one ?
>
>Is there an EASY way with signal/slot to update the GUI
>thread from another thread ?

I have a rudimentary class called QSynchronizing in kdenonbeta/libqt-addon 
that does what you want.

But, answering your more general question: you CANNOT change the GUI outside 
the GUI thread. Therefore, your helper thread has to advise the GUI thread of 
the change and let it do the work instead.

Also note that my class is synchronous -- that is, when the called function in 
the helper thread returns, the GUI thread will have finished processing. And 
also note that this works only on the Qt/X11 architecture. Qt/Win32, TT 
engineers tell me, has one GUI thread per dialog. The class exploits the fact 
that the GUI thread is the event thread as well.

PS: it passed the initial tests for me, but it has never been completely 
tested.

-- 
  Thiago Macieira  -  Registered Linux user #65028
   thiagom@mail.com           
    ICQ UIN: 1967141   PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

[Attachment #5 (application/pgp-signature)]

>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic