Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Show/hide top-level submenu at runtime
Qt 6.11 is out! See what's new in the release blog

Show/hide top-level submenu at runtime

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 4.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    In my application, I want to dynamically show or hide top-level submenus at runtime. To do so, we use QWidget::setVisible() as QMenu is derived from QWidget after all. Unfortunately, it does not work. Our code looks like this:
    In mainwindow.h:
    @
    QMenu *helpMenu;
    QAction *actionHelpAbout;
    @

    In mainwindow.cpp:
    @
    actionHelpAbout = new QAction(tr("&About"), this);
    helpMenu = menuBar()->addMenu(tr("&Help"));
    helpMenu->addAction(actionHelpAbout);
    helpMenu->setVisible(false);
    @

    [EDIT: code formatting, please wrap in @-tags, Volker]

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      the only way I see is to disable the menu item/action or remove it from the menu or menu bar.

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        [quote author="Volker" date="1329084878"]the only way I see is to disable the menu item/action or remove it from the menu or menu bar.[/quote]
        Thanks, I'll try your method today.

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved