Reputation: 2478
I want to show the corresponding page when mouse cursor hover on the tab of a QTabWidget
.
For example, when the mouse cursor hover on tab ‘page2’ here , I hope the QTabWidget
shows the corresponding page automatically instead of clicking. How to implement this feature?
Upvotes: 2
Views: 1676
Reputation: 2116
You may try using setTabToolTop function.
ui->tabWidgetHz->setTabToolTip(0,"tooltip for tab1.");
ui->tabWidgetHz->setTabToolTip(1,"tooltip for tab2.");
ui->tabWidgetHz->setTabToolTip(2,"tooltip for tab3");
Upvotes: 0
Reputation: 486
You may try adding an event filter on the QTabWidget object's QTabBar in order to trap the mouse move event. In the filter handler, use QTabBar::tabAt( QPoint ) to find which tab is below the cursor. Set up a timer when the cursor first enters a given tab, reset time when cursor leaves it. When the timer fires, switch active tabs.
Upvotes: 2