[Qt-interest] QListWidget increasingly slow

Josiah Bryan jbryan at productiveconcepts.com
Wed Nov 11 01:10:59 CET 2009



Bob Hood wrote:
> Josiah Bryan wrote:
>> Have you thought about using a QTextEdit and using html to colorize 
>> the lines and add icons? Use the QTextCursor interface to append html 
>> to the document.
>>
>> Line with icon html:
>>
>> <div style='background:red;color:white'><img src=':/data/icon.png'> 
>> Hello World!</div>
>>
> 
> Yes, indeed.  Using QTextEdit with its ensureCursorVisible() method 
> solves the backup problem.  Text flows without trouble from start to end 
> (3,000+ lines) while the output is generated.  Thanks for the 
> suggestion, Josi!
> 
> I have a minor issue, however.  I'm trying to insertHtml() on the 
> QTextEdit, but all I'm getting is the text itself without any of the 
> formatting.  For example, the HTML you provided (above) just shows up as 
> "Hello World!" in black on the white background.  My icon is not being 
> displayed, and the color selections appear to be ignored.  Is there some 
> kind of additional setup I need to perform on the QTextEdit to get it to 
> properly process HTML text?
> 

Here's some actual HTML generated by a QTextEdit from plain text:

<!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:'Sans 
Serif'; font-size:9pt; font-weight:400; font-style:normal;"><p 
align="left" style="margin-top:0px; margin-bottom:0px; margin-left:0px; 
margin-right:0px; -qt-block-indent:0; text-indent:0px; background:red; 
color:white"><span style=" font-family:'Sans Serif'; 
color:white;background:red;font-size:9pt; font-weight:400;">Chorus 
1</span></p></body></html>

Does that render the word 'Chorus 1' white with red background?

I must confess, I am by far no expert on using HTML in Qt - for one, 
I've never used images in a text edit, though it should work - the docs 
say they do and one of the examples even shows how to insert images 
inline IIRC.

-josiah





More information about the Qt-interest-old mailing list