[Qt-interest] Using QTextEdit in QItemDelegate

Wilhelm wilhelm.meier at fh-kl.de
Thu Sep 30 17:12:41 CEST 2010


Am 30.09.2010 16:54, schrieb Wilhelm:
> Hi all,
>
> I think this is a well known problem, but I still can't find a solution
> for it:
>
> Just for curiosty I tried to use a QTextEdit in a custom QItemDelegate
> to render html text:
>
> void Delegate::paint(QPainter *painter, const QStyleOptionViewItem
> &option, const QModelIndex &index) const {
>     QString s = index.model()->data(index, Qt::DisplayRole).toString();
>     QTextEdit te;
>     te.setHtml(s);
>     painter->save();
>     painter->translate(option.rect.x(), option.rect.y());
>     b.render(painter);
>   
sorry, must read:

    te.render(painter);


>     painter->restore();
> }
>
> This works almost, but the height of the cells is not correct.
>
> What am I doint wrong?
>
>   


-- 
Wilhelm





More information about the Qt-interest-old mailing list