• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Possibility of running GUI on multithreads

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are QT and tcl/tk threadsafe?
 
author
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you.
 
reply
    Bookmark Topic Watch Topic
  • New Topic