Customise border radius of QTableView row selection
-
@siya
subclassing QStyleItemDelegate should do what you want (untested though):void MyStyleItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const { bool isSelected = option.state & QStyle::State_Selected; QStyleOptionViewItem opt = option; opt.state &= ~QStyle::QStyle::State_Selected; QStyledItemDelegate::paint(painter, opt, index); if( isSelected ){ // draw rounded rect using painter } }
-
@raven-worx He wants to do this for the whole row, not for one item. I think this may be the last thing for him to do in his project.
-
@JoeCFD
still possible (and the only way i think).
It needs to be checked if its a middle index or an index on the side of the view and draw the borders accordingly -
@raven-worx Agree. That is the part missing in your previous code.
-
Hi,
You have the model index, so if it's the left most one, draw the left round corners and if it's the right most one, draw the right rounded corner.
The other option is to use one delegate for the first and last column to do the special painting. Note that this is not the correct solution if your users can reorder the columns.