[PyQt] Issue of QWebPage.extension

Detlev Offenbach detlev at die-offenbachs.de
Mon Jan 7 14:10:09 GMT 2013


Hello,

you have to cast it explicitly using sip.cast.

Here is a code extract of the eric5 web browser.

        if extension == QWebPage.ErrorPageExtension:
            info = sip.cast(option, QWebPage.ErrorPageExtensionOption)
            errorPage = sip.cast(output, QWebPage.ErrorPageExtensionReturn)

Regards,
Detlev

On Monday 07 January 2013, 21:55:27 Flya Flyaa wrote:

I want to get page detailed error message this 
way: http://stackoverflow.com/questions/7279046/how-to-get-detailed-error-
message-when-qtwebkit-fails-to-load-a-page


This need  reimplement  QWebPage.extension 
http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qwebpage.html#extension, 
and get detail from the second argument ExtensionOption.


Code like this: 


    def extension(self, extension, info = None, errorPage = None):
        if extension == QtWebKit.QWebPage.ErrorPageExtension:
            content = u"<html><head><title>Failed loading 
page</title></head><body><h1>Failed loading page (%s)</h1><h2>%s</h2> 
</body></html>" % (info.errorString, info.url.toString())
            errorPage.content = QtCore.QByteArray(content.encode('utf-8'))
            gdata.log(u'Warn: Failed loading [%s] (%s)!' % (info.errorString, 
info.url.toString() ))
            return True
        return True


When extension == QtWebKit.QWebPage.ErrorPageExtension, the second argument 
should be QWebPage.ErrorPageExtensionOption, but it always 
be QWebPage.ExtensionOption, and can't get the detailed error message from it.


PySide has this problem in earlier versions, it be fixed later with test 
case http://pyside.sourcearchive.com/documentation/1.0.1-1/bug__694_8py_source.html 
. Hope PyQt can fix it. 


-- 
Detlev Offenbach
detlev at die-offenbachs.de
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20130107/9f2a99ae/attachment-0001.html>


More information about the PyQt mailing list