Different text block colours in QListView (QListWidget)
Is it possible to set different colours for text blocks in one list widget item in QListWidget (or any other widget not inherited from QTextDocument)?
I think its possible do this by redefining paint method in QListWidget(any other widget) but maybe there is a simpler way like using QSyntaxHighlighter in QTextDocument?
Re: Different text block colours in QListView (QListWidget)
Its possible using delegates. You need to use setItemDelegate() function and handle the coloring in delegate.
You can override drawDisplay() method of the delegate for ur rendering. And you can use syntax highlighter in your delegate :)
Re: Different text block colours in QListView (QListWidget)
But is it possible to higlight blocks of text(single characters) in cases when i cant use delegates, for example in QLabel or QLineEdit?
Re: Different text block colours in QListView (QListWidget)
Quote:
Originally Posted by
rippa
But is it possible to higlight blocks of text(single characters) in cases when i cant use delegates, for example in QLabel or QLineEdit?
QLabel supports rich text, QLineEdit doesn't.
Re: Different text block colours in QListView (QListWidget)
Quote:
Originally Posted by
rippa
But is it possible to higlight blocks of text(single characters) in cases when i cant use delegates, for example in QLabel or QLineEdit?
instead of qlineedit you can use QTextEdit if you want rich text
Re: Different text block colours in QListView (QListWidget)
So the idea is to delegate(use ditrectly) QTextDocument (QTextEdit) if its possible and use QSyntaxHighlighter with it and it is impossible without overriding paint method to highlight text blocks in objects that dont inhererit from QTextDocument?
Re: Different text block colours in QListView (QListWidget)
Thanks to all. Done it with delegating QTextEdit to my ListWidget.