[Qt-interest] Using QTextEdit in QItemDelegate

Wilhelm wilhelm.meier at fh-kl.de
Thu Sep 30 16:54:13 CEST 2010


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);
    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