dev
dev

Reputation: 2200

QTableView mouse pointer show/hide issue with tableview scrollbar

I am using QTableView and I want to hide mouse pointer on table cells and mouse pointer should be visible on header and scrollbar, and for that I am using mouseEnter and mouseLeave event and mouse movement to show/hide mouse pointer.

But the problem is while moving mouse pointer from table data cells to outside the table, when mouse pointer reaches the scrollbar, it is not visible as I am not getting mouseLeave event on table while mouse pointer is on scrollbar and also that time no mouse move event in QTableView.

Can anyone please help to achieve mouse pointer hiding on table cells only and should be visible on header and on scrollbar?

Upvotes: 2

Views: 690

Answers (1)

Dmitriy
Dmitriy

Reputation: 5497

QTableView is a compound widget, it inherits from QAbstractScrollArea which has a QScrollBar widget in it. All you need is to subclass QScrollBar and reimplement mouseEnter and mouseLeave for it, as you've done for QTableView. After that you call this: QTableView::setVerticalScrollBar ( QScrollBar * scrollBar );

e.g.

class MyScroll : public QScrollBar {
// ...
}

my_table_view->setVerticalScrollBar( new MyScroll(my_table_view) );

Upvotes: 1

Related Questions