[Qt-interest] Basic QThread question
Phil
phillor at telstra.com
Tue Apr 27 09:14:25 CEST 2010
Thank you for reading this.
This is the basic situation.
My main class polls a hardware device every second which returns an int
value. The hardware device is slow and so the GUI is blocked for about half a
second each second.
To overcome the blocking, the hardware class is now sub-classed from
QThread and has a function similar to the following as well as a run()
function:
int hardware::getValue()
{
return x;
}
I can see that the run() function starts each second and then stops as it
should.
My question is, how do I have run() return the value x? Should I periodically
call run() from the main class (hardware.run()) which in turn calls getValue()
which in turn emits a signal to return x to the main class via the signal/slot
mechanism?
It seems a bit convoluted, perhaps there is a more practical method?
--
Regards,
Phil
More information about the Qt-interest-old
mailing list