[Qt-interest] QTableView and delegate
Andre Somers
andre at familiesomers.nl
Mon Nov 9 11:36:50 CET 2009
Wolfgang Pausch wrote:
> Hello,
>
>
>> Delegates also work when just rendering the data. I am using that at
>> several places in my code. Just reimplement the
>> QAbstractItemDelegate::sizeHint() and QAbstractItemDelegate::paint()
>> methods. It is to be expected that the *editor* is not used for display
>> purposes... That would make for very heavy item views when you have a
>> lot of data in your view.
>>
>
> Ok. Sounds good. However, I just want to exchange the data the table should
> display, not the way how some string (5, "foo", etc.) is rendered. So, when
> reimplementing the paint method, conceptionally I would just need to call the
> usual paint method of the table, with exchanged data. But how?
>
> Can you point me to some sample code regarding this?
>
I agree with other authors that a custom (proxy) model would probably be
the best solution for you. However, overriding the paint is not that
hard either. One way is to subclass QStyledItemDelegate and reimplement
it's displayText method. That should already do it.
André
More information about the Qt-interest-old
mailing list