The QEventLoop loop you created has nothing to do with the system message queue. Instead, call QCoreApplication::processEvents() :
connect(this, SIGNAL(finishedBusProcessing()), &loop, SLOT(quit())); for (size_t i = 0; i < jsResult.toList().size(); i++) { downloader_.setUrl(QUrl(SCHEDULE_SOURCE + jsResult.toList().at(0).toString())); downloader_.execute(); QCoreApplication::processEvents(); }
But it is generally better to replace the cycle with a chained pending self-calling auxiliary function that performs one iteration of the cycle per pass:
class DataManager : public <либо QObject, либо его потомок> { Q_OBJECT Q_INVOKABLE void processingHelper(QList<QVariant> list, int itemId); // ... }; void DataManager::processingHelper(QList<QVariant> list, int itemId) { if(itemId < list.size()) { downloader_.setUrl(QUrl(SCHEDULE_SOURCE + list.at(itemId ).at(0).toString())); downloader_.execute(); QMetaObject::invokeMethod( this, "processingHelper", Qt::QueuedConnection, Q_ARG(QList<QVariant>, list), Q_ARG(int, itemId + 1) ); } } // От вашего кода в основном методе остаётся только это: connect(this, SIGNAL(finishedBusProcessing()), &loop, SLOT(quit())); processingHelper(jsResult.toList(), 0);
PS: At first I wanted to pass iterators to the DataManager::processingHelper() on the processed and last elements of the list, but then I saw that even during the first asynchronous call, the main method would have time to complete its work and the list would be destroyed. It was necessary to replace the transfer of iterators to the transfer of the list itself (more precisely, its ownership) and the number of the element being processed (the list can be moved at any moment in memory, which would make the iterator incorrect).
Now about what's going on here.
First, we mark the helper method as Q_INVOKABLE so that it can be called deferred through the message queue.
Then we add Q_OBJECT to force Qt to extract and explicitly save information about this method (its name and the type of its arguments).
When we call a helper method to process the first URL, at the end of its work using QMetaObject::invokeMethod(..., Qt::QueuedConnection, ...) queuing the message request to call itself with the next URL. Since downloader_.execute() hangs without a queue of messages, it means that he also puts some messages into it, and our request will be right after them.
newBusflowing - Cerbo