PDA

View Full Version : How to get user-defined message?



ponponfish
17th May 2011, 13:18
I have two thread, A use PostMessage() sending one message to B.
But B can not receive user-defined event. Here I use Widget::event(),
How can I get this user-defined message?

Santosh Reddy
17th May 2011, 15:05
I don't think you can use Widgets Class in a thread, read QThread Documentation

... "Note, however, that it is not possible to use any widget classes in the thread"...

You can use plain signal-slot to communicate, lets say an object in thread A sends a signal to a slot of an object in thread B, (provided they are connected). This is possible. May be then you can pass the complete user-defined message in the signal to the slot.

wysota
17th May 2011, 15:56
If you use WinAPI for sending, you need to use WinAPI for receiving as well.

Wong
17th May 2011, 16:19
Native Windows events ? Or can try QWidget::winEvent ( MSG * message, long * result )