Rekha Pai wrote:I used C++ with QT gui and C with tcl/tk gui. At both places I
came across a problem of updating and refreshing the front end
(gui) for some event at the back end. This was because the gui runs
on single thread. Somehow I managed to update by writing into a hidden
widget which automatically calls the paint() method.
My question is can the gui run on multi thread?
With many GUI frameworks (and I think QT is one of them) the GUI works best if all GUI changes happen on the same thread. This is often a requirement of the OS --- e.g. some Microsoft Windows API calls require that the thread calling the API is the thread that created the window.
A useful technique in this case is to use some kind of message queue to pass the data from the thread doing the work over to the GUI thread. This is covered in chapter 8.
Campbell Ritchie wrote:Are QT and tcl/tk threadsafe?
Qt provides thread support in the form of platform-independent threading classes, a thread-safe way of posting events, and signal-slot connections across threads. This makes it easy to develop portable multithreaded Qt applications and take advantage of multiprocessor machines. Multithreaded programming is also a useful paradigm for performing time-consuming operations without freezing the user interface of an application.
Earlier versions of Qt offered an option to build the library without thread support. Since Qt 4.0, threads are always enabled.
tcl is thread safe but tk is not.
Joined: Oct 13, 2005
subject: Possibility of running GUI on multithreads