[PyQt] QWebHistory load/save

David Bronke whitelynx at gmail.com
Mon Mar 15 18:54:17 GMT 2010


I had already done those 2 changes in my version of his script; I've
attached my modified version. With this version, I still get a zero-length
file.



On Mon, Mar 15, 2010 at 13:48, Phil Thompson <phil at riverbankcomputing.com>wrote:

> On Mon, 15 Mar 2010 13:24:21 -0500, Russell Valentine
> <russ at coldstonelabs.org> wrote:
> > Yes, my fault. How about this one:
> > It will be a while before I can try it. In the process up upgrading to
> > Qt4.6
> > ===========
> >
> > from PyQt4 import QtCore, QtGui, QtWebKit
> > import sys
> >
> >
> > class MainWindow(QtGui.QMainWindow):
> >      def __init__(self):
> >          super(QtGui.QMainWindow, self).__init__()
> >          self.webview=QtWebKit.QWebView()
> >          self.setCentralWidget(self.webview)
> >      def go(self):
> >          self.webview.load(QtCore.QUrl("http://python.org"))
> >          f=QtCore.QFile("history.file")
>
>            f.open(QtCore.QIODevice.WriteOnly)
>
> >          d=QtCore.QDataStream(f)
> >          d << (self.webview.history())
> >
> >
> >
> > if __name__ == "__main__":
> >      app = QtGui.QApplication(sys.argv)
> >      window = MainWindow()
> >      window.show()
> >      QtCore.QTimer.singleShot(1000, window.go)
> >      sys.exit(app.exec_())
>
> With this I get a 12 byte file - not an empty file.
>
> The history isn't updated until the load is finished. If you connect the
> loadFinished() signal to a slot that writes the history I get a 254 byte
> file.
>
> Phil
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20100315/cbf6502f/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: qwebhistory-test.py
Type: application/octet-stream
Size: 488 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20100315/cbf6502f/attachment.obj>


More information about the PyQt mailing list