ok.
i finally found one of your early posts on this topic which gives a sample code
{
painter->save();
doc.setHtml( index.data().toString() );
doc.setPageSize( option.rect.size());
painter->translate(option.rect.x(), option.rect.y());
doc.documentLayout()->draw(painter, context);
painter->restore();
}
void CommentDelegate::paint( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const
{
painter->save();
QTextDocument doc;
doc.setHtml( index.data().toString() );
QAbstractTextDocumentLayout::PaintContext context;
doc.setPageSize( option.rect.size());
painter->translate(option.rect.x(), option.rect.y());
doc.documentLayout()->draw(painter, context);
painter->restore();
}
To copy to clipboard, switch view to plain text mode
i used this method and it worked. But now there is another problem of obtaining
right size values to be returned from sizeHint() function.
i am reimplementing the sizeHint() method of the Delegate and for the time being, i am just returning a constant size of QSize(200,250). But of course this should be determined by the content of the item to be displayed. For large contents; some of the text are just lost behind the content of next item.
i tried QTextDocument:
ageSize() and QTextDocument::documentLayout()->documentSize() methods , after setting the content of the QTextDocument object , but it didnt worked.
any suggestions appreciated.. thanks...
Bookmarks