PDA

View Full Version : updating the statusbar according to the menubar using QMenuBar::hovered()?



furskytl
28th September 2011, 09:46
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(QAct ion*)),this,SLOT(updateBar(QAction*)));

and

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!

high_flyer
28th September 2011, 15:49
Below me is a better solution! :)

FelixB
28th September 2011, 15:52
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 :)

furskytl
29th September 2011, 14:52
Oh,yes!I am really stupid!!!Too ignorant!