I'm using QWebView to display an HTML page that is local to my machine. My code looks something like this:
m_url = "file:///c:temp/foo.html";
connect(m_webView, SIGNAL(loadFinished(bool)), SLOT(onLoadFinished(bool)));
m_webView
->load
( QUrl(m_url
) );
.
.
.
void MyWindow::onLoadFinished(bool okay)
{
if ( ! okay )
{
QString errorMsg
( tr
("<html><body>An error occurred while trying to load %1.</body></html>").
arg(m_url
) );
m_webView->setHtml(errorMsg);
}
}
m_url = "file:///c:temp/foo.html";
connect(m_webView, SIGNAL(loadFinished(bool)), SLOT(onLoadFinished(bool)));
m_webView->load( QUrl(m_url) );
.
.
.
void MyWindow::onLoadFinished(bool okay)
{
if ( ! okay )
{
QString errorMsg( tr("<html><body>An error occurred while trying to load %1.</body></html>").arg(m_url) );
m_webView->setHtml(errorMsg);
}
}
To copy to clipboard, switch view to plain text mode
The problem is that 'okay' seems to always be true, even when:
- the file doesn't exist
- the file contains bad HTML
- the file contains no HTML
In a search of the Trolltech TaskTracker and googling, I didn't find any reports of this issue, so I'm thinking maybe there's something wrong with how I'm using QWebView. According to the docs, the boolean parameter of loadFinished() "will indicate whether the load was successful or any error occurred." Seems like at least one of the cases I listed above would elicit an error indication from loadFinished(), but that's not happening. Does anyone know if I'm doing something wrong or if this is just a bug in QWebView::loadFinished()?
Bookmarks