{
//QItemDelegate::drawDisplay(painter,option,rect,text);
QColor colors
[3] = {Qt
::black,Qt
::red,Qt
::blue};
QString textToDisplay
= option.
fontMetrics.
elidedText(text,Qt
::ElideNone,rect.
width());
int len = textToDisplay.length();
int x,y;
x = rect.x();
y = rect.y()+10;
for(int i=0;i<len;i++)
{
painter->setPen(colors[i%3]);
painter
->drawText
(x,y,
QString(textToDisplay
[i
]));
x += option.fontMetrics.width(textToDisplay[i]);
}
}
void XMLDelegate::drawDisplay ( QPainter * painter, const QStyleOptionViewItem & option, const QRect & rect, const QString & text ) const
{
//QItemDelegate::drawDisplay(painter,option,rect,text);
QColor colors[3] = {Qt::black,Qt::red,Qt::blue};
QColor red(Qt::red);
QColor blue(Qt::blue);
QColor black(Qt::black);
QString textToDisplay = option.fontMetrics.elidedText(text,Qt::ElideNone,rect.width());
int len = textToDisplay.length();
int x,y;
x = rect.x();
y = rect.y()+10;
for(int i=0;i<len;i++)
{
painter->setPen(colors[i%3]);
painter->drawText(x,y,QString(textToDisplay[i]));
x += option.fontMetrics.width(textToDisplay[i]);
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks