[PyQt] QWebHistory load/save

Russell Valentine russ at coldstonelabs.org
Mon Mar 15 18:24:21 GMT 2010


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")
         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_())




Phil Thompson wrote:
> On Mon, 15 Mar 2010 12:57:27 -0500, David Bronke <whitelynx at gmail.com>
> wrote:
>> Well, according to the Qt docs, the << and >> operators for QWebHistory
>> were
>> added in Qt 4.6, which would explain why it's just giving you
>> NotImplemented
>> under Qt 4.5.3... I'm not seeing that output here, though, and I'm still
>> getting a zero-length file. (with your test script as well)
> 
> 
> Which is what you would expect - you don't have an event loop running.
> 
> Phil
> 
>> On Mon, Mar 15, 2010 at 12:39, Russell Valentine
>> <russ at coldstonelabs.org>wrote:
>>
>>> Looks like your on to something unless I did something wrong as well. I
>>> wrote a little simple case.  Using .__lshift__ instead of "<<" just made
>>> it
>>> not have an exception but it shows as "NotImplemented" in the console.
>>>
>>> Qt: 4.5.3
>>> PyQt4: 4.7
>>> Python: 2.6.4
>>> =================
>>>
>>> from PyQt4 import QtCore, QtGui, QtWebKit
>>> import sys
>>>
>>> app = QtGui.QApplication(sys.argv)
>>>
>>> f=QtCore.QFile("history.file")
>>> d=QtCore.QDataStream(f)
>>> page=QtWebKit.QWebPage()
>>> page.mainFrame().load(QtCore.QUrl("http://python.org"))
>>>
>>> d.__lshift__(page.history())
>>>
>>>
>>>
>>>
>>> David Bronke wrote:
>>>
>>>> Sorry, I spoke to soon. Using out.__lshift__(view.page().history())
>>>> yeilds
>>>> a
>>>> zero-length file. Attached is another somewhat minimal test case; it
>>>> loads
>>>> google, wikipedia, and CNN one after the other, and when CNN is loaded,
>>>> it
>>>> saves the web view's history to a file and checks the file's length. On
>>>> my
>>>> machine, this invariably comes out to 0 bytes.
>>>>
>>>> Qt version: 4.6.1
>>>> PyQt4 version: 4.7.1-snapshot-20100120 (I couldn't get anything but the
>>>> snapshot to install correctly)
>>>> Python version: 2.6.4
>>>> OS: Arch Linux
>>>>
>>>> Should I update to the latest snapshot and see if that fixes anything?
>>>>
>>>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
> 



More information about the PyQt mailing list