Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    SetPage possibly not working on QWebView in PySide?

    Language Bindings
    3
    5
    3192
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      selfpropelled last edited by

      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

      1 Reply Last reply Reply Quote 0
      • D
        danilocesar last edited by

        File a bug report at "http://bugs.openbossa.org/":http://bugs.openbossa.org/

        <a href="http://www.danilocesar.com">Danilo Cesar Lemes de Paula</a>
        Software Engineer

        1 Reply Last reply Reply Quote 0
        • S
          selfpropelled last edited by

          Ok, thanks.

          1 Reply Last reply Reply Quote 0
          • H
            hugopl last edited by

            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]

            1 Reply Last reply Reply Quote 0
            • S
              selfpropelled last edited by

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

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

              1 Reply Last reply Reply Quote 0
              • First post
                Last post