I am not interested in DirectConnection - that is the whole idea of having the thread for.
I want to post the signals, and let the target thread execute them in its own time.
I am not interested in DirectConnection - that is the whole idea of having the thread for.
I want to post the signals, and let the target thread execute them in its own time.
Hi Dani, nice to hear from you againI hope we can drink a 3EUR worth small bottle of water some time soon
About the problem - as Jacek pointed out the problem of thread affinity causes Qt to misinterpret your intentions. HSCSocket (thread) is created with the GUI thread affinity and you then make a connection to the thread object that is handled by the GUI thread.
There are two solutions:
1. make the connection not to the thread object, but to an object created by the thread's run method
or
2. push the thread object to the thread itself, like so:
That just might workQt Code:
connect(m_hpscSocket, SIGNAL(started()), this, SLOT(onStarted())); m_hpscSocket->start(); //... void FrmPower::onStarted(){ m_hpscSocket->moveToThread(m_hpscSocket); }To copy to clipboard, switch view to plain text mode
Remember you'll lose the parent-child relation between FrmPower object and the thread object.
babu198649 (12th October 2009)
Hi Wysota and Jacek,
Yes, it will be cool to have a 3EU drink again, I wont mind if it will be a trolltech event though![]()
Ok, I think I understand now.
Hmm, I new I need to implement a queue, and I thought that if I use the thread safe signal/slots I will just let the QThread queue do the work, and all I need to do is post signals from my gui thread.
That was what I was trying to do anyhow...
But you are right, my SocketThread class it self lives in the GUI thread.
I guess I will just fall back to custom events then.
I guess that the threaded signals/slots are doing just that behind the scenes, but for me it will be less coding with custom events.
Thanks again for the first class help guys!
If you want a queue, maybe it's better to use postEvent() directly? Signals/slots won't give you any advantage here...
Yes, its exactly what I meant when I said custom events.
Thanks.
Yes, I knowI just noticed that after sending my post and added the second sentence just to make the post say something anyway
![]()
Bookmarks