← Back to team overview

mqtt-users team mailing list archive

mosquitto_loop + other toolkit event loops

 

I'm trying to use libmosquitto to incorporate messages from a subscriber into another half written app which uses the Qt framework and so already has its own event loop. Can anyone share code which shows how to combine event loops (in particular QApplication's event loop)?

So far I've tried combining them like this (adding QApplication events into mosquitto's event loop):
        while(!mosquitto_loop(mosq, -1)){
                a.processEvents(); //process other non-mosquitto events
        }

but the "other events" involve a QPainter which now complains about being invoked outside of its native PaintEvent (at least I think thats what the error is telling me).


An alternative to incorporating Qt events into the mosquitto event loop would be to incorporate mosquitto events into Qt's event loop (googling suggests either QAbstractEventDispatcher or QSocketNotifier as possibilities to do it). However that probably entails reimplementing much, or all, of the existing libmosquitto(pp) - not sure if I'm up to that ...


Does anyone have insights about this? Example code even?


chris





Follow ups