[toc]
定位
把 QWebEngineview
发起的每个网络请求全部打印,看看是哪个请求慢:
重写 QWebEngineUrlRequestInterceptor
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| class CustomUrlRequestInterceptor : public QWebEngineUrlRequestInterceptor { public: CustomUrlRequestInterceptor(QObject* parent = nullptr) : QWebEngineUrlRequestInterceptor(parent) {}
void interceptRequest(QWebEngineUrlRequestInfo& info) override { if (info.requestUrl().host() == "www.example.com") { QUrl newUrl = info.requestUrl(); newUrl.setHost("www.newexample.com"); info.setUrl(newUrl); }
info.setHttpHeader("User-Agent", "Custom User-Agent"); LogUtils::info(info.requestUrl().toString().toStdString().c_str()); } };
|
关闭系统代理
设置关闭系统自动代理即可:
1
| QNetworkProxyFactory::setUseSystemConfiguration(false);
|