C++ (Qt) ... QRect rcText = style->subElementRect( QStyle::SE_ItemViewItemText, &opt, widget ); const int textMargin = style->pixelMetric(QStyle::PM_FocusFrameHMargin, 0, widget) + 1; // hak from qt rcText = rcText.adjusted( textMargin, 0, -textMargin, 0 ); // remove width padding // hak from qt int rcTextW = rcText.width(); opt.text.replace( '\n', QChar::LineSeparator ); QStringList l = opt.text.split( QChar::LineSeparator ); opt.text = ""; for( int i=0,n=l.size(); i<n; i++ ) { l[i] = opt.fontMetrics.elidedText( l[i], opt.textElideMode, rcTextW ); opt.text += l[i]; if( i<(n-1))opt.text += QChar::LineSeparator; } opt.textElideMode = Qt::ElideNone; style->drawControl(QStyle::CE_ItemViewItem, &opt, painter, widget); ...