updating the statusbar according to the menubar using QMenuBar::hovered()?
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:
Code:
connect(Ui_MainWindow
::menuBar,
SIGNAL(hovered
(QAction*)),
this,
SLOT(updateBar
(QAction*)));
and
Code:
void MainWindow
::updateBar(QAction * action
) {
if(action != NULL)
{
statusBar()->showMessage(action->toolTip(),5000);
}
}
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!
Re: updating the statusbar according to the menubar using QMenuBar::hovered()?
Below me is a better solution! :)
Re: updating the statusbar according to the menubar using QMenuBar::hovered()?
you need to set a StatusTip to your actions. This text will be displayed automatically in the statusbar when hovering the actions in a menu :)
Re: updating the statusbar according to the menubar using QMenuBar::hovered()?
Oh,yes!I am really stupid!!!Too ignorant!