Results 1 to 4 of 4

Thread: updating the statusbar according to the menubar using QMenuBar::hovered()?

  1. #1
    Join Date
    Sep 2011
    Posts
    24
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Exclamation 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:

    Qt Code:
    1. connect(Ui_MainWindow::menuBar,SIGNAL(hovered(QAction*)),this,SLOT(updateBar(QAction*)));
    To copy to clipboard, switch view to plain text mode 

    and
    Qt Code:
    1. void MainWindow::updateBar(QAction * action)
    2. {
    3. if(action != NULL)
    4. {
    5. statusBar()->showMessage(action->toolTip(),5000);
    6. }
    7.  
    8. }
    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!

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: updating the statusbar according to the menubar using QMenuBar::hovered()?

    Below me is a better solution!
    Last edited by high_flyer; 28th September 2011 at 16:06.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Oct 2010
    Location
    Berlin, Germany
    Posts
    358
    Thanks
    18
    Thanked 68 Times in 66 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default 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

  4. The following user says thank you to FelixB for this useful post:

    furskytl (29th September 2011)

  5. #4
    Join Date
    Sep 2011
    Posts
    24
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: updating the statusbar according to the menubar using QMenuBar::hovered()?

    Oh,yes!I am really stupid!!!Too ignorant!

Similar Threads

  1. QGraphicsPathItem changing state when hovered
    By Vit Stepanek in forum Qt Programming
    Replies: 4
    Last Post: 8th December 2010, 16:44
  2. How to identify drag hovered items in itemviews?
    By happy11wl in forum Qt Programming
    Replies: 2
    Last Post: 1st June 2010, 12:08
  3. QMouseEvent - prevent on statusbar/menubar
    By DavidY in forum Newbie
    Replies: 1
    Last Post: 20th December 2009, 07:43
  4. Set a ToolButton Hovered
    By vajindarladdad in forum Newbie
    Replies: 7
    Last Post: 1st September 2009, 12:33
  5. statusbar
    By bhogasena in forum Qt Programming
    Replies: 7
    Last Post: 3rd February 2009, 14:54

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.