[PyQt] problems with QTextBrowser

Dusan Zatkovsky msk.conf at seznam.cz
Wed Apr 16 10:13:50 BST 2008


I see some progress with the problem, but it is still not what i am looking 
for.

Here is my debug code:

# decode base64 data
html = utils.decB64 ( data )

print type ( html )
# prints "<type 'str'>"

print repr ( html )
# prints "'<\x00h\x00t\x00m\x00l\x00>\x00<\x00h\x00e\x00a blahblah..."
# it seems to be some unicode ( 8, 16? )

uni = unicode ( html, 'utf-8')
print repr ( uni )
# prints "u'<\x00h\x00t\x00m\x00l\x00>\x00<\x00h\x00e\x00a blahblah ..."
# no difference

ascii = uni.encode ( 'ascii' )
print 'test3', repr ( ascii )
# prints NOTHING (?!) "test3" is not printed too.
# ( maybe some chars has broke the terminal ? )

qstr = QString ( uni )
print qstr.toUtf8()
# prints	"<html><head><meta name="qrichtext" content="1" /><style
		type="text/css">p, li { white-space: pre-wrap; }</style></head>
		<body style=" font-family:'Sans Serif'; font-size:10pt; font-weight:400;
		font-style:normal;"><p style=" margin-top:0px; margin-bottom:0px;
		margin-left:0px; margin-right:0px; -qt-block-indent:0;
		text-indent:0px;">aaa</p></body></html>
		"

iw.ui.udescTextBrowser.setHtml ( qstr )
# shows "   p, li { white-space: pre-wrap; }    aaa   " in browser

iw.ui.udescTextBrowser.setHtml ( ascii )
# shows nothing in browser


iw.ui.udescTextBrowser.setHtml ( uni )
# shows "   p, li { white-space: pre-wrap; }    aaa   " in browser



--
Regards,
Dusan



More information about the PyQt mailing list