[Moved] new to Qt development
-
Qt provides signals and slots to send messages between objects. You might have a more easy live if you switch to QThread. I'm not 100% sure if it's possible to use signals/slots with native threads (be sure to force the use of queued connections in this case!)
It is very recommended to read pepps excellent article on "Threads, Events and QObjects":http://developer.qt.nokia.com/wiki/Threads_Events_QObjects in the wiki. It will save you on stepping into common pitfalls using Qt and threads.
-
Can anyone direct me to sample code showing Qt sending messages to native threads?
-
I'm not so sure about that. I think you can just spin a QEventLoop from any thread, QThread or not. Sure, QThread has it build in, but I don't think there is much magic involved there. Once you have a running eventloop, you can use slots in the thread, right?
I am not saying I'd use this on new code. But if you already have existing threading code that you want to bolt this on to, it should not be impossible to do so.
-
[quote author="Andre" date="1317547623"]I'm not so sure about that. I think you can just spin a QEventLoop from any thread, QThread or not. Sure, QThread has it build in, but I don't think there is much magic involved there. Once you have a running eventloop, you can use slots in the thread, right?[/quote]
Yes, it should be that way. If a QObject class is created inside a thread that is not a QThread (like the main thread) a pseudo QZhread object is created and it works.