Setting and getting html text in a qtextbrowser/qtextedit with pyqt4
for example if you just set
self.textedit.setHtml("<b>Bold text</b>")
htmlCheck=self.textedit.toHtml()
hmtlCheck=
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
"http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt;
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;"><span style=" font-weight:600;">Bold
text</span>
</p>
</body></html>
Why can't I just only get my setted text from the first code line back?
This, what I get back, is so bad for further editing... Imagine, I write a
bigger text in this. I'd like to select text and make it bold, or make a
list, and detect hyperlinks in real time... I don't know how to deal with
it when there is so much garbage around my code that works alone, too. And
there are afaik only the .toPlainText() and .toHtml() functions... The
hyperlink-thing is really simple, I could just setText and getPlainText
and run a regex each time over all the www.'s and http's. But I also want
a dynamic list functionality or bold, maybe, and thus cannot use
toPlainText()...
Has someone a good advise for me?
No comments:
Post a Comment