PDA

View Full Version : QNetworkAccessManager and https. help!



valerino
22nd July 2010, 14:13
Hi, i know this topic has already been discussed in other forums. I've found some solutions, and i tried everything with no luck.

the problem is depicted here :
http://old.nabble.com/QWebView-and-https-td28519684.html

simply put, using QWebView with https results in the SslErrors slot never been called.

can someone point me in the right direction ? As you see, this is a simple source to better illustrate the problem. no certificates are loaded, so it should call the SslErrors in any way. but it doesnt.

regards, valerio



MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
connect (ui->pushButton,SIGNAL(clicked()),this,SLOT(onGoClick() ));
m_mgr = new QNetworkAccessManager(this);
}

MainWindow::~MainWindow()
{
delete ui;
delete m_mgr;
}

void MainWindow::onSslErrors(QNetworkReply *reply, const QList<QSslError> &errors)
{
// report ssl errors
foreach (QSslError error, errors)
{
qDebug() << "--> onSslErrors" << error.errorString();
}
reply->ignoreSslErrors();
}

void MainWindow::onGoClick()
{
if (ui->lineEdit->text().isEmpty())
return;

QUrl url (ui->lineEdit->text());
QWebPage* page = new QWebPage(m_mgr);
page->setNetworkAccessManager(m_mgr);
connect (page->networkAccessManager(),SIGNAL(sslErrors(QNetworkRe ply*, QList<QSslError>)),this,SLOT(onSslErrors(QNetworkReply*, QList<QSslError>)));
ui->webView->setPage(page);
page->mainFrame()->load(url);
}