Setting margin for drawText
I have a custom item delegate to color tableview rows.
It works fine with one exception - the text is drawn with no margin.
The standard delegate sets a small margin to the left of the text it draws.
I have looked at the Trolls source for the standard delegate but with my limited skills, I can't see how to achieve this in my code.
This is the line that draws the text:
painter->drawText(option.rect, Qt::AlignJustify, index.data().toString());
Any ideas are appreciated....
Re: Setting margin for drawText
Change option.rect
It's a rectangle that defines the place where the text is drawn. Just shift it a few pixels.
Re: Setting margin for drawText
Thanks tbscope - it's perfect now.
Code:
QRect rect
= option.
rect;
rect = rect.adjusted(3, 0, 0, 0);
painter->drawText(rect, Qt::AlignJustify, index.data().toString());