[PyKDE] QTextBrowser & QMimeSourceFactory

Pete Ware ware at cis.ohio-state.edu
Mon Apr 3 00:02:13 BST 2000

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?
#! /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
text.setSource ('help-start.html')
text.setSource ('test.html')

main.setCentralWidget (text)
app.setMainWidget (main)

main.show ()
app.exec_loop ()

More information about the PyQt mailing list