How to get network reply information using QWebEngineView
recently I'm trying to migrate my webkit codes into webengine, but I've got some problems getting the network reply information.
I tried to visit a webpage on my own server using a https link, but somehow it doesn't work. I guess there're some setting errors, but how can I get this errors?
I used the onFinished() and sslError() signals of QNetworkAccessManager before, but according to the documentation, the webengine doesn't go through QNetworkAccessManager any more.
Is there any methods in webengine instead, so that I can get the reply information?
I haven't used Qt WebEngine personally, but at a quick glance, those two signals might have the following approximate equivalents:
- QNetworkAccessManager::finished => QWebEngineView::loadFinished
- QNetworkAccessManager::sslErrors => QWebEnginePage::certificateError
Note however, that certificateError is not a signal, but a protected virtual function. I guess this gives more flexibility (it allows you to actually choose how to respond to the error), but probably requires you to sub-class QWebEnginePage to override that virtual method (perhaps to emit your own signal?), then use QWebEngineView::setPage to use an instance of your custom QWebEnginePage class.
Of course, this is all just speculation... I'm sure someone with actual Qt WebEngine experience could offer better advice. But hopefully this gives you something to look at in the meantime.
Hi @Paul-Colby ,
thx for the reply. :)
I've also noticed these two methods, but somehow can't get through with them.
The difference between the finished signal of access manager and webengine view is that , the loadFinished signal gives no concrete information about the network reply. As mentioned before, those reply information is what I need to analyze the reason of my connection failure.
The certificateError method looks very interesting, but I just couldn't trigger it...I've tried to sub-class QWebEnginePage and override this method with a simple qDebug string, but nothing happened at all. I guess there should be some other way to use this method and will look into it further.
Anyway, thanks very much for the advices.:D
With the help of you guys i could soulve it, and posted the answer here: