[PyQt] problems with QTextBrowser

Dusan Zatkovsky msk.conf at seznam.cz
Tue Apr 15 14:50:51 BST 2008

Hi there.

I have problem with QTextBrowser. I am writing db app, which (basically) asks 
user for some rich text ( using dialog with QTextEdit ), then it receives 
that text as html ( doc = self.ui.textEdit.document(),  text = 
doc.toHtml() ). That html is converted to base64 and stored to database then.

On other place, it is readed from db, decoded from base64 and following code 
is called:

html = utils.decB64 ( data )	# this is my own decoding method, because i
						# am 'hacking' base64 string ( not using =+)

self.ui.textBrowser.setHtml ( html )		# textBrowser is QTextBrowser class
								# constructed by .ui file

Browser shows only "<" charracter.

Debugging the code, html is 'str' type and contains following string:

<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;">fooo</p>
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; 
margin-left:0px; margin-right:0px; -qt-block-indent:0; 

It seems to be valid html code. I have tried to convert that string to 
QString, but without success.

When I hardcoded that html string as one-line string directly to code ( 
instead of calling html = utils.decB64.... ), html was shown right.

What am I doing wrong?



More information about the PyQt mailing list