QItemDelegate clickable icon
I draw a text and the icon using QItemDelegate. Any ideas how can I make the icon clickable, like mouse over on specific rect to show the mouse hand and once clicked there emit some action.
Could you point me to some good direction please ?
Code:
{
if ( option.
state & QStyle::State_Selected ) painter->fillRect(option.rect, option.palette.highlight());
else if ( option.
state & QStyle::State_MouseOver ) painter->fillRect(option.rect, option.palette.highlight());
QRect iconRect
= option.
rect;
iconRect.setTop( iconRect.top() );
iconRect.setLeft( iconRect.width() );
painter
->drawPixmap
(QPoint(iconRect.
left(), iconRect.
top()), pixmap
);
QRect textRect
= option.
rect;
QString text
= qvariant_cast<QString>
(index.
data(Qt
::DisplayRole));
painter->drawText( textRect, text );
}
Re: QItemDelegate clickable icon