通过覆盖 QNetworkAccessManager 的 createRequest 虚函数,您可以强制它使用特定的 ssl 协议:
MyNetworkAccessManager::MyNetworkAccessManager(
QNetworkAccessManager *oldManager, QObject *parent /*= 0*/)
: QNetworkAccessManager(parent)
{
setCache(oldManager->cache());
setCookieJar(oldManager->cookieJar());
setProxy(oldManager->proxy());
setProxyFactory(oldManager->proxyFactory());
}
QNetworkReply* MyNetworkAccessManager::createRequest(
QNetworkAccessManager::Operation op, const QNetworkRequest &req,
QIODevice *device)
{
QSslConfiguration sslConfig = req.sslConfiguration();
sslConfig.setProtocol(QSsl::SslV3);
req.setSslConfiguration(sslConfig);
return QNetworkAccessManager::createRequest(op, req, outgoingData);
}
view = new QWebView(this);
QNetworkAccessManager *oldManager = view->page()->networkAccessManager();
MyNetworkAccessManager *newManager = new MyNetworkAccessManager(oldManager, this);
view->page()->setNetworkAccessManager(newManager);