Answer call in Qt

I have a Qt / C ++ application with a normal GUI stream and network stream. The network stream uses an external library, which has its own event loop based on select (), so the network stream does not use the Qt event system.

At the moment, the network stream simply emits () s signals when various events, such as a successful connection, occur. I think this works fine, as the signal / slot mechanism correctly places the signals for the GUI stream.

Now I need the network stream to call the GUI stream to ask questions. For example, a network stream may require a GUI stream to request a dialog to request a password.

Does anyone know a suitable mechanism for this?

My best idea is to wait for a network stream using QWaitCondition after allocating an object ( emit passwordRequestedEvent(passwordRequest); ). The passwordRequest object would have a handle to a specific QWaitCondition and therefore could signal it when a decision was made ..

Is this something reasonable? or is there another option?

+4
source share
1 answer

Using signals to send messages between streams is fine, if you don’t like using the Condition Variable, then you can send signals in both directions more or less asynchronously: this may be the best option if you want to continue processing network material while you wait for an answer from the graphical interface.

+6
source

Source: https://habr.com/ru/post/1311301/


All Articles