This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Possibility of running GUI on multithreads

 
Rekha Pai
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Very glad to hear about this book.

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?

Regards,
Rekha.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49412
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are QT and tcl/tk threadsafe?
 
Anthony Aj Williams
author
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rekha Pai
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Regards,
Rekha.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49412
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic