PDA

View Full Version : QListWidget syntax highlight



Ken_Afford
22nd January 2010, 15:05
is it possible to apply QSyntaxHighlighter to QListWidget?

I was looking at the Qt source and was planning to subclass QSyntaxHyghlighter to accept QListWidget or QListWidgetItems instead of QTextDocument and/or subclass QListWidget/QListWidgetItems that I could pass to the constructor of QSyntaxHighlight but it doesn't seem to be possible, or am I looking at the wrong places? Version 4.0 used to have a setBackgroundColor and setTextColor for QListWidget but that was replaced with stylesheet that might complicate what I'm trying to do.

Any help would be appreciated. Thanks.

aamer4yu
22nd January 2010, 16:54
is it possible to apply QSyntaxHighlighter to QListWidget?
Yes,, with delegates..
Have a look at QItemDelegate and QStyledItemDelegate. You can use a syntax highlighter in the delegate class and draw the text colored as per the highlighter