Create a new class which inherits QItemDelegate, and override:
void QItemDelegate::drawFocus ( QPainter * painter, const QStyleOptionViewItem & option, const QRect & rect ) const [virtual protected]
Renders the region within the rectangle specified by rect, indicating that it has the focus, using the given painter and style option.
At simplest possible, the implementation of drawFocus() could look something like this:
{
if (option.
state & QStyle::State_HasFocus) {
pen.setWidth(3);
painter->setPen(pen);
painter->drawRect(rect);
}
}
void GridDelegate::drawFocus(QPainter* painter, const QStyleOptionViewItem &option, const QRect &rect) const
{
if (option.state & QStyle::State_HasFocus)
{
QPen pen(Qt::black);
pen.setWidth(3);
painter->setPen(pen);
painter->drawRect(rect);
}
}
To copy to clipboard, switch view to plain text mode
Note: above code snippet is just a dummy example for you to get started. I suggest you to take a quick look at QItemDelegate sources, there you will get a neat reference from.. 
Then, for example in the constructor of Grid, you would set the item delegate to the one you created:
setItemDelegate(new GridDelegate(this));
setItemDelegate(new GridDelegate(this));
To copy to clipboard, switch view to plain text mode
Bookmarks