[Qt-interest] Basic QThread question
Sean Harmer
sean.harmer at maps-technology.com
Fri May 7 10:15:38 CEST 2010
This email contained a .zip file attachment. Raytheon does not allow email attachments that are considered likely to contain malicious code. For your protection this attachment has been removed.
If this email is from an unknown source, please simply delete this email.
If this email was expected, and it is from a known sender, you may follow the below suggested instructions to obtain these types of attachments.
+ Instruct the sender to enclose the file(s) in a ".zip" compressed file, and rename the ".zip" compressed file with a different extension, such as, ".rtnzip". Password protecting the renamed ".zip" compressed file adds an additional layer of protection. When you receive the file, please rename it with the extension ".zip".
Additional instructions and options on how to receive these attachments can be found at:
http://security.it.ray.com/antivirus/extensions.html
http://security.it.ray.com/news/2007/zipfiles.html
Should you have any questions or difficulty with these instructions, please contact the Help Desk at 877.844.4712
---
Hi Phil,
On 07/05/2010 08:38, Sean Harmer wrote:
> Hi Phil,
>
> On 07/05/2010 02:31, Phil wrote:
>> On Thu, 6 May 2010 07:40:49 pm Sean Harmer wrote:
>>> Hi,
>>>>
>>>> Yes, but the OP does seem to get the code working but still running in
>>>> the GUI thread. Based on my experience on a similar problem and
>>>> referring to the previous list entry (see link in my first reply) this
>>>> was the solution. Maybe this is not the case here, but it might be...
>>>
>>> I know what you mean, but let's wait and see if the OP posts some more
>> of
>>> his main thread code as requested. :-)
>>
>> Thank you for the replies, more food for thought.
>>
>> I fear that I may not have stated the problem clearly enough. As I see it, the
>> problem is in the original code that Sean kindly sent me. I wanted to know if
>> there is a typo in this line:
>>
>>> connect( m_workerThread->poller(), SIGNAL( value( int ) ),
>>> this, SLOT( processValue( int ) ) );
>>
>> There isn't a poller() function and if I create one then this is the result:
>
> Yes there was:
>
> DevicePoller* poller() const { return m_poller; }
>
> It simply returns a pointer to the DevicePoller object that is a child
> of the worker thread object.
>
>> "invalid use of void expression"
>
> Ah, maybe it is an ordering problem as the DevicePoller object is not
> created until the run() function is called from the worker thread's
> context. Before this, the pointer value will be 0.
>
> Bear with me for a few minutes and I will make a small application that
> works but will just generate random numbers in a worker thread using the
> above method. I'll post it to the list shortly for you, then all you
> have to do is to insert the code that talks to your device.
>
> All that is missing is waiting for the DevicePoller object to be created
> before connecting to it.
Please try the attached application. Instead of querying your device it
simply generates a random number. If you set breakpoints in the
DataProcessor::processData(int x) and DevicePoller::poll() methods then
look at the Threads debug view in creator you will see that this does
work using two threads and that the "polling" is performed in the worker
thread as expected. The main thread function simpy prints out the square
of the random number generated by the worker thread.
Hopefully this will allow you to get it working with your polling code.
Just replace the call to qrand() % 10 with your own code.
HTH,
Sean
More information about the Qt-interest-old
mailing list