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. [SOLVED] Add QAction into QMenuBar in Designer

[SOLVED] Add QAction into QMenuBar in Designer

Scheduled Pinned Locked Moved Unsolved General and Desktop
qmenubarqactionqtdesigner
5 Posts 2 Posters 7.6k Views
  • 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.
  • M Offline
    M Offline
    matobodo
    wrote on 26 Jun 2016, 17:24 last edited by matobodo
    #1

    Is it possible to add QAction into QMenuBar in the Designer? I haven't found any way to do it. The only way I know is to write this code but I want to do it in the designer:

        QAction *action = new QAction("My action");
        ui->menuBar->addAction(action);
    
    1 Reply Last reply
    0
    • C Offline
      C Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on 26 Jun 2016, 18:09 last edited by Chris Kawa
      #2

      The designer only supports menu bars on a QMainWindow, so if you're using a QDialog or a plain QWidget you're out of luck.
      If you're using a QMainWindow based widget you can just drag and drop the action from the actions panel to the menu bar.

      1 Reply Last reply
      1
      • M Offline
        M Offline
        matobodo
        wrote on 26 Jun 2016, 21:14 last edited by
        #3

        I have menu bar in the main window, but drag and drop the action is not working:
        https://www.youtube.com/watch?v=ujmShlPqhMs

        1 Reply Last reply
        0
        • C Offline
          C Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on 26 Jun 2016, 21:30 last edited by
          #4

          Ah, ok, I misunderstood. You can't do that using the designer indeed. I can only speculate why that is but I suspect that's because it's uncommon to have an action on a menu bar. Actions usually go on tool bars and menu bars have, well, menus.

          You can create a menu typing in the "Type here" field. You can then add action to that menu via drag&drop but you can't put an action directly on the menu bar. Just a designer limitation (one of many).

          1 Reply Last reply
          1
          • M Offline
            M Offline
            matobodo
            wrote on 26 Jun 2016, 22:19 last edited by
            #5

            Ok, thanks.

            1 Reply Last reply
            0

            4/5

            26 Jun 2016, 21:30

            • Login

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