As you've said yourself there are quite a number of ways to do that.
One approach that i find rather elegant myself is the request handler pattern used for example by the QML API of WebEngineView.
The C++ side emits a signal that transports a request context, which is then used by the QML side to communicate the result back.
See for example http://doc.qt.io/qt-5/qml-qtwebengin...quested-signal
If you know or require that the QML side uses a modal dialog and thus a nested event loop, then you can retrieve the user's input right after the emit returns.
RequestContext context;
emit requestDialog(&context);
// continue in "linear" workflow
RequestContext context;
emit requestDialog(&context);
// continue in "linear" workflow
To copy to clipboard, switch view to plain text mode
If you want to handle the nested event loop on the C++ side, it will look more like this:
RequestContext context;
connect(&context, &RequestContext::done, &loop, &QEventLoop::quit);
emit requestDialog(&context);
// check if dialog has not already been
if (!context.isDone() {
loop.exec();
}
// continue in "linear" workflow
RequestContext context;
QEventLoop loop;
connect(&context, &RequestContext::done, &loop, &QEventLoop::quit);
emit requestDialog(&context);
// check if dialog has not already been
if (!context.isDone() {
loop.exec();
}
// continue in "linear" workflow
To copy to clipboard, switch view to plain text mode
Cheers,
_
Bookmarks