PDA

View Full Version : [WebKit] catch "page not found" error



maston
19th June 2010, 19:36
Hello.

I have WebKit Widget on MainWindow. I want to print my own message in HTML in WebKit, if page is not found.

How to do it?

Thanks.

squidge
19th June 2010, 21:28
Trap the status code of 404?

maston
21st June 2010, 12:52
Hi.

not error 404

for example in webview->load ("http://www.balblabwefweew.com") and nothing happen.

i want to show message in HTML info: page not found check url etc.

gajvik4
16th November 2010, 15:44
Hi,

Try, this

connect(webView, SIGNAL(loadFinished(bool)), this, SLOT(onLoadFinished(bool)));


void Browser::onLoadFinished(bool success){
qDebug() << success;
if (!success)
webView->page()->mainFrame()->setHtml("Page not Found");

}

In onLoadFinished function you can check the result (true, or false).
And then you can write your message.
webView->page()->mainFrame()->setHtml("Page not Found");