Item stuck in mouseover state when the mouse leaves a QListView
-
Hi I posted this question on stackoverflow with no response so I'm going to try here.
When the mouse cursors leaves a QListview, the last item that the mouse was over is sometimes still stuck in mouse over state. This usually happens if I move the mouse to the parent widget or another QListview that is above it.
My QListView has a QStyledItemDelegate that draws the item and I check the mouse over state in the paint method in the following way :
void MyDelegate::paint( QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index ) const { if( option.state & QStyle::State_MouseOver) { // Paint in MouseOver state } else { // Paint normally } }
Then I implemented the leaveEvent in my QListView to call update so the view is updated when the mouse leave the view.
void MyListView::leaveEvent(QEvent *event) { update(); QListView::leaveEvent(event); }
This does call the paint method of the delegate on leave but doesn't change the hover state of the item last hovered over in the QListView.
Is there a way to force the delegate to repaint and the last item not be in mouse over state when the cursor leaves the listview ?
-
Hi,
You should also tell:
- Which version of Qt
- Which OS