PDA

View Full Version : Thread and GUI control



foxyproxy
17th March 2008, 19:03
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:


#include <iostream>
#include ...

Test::Test()
{
cout << "Constructor called" << endl;
}

Test::method()
{
lib->doSomething();
data = lib->getData();
... // use data returned from the method and update gui
}

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 ;)

wysota
17th March 2008, 20:33
Does "lib" have any signals? Is it a Qt based class?

foxyproxy
17th March 2008, 20:47
No, its not Qt based but it uses pthread

wysota
17th March 2008, 20:52
There is not much you can do then, unless the library gives some notification when it's finished.