I have done some progresses, but have a problem retrieving the "item rect" (rW of marcel's last post); I tryed to get it with option.rect.width() but its value is zero and the application fault computing f. Here the new sizeHint:
{
QRect rect
= fontMetrics.
boundingRect(index.
data().
toString());
float f = rect.width() / option.rect.width();
int approxLineCount = int(f) + 1;
return QSize(option.
rect.
width(), approxLineCount
* fontMetrics.
height());
}
QSize TextPainter::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
{
QFontMetrics fontMetrics = option.fontMetrics;
QRect rect = fontMetrics.boundingRect(index.data().toString());
float f = rect.width() / option.rect.width();
int approxLineCount = int(f) + 1;
return QSize(option.rect.width(), approxLineCount * fontMetrics.height());
}
To copy to clipboard, switch view to plain text mode
Regards
Bookmarks