[Interest] Multicolored text in a QTableView cell?

Carl Schumann schumann at fnal.gov
Wed Jun 13 23:44:35 CEST 2012


On 6/13/2012 11:51 AM, Konrad Rosenbaum wrote:
> Hi,
>
> On Wednesday 13 June 2012 17:27:20 Carl Schumann wrote:
>> Where MccModel subclassed from QAbstractTableModel.    This did not
>> work, specifically it displayed the whole long rich text string in
>> black.   How should I be doing multicolored table cells please?
> Use a custom delegate instead: derive a class from QItemDelegate and override
> the paint method to do your custom drawing. If you want to use rich text you
> can for example use QTextDocument::drawContents as a helper.
>
>
> 	Konrad
The documentation for QItemDelegate, 
http://qt-project.org/doc/qt-4.8/qitemdelegate.html#details, indicates I 
should use QStyledItemDelegate 
<http://qt-project.org/doc/qt-4.8/qstyleditemdelegate.html>:
> Detailed Description
> ....
> The QItemDelegate class is one of the Model/View Classes and is part 
> of Qt's model/view framework. Note that QStyledItemDelegate has taken 
> over the job of drawing Qt's item views. We recommend the use of 
> QStyledItemDelegate when creating new delegates.
So should I really be using QStyledItemDelegate please?

Thanks,
Carl Schumann


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120613/7c1e8c15/attachment.html>


More information about the Interest mailing list