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. How to disable and enable the menus in menu bar?

How to disable and enable the menus in menu bar?

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 16.3k 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.
  • ? This user is from outside of this forum
    ? This user is from outside of this forum
    Guest
    wrote on last edited by
    #1

    @nathan:
    how to disable and enable the menus in menu bar..
    thanks for your good response..?

    [andreyc EDIT: I moved this question from old thread (2011)]

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      imyournathan if you have a question please start new thread next time.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        andreyc
        wrote on last edited by
        #3

        @
        QMenuBar *menuBar;
        QMenu *menuFile;
        QAction *actionOpen;
        QAction *actionClose;

        menuBar = new QMenuBar(MainWindow);

        menuFile = new QMenu(menuBar);
        menuFile->setTitle("File");

        actionOpen = new QAction(MainWindow);
        actionOpen->setText("Open");

        actionClose = new QAction(MainWindow);
        actionClose->setText("Close");

        menuBar->addAction(menuFile->menuAction());
        menuFile->addAction(actionOpen);
        menuFile->addAction(actionClose);
        @

        To disable one of the items or whole "File" menu
        @
        actionOpen->setEnable(false);
        menuFile->setEnable(false);
        @

        To enable them back
        @
        actionOpen->setEnable(true);
        menuFile->setEnable(true);
        @

        S 1 Reply Last reply
        0
        • A andreyc

          @
          QMenuBar *menuBar;
          QMenu *menuFile;
          QAction *actionOpen;
          QAction *actionClose;

          menuBar = new QMenuBar(MainWindow);

          menuFile = new QMenu(menuBar);
          menuFile->setTitle("File");

          actionOpen = new QAction(MainWindow);
          actionOpen->setText("Open");

          actionClose = new QAction(MainWindow);
          actionClose->setText("Close");

          menuBar->addAction(menuFile->menuAction());
          menuFile->addAction(actionOpen);
          menuFile->addAction(actionClose);
          @

          To disable one of the items or whole "File" menu
          @
          actionOpen->setEnable(false);
          menuFile->setEnable(false);
          @

          To enable them back
          @
          actionOpen->setEnable(true);
          menuFile->setEnable(true);
          @

          S Offline
          S Offline
          sami1592
          wrote on last edited by
          #4

          @andreyc

          Approaching like this would disables the QMenu, and it's children are no longer visible. Is there is a way in which the user can see that ta QMenu is disable but still can see it's children?

          menuFile->setEnable(false);
          
          B 1 Reply Last reply
          0
          • S sami1592

            @andreyc

            Approaching like this would disables the QMenu, and it's children are no longer visible. Is there is a way in which the user can see that ta QMenu is disable but still can see it's children?

            menuFile->setEnable(false);
            
            B Offline
            B Offline
            Bagavathi
            wrote on last edited by
            #5

            @sami1592

            In the same way, You can disable all the sub menus and enable the main menu.

            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