Two-colored cell in item view
Hi,
I want to make two-colored cell in QTableView.
I made my delegate class with the following paint method:
Code:
void BitViewDelegate
::paint(QPainter *painter,
{
QString text
= index.
model()->data
(index, Qt
::DisplayRole).
toString();
QRect myRect
= option.
rect;
myRect.setX(option.rect.x() + option.fontMetrics.width(l));
myRect.setWidth(option.rect.width() - option.fontMetrics.width(l));
painter->fillRect(myRect, Qt::green);
}
But there is a little problem. My rectangle and previous character (the one before the text.left(5) string) overlap.
It seems to me that there is a little margin between the border of the cell and default delegate.
How it can be calculated?
Or is there any other better solution how to make two-colored cells?
Re: Two-colored cell in item view
For calculating such things see QStyle::styleHint().