Results 1 to 3 of 3

Thread: GUI thread and Working thread comunication

  1. #1
    Join Date
    Sep 2007
    Posts
    3
    Thanks
    2

    Default GUI thread and Working thread comunication

    Hi everybody.

    I have a very simple question that is stopping me from continue my project.

    When I have a GUI thread and XX working threads, I know that I can emit signals from the working threads to the GUI thread, but, can I emit signals from the GUI thread to one of the working threads?
    If yes, how can I do that?

    Just to get an idea:
    Imagine I have a file browser on the GUI and when I click on one file. This causes a parameters frame to be filled with a parameters form. Then, filled the parameters, I want to execute some actions on that file, based on the parameters. I want to do that in a separate working thread. How can that thread Know what file to process and the parameters to use?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: GUI thread and Working thread comunication

    Yes, you can emit signals both ways. Just emit a signal to an object that lives in the worker thread.

  3. The following user says thank you to wysota for this useful post:

    FasTTo (13th September 2007)

  4. #3
    Join Date
    Nov 2006
    Posts
    86
    Thanks
    6
    Thanked 14 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: GUI thread and Working thread comunication

    Well, If you are creating the working thread once you know the parameters, then just pass the parameters to the thread when you create it. So your pseudo code could be like:

    <user clicks on a file>
    Gui thread makes a file properties pane
    gui thread looks at the file to see what properties it has
    <at this point you know what file and what properties it has>
    gui thread creates a worker thread and passes in a pointer to some info that contains details about what file and properties to work on.

    Paul

  5. The following user says thank you to thomaspu for this useful post:

    FasTTo (13th September 2007)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.