Made a GET request to the site in a separate thread. But the shape for a few seconds is framed And it is completely incomprehensible why the request takes so long. A simple get request for c # can take 2–3 seconds. Immediately almost 10 seconds goes to the same request. What am I doing wrong?
link to github https://github.com/Radzhab/QTparser
#ifndef THREAD_H #define THREAD_H #include <QThread> #include <QTextEdit> #include <httphelper.h> class Worker : public QObject { Q_OBJECT QThread workerThread; HttpHelper *helper; public slots: void doWork(const QString &result) { emit resultReady(helper->GetHtml()); } signals: void resultReady(const QString &result); }; class Controller : public QObject { Q_OBJECT QThread workerThread; QTextEdit *textDesk; public: Controller(QTextEdit *txt): textDesk(txt) { Worker *worker = new Worker; worker->moveToThread(&workerThread); connect(&workerThread, SIGNAL(finished()), worker, SLOT(deleteLater())); connect(this, SIGNAL(operate(QString)), worker, SLOT(doWork(QString))); connect(worker, SIGNAL(resultReady(QString)), this, SLOT(handleResults(QString))); workerThread.start(); } ~Controller() { workerThread.quit(); workerThread.wait(); } public slots: void handleResults(const QString &str) { textDesk->append(str); } signals: void operate(const QString &); }; #endif // THREAD_H
QNetworkAccessManager
to send requests, then you do not need to send them in a separate stream, because the manager himself creates threads as needed and with a maximum number of up to six. - alexis031182 pm