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