Results 1 to 4 of 4

Thread: Thread and GUI control

  1. #1
    Join Date
    Mar 2008
    Posts
    16
    Thanks
    3
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Thread and GUI control

    Hello, this is my frist post and I need your help

    Im doing a gui by using third-party library but I have a problem. I will do an example to be clear:

    Qt Code:
    1. #include <iostream>
    2. #include ...
    3.  
    4. Test::Test()
    5. {
    6. cout << "Constructor called" << endl;
    7. }
    8.  
    9. Test::method()
    10. {
    11. lib->doSomething();
    12. data = lib->getData();
    13. ... // use data returned from the method and update gui
    14. }
    To copy to clipboard, switch view to plain text mode 

    The problem is the method doSomething() doesn't return immedialty wot I want but it takes few secs. So when it calls getData(), data variable doesn't contain the right thing.
    I think I should implement something like qmutex or qwaitcondition to wait doSomething() method finish. Can someone explain me how to do that, please? And how does it work?

    Thank you very much

  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: Thread and GUI control

    Does "lib" have any signals? Is it a Qt based class?

  3. #3
    Join Date
    Mar 2008
    Posts
    16
    Thanks
    3
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Thread and GUI control

    No, its not Qt based but it uses pthread

  4. #4
    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: Thread and GUI control

    There is not much you can do then, unless the library gives some notification when it's finished.

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.