[PyKDE] QTextBrowser & QMimeSourceFactory
Phil Thompson
phil at river-bank.demon.co.uk
Mon Apr 3 22:03:20 BST 2000
Pete Ware wrote:
>
> I'm trying to use QTextBrowser but I'm not able to ever change what is
> currently being displayed. My guess is that PyQt is messing up
> reference counting. The following script demonstrates the problem.
> If you run this, you'll get a blank window. If you comment out one of
> the suggested lines, things work.
>
> Any ideas?
> Thanks,
> --pete
I've added a couple of print statements...
#! /usr/bin/env python
import qt
import sys
app = qt.QApplication (sys.argv)
main = qt.QMainWindow ()
text = qt.QTextBrowser (main)
mime_default = qt.QMimeSourceFactory ()
text.setMimeSourceFactory (mime_default)
#mime_path = qt.QStringList
('/n/gold/6/ware/Research/projects/grading/doc')
#mime_default.setFilePath (mime_path)
mime_default.setText ('help-start.html', '<b>this is a test</b>')
mime_default.setText ('test.html', '<b>test 2</b>')
#
# Comment out just one of these and it works
#
print text.mimeSourceFactory().data('test.html',text.context())
text.setSource ('help-start.html')
print text.mimeSourceFactory().data('test.html',text.context())
text.setSource ('test.html')
main.setCentralWidget (text)
app.setMainWidget (main)
main.show ()
app.exec_loop ()
The call to mimeSourceFactory().data() is what is failing inside the
second setSource(), and this failing is caused by the first setSource().
Looking at the comments in the Qt documentation for
QMimeSourceFactory::data() I'd guess that this is just the way it works
and not a PyQt problem.
Phil
More information about the PyQt
mailing list