Hello,every one!I want to implement one effect in my application :when the mouse is on a certain item of the menu,the statusbar will show the toollip message accordingly,and when the mouse is out,the statusbar show nothing! I think of it like this:
connect(Ui_MainWindow
::menuBar,
SIGNAL(hovered
(QAction*)),
this,
SLOT(updateBar
(QAction*)));
connect(Ui_MainWindow::menuBar,SIGNAL(hovered(QAction*)),this,SLOT(updateBar(QAction*)));
To copy to clipboard, switch view to plain text mode
and
void MainWindow
::updateBar(QAction * action
) {
if(action != NULL)
{
statusBar()->showMessage(action->toolTip(),5000);
}
}
void MainWindow::updateBar(QAction * action)
{
if(action != NULL)
{
statusBar()->showMessage(action->toolTip(),5000);
}
}
To copy to clipboard, switch view to plain text mode
However,it doesn't work!And I happen to find that some messages flash quickly on the statusbar when I move my mouse over the menubar.I think maybe the signal hovered() is always emitting while my mouse stops on one of the actions of the menubar,right?What should I do?Thanks very much!
Bookmarks