Project

General

Profile

Qt and Wt signal/slot mechanism

Added by kbarni kbarni about 10 years ago

Hello,

I have some difficulties understanding the signal/slot mechanism in the wtwithqt example.

I'm monitoring a GPS with a QThread and I want to update the interface with the actual position.

Normally I would initialize a GPSThread somewhere in the main() function (as I need only one thread), pass a pointer of this thread to the WQApplication, and connect the position signal of the thread with the update slot of the application.

What's the correct way of communicating between a QThread and the WQApplication? (the example demonstrates only communication within the same thread)

Where should I create the QThread?

Thanks for any explications!

Regards,

kbarni


Replies (2)

RE: Qt and Wt signal/slot mechanism - Added by Wim Dumon about 10 years ago

Hello kbarni,

I don't know by heart how this should look like - it seems to me that you need some kind of event loop in your QThread for signals posted between threads to work? I don't have much experience with that. Qt uses quite a specific method for inter-thread signals.

For what you describe, I think the easiest way is to keep the Qt and Wt part of the application disconnected. If you want to update a Wt session from a Qt process, use WServer::post() to propagate the event from Qt to Wt. Then use serverpush in Wt to propagate the update to the client.

Wim.

RE: Qt and Wt signal/slot mechanism - Added by kbarni kbarni about 10 years ago

Thanks! I wasn't aware of the WServer class, but it seems this is what I'm looking for :)

    (1-2/2)