[PyQt] How do I change a mixed font format?

bluekyu bluekyu.dev at gmail.com
Tue Feb 21 04:43:09 GMT 2012


Hello. I have a problem about QTextEdit. Setting font functions of 
QTextEdit do not work as those of word processor.

I want to change mixed font formats consistently.
For example, selected text is """<p 
style="font-style:italic;">Text1</p><p>Text2</p>."""
I want to apply "underline" to the text, so I can use 
QTextEdit.setFontUnderline().
And then, the text is """<p style="font-style:italic; 
text-decoration:underline;">Text1</p><p 
style="text-decoration:underline;">Text2</p>"""

However, if I use QTextEdit.setCurrentFont for "strike out", all text is 
set to font of last cursor
as """<p style="text-decoration:line-through;">Text1</p><p 
style="text-decoration:line-through;">Text2</p>"""

setFont* functions of QTextEdit work well, but using setCurrentFont for 
unsupported function does not work as word processor.

How can I do that?


More information about the PyQt mailing list