SetPage possibly not working on QWebView in PySide?



  • When I call setPage in PySide, it does not seem to work the way I expect, but perhaps I need to call it differently.

    Here's some code that works in PyQt4, though you have to kill it externally since I don't know how to do so programmatically (as an aside, I would love to know):

    @rom sys import exit
    from PyQt4.QtGui import QApplication
    from PyQt4.QtWebKit import QWebView, QWebPage

    class testWebPage(QWebPage):
    def sayMyName(self):
    return 'testWebPage'

    app = QApplication([])
    webview = QWebView()

    twp = testWebPage()
    print type(twp)
    print twp.sayMyName()
    webview.setPage(twp)
    p = webview.page()
    print type(p)
    print p.sayMyName()

    exit(app.exec_())@

    the output is, as I expect:

    @$ python set_webpage_pyqt.py
    <class 'main.testWebPage'>
    testWebPage
    <class 'main.testWebPage'>
    testWebPage@

    but with PySide, the very similar code:

    @from sys import exit
    from PySide.QtGui import QApplication
    from PySide.QtWebKit import QWebView, QWebPage

    class testWebPage(QWebPage):
    def sayMyName(self):
    return 'testWebPage'

    app = QApplication([])
    webview = QWebView()

    twp = testWebPage()
    print type(twp)
    print twp.sayMyName()
    webview.setPage(twp)
    p = webview.page()
    print type(p)
    print p.sayMyName()

    exit(app.exec_())@

    fails, producing the output:

    @$ python set_webpage.py
    <class 'main.testWebPage'>
    testWebPage
    <type 'PySide.QtWebKit.QWebPage'>
    Traceback (most recent call last):
    File "set_webpage.py", line 18, in <module>
    print p.sayMyName()
    AttributeError: 'PySide.QtWebKit.QWebPage' object has no attribute 'sayMyName'@

    which to me indicates that setPage didn't work. So is there a bug in my thinking, in PySide, or elsewhere? Thanks in advance!

    Andy





  • Ok, thanks.



  • Fixed in commit:

    "http://qt.gitorious.org/pyside/pyside/commit/cbf12bc3a010508081d59bdac832d3e2bb9e0c2a":http://qt.gitorious.org/pyside/pyside/commit/cbf12bc3a010508081d59bdac832d3e2bb9e0c2a

    but the fix will just be on 0.4.2, because we already tagged the next version.

    [edit: fixed link / chetankjain]



  • Ah, thanks. I already filed the bug, should I close it?

    Edit: Never mind, I see that someone else closed it for me. Thanks.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.