PDA

View Full Version : QItemDelegate highlight row



bmn
24th February 2016, 12:46
Hello,

I have implemented my own QItemDelegate for items in one column of a QTreeView.
Now what is missing is the code to highlight the whole row when the mouse is somewhere above the row.

The selection stops when my delegate starts and i need it to continue with the same style as before (see attachement).
11738

Anybody already tried this?


I hope somebody can help me.

Thank you in advance.

ChrisW67
25th February 2016, 20:28
it is not clear what you are asking and your picture, showing everything shaded in some way, does not help much.

bmn
26th February 2016, 10:13
Never mind,

found the solution by making sure to copy all parameters from the paint call to drawPrimitive befor doing the rest of my drawing.


void myDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const
{
...
QApplication::style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &option, painter, 0);
...
//Do my drawing
}