Results 1 to 3 of 3

Thread: How to hide/remove a addMenu() menu

  1. #1
    Join Date
    Mar 2007
    Posts
    74
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default How to hide/remove a addMenu() menu

    Hi,

    I've added a menu and menu items using menuBar()->addMenu() and the subsequent addAction() calls. I know that calling clear() will remove the menu subitems added by addAction(), but how do I remove or hide the actual menu
    item that was added by the addMenu() call.

    I don't see any reference to this functionality.

    Thanks!

    Mark

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to hide/remove a addMenu() menu

    addMenu returns a QAction*.
    Use QMenuBar::removeAction(QAction*) to remove it.

    Regards

  3. #3
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to hide/remove a addMenu() menu

    For hiding a menu when you own its action you can call QAction::menu()->setVisible(false) or hide().

    To show it call setVisible(true) or show().

    Regards

Similar Threads

  1. Docked Widget Menu
    By Chuk in forum Qt Programming
    Replies: 6
    Last Post: 3rd July 2013, 14:12
  2. MainWindow Menu bug in Qt 4.2.3?
    By No-Nonsense in forum Qt Programming
    Replies: 4
    Last Post: 11th March 2007, 11:47
  3. Tracking separators in a menu (insertSeparator)
    By PrimeCP in forum Qt Programming
    Replies: 4
    Last Post: 25th January 2006, 18:10

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.