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] QMenuBar && menu's order
Forum Updated to NodeBB v4.3 + New Features

[Solved] QMenuBar && menu's order

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 5.6k 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.
  • L Offline
    L Offline
    luca
    wrote on last edited by
    #1

    Hi all,
    I have a QMainWindow with it's menubar.
    In the mainWindow contructor I add two menus (File, help) .

    When users login in a QDialog I need to add some other menus in the menubar after the "File" menu and before the "Help" menu.

    Ho can I do without deleting and re-adding all menus?

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

      Well, you could always try QMenuBar::insertMenu()...

      1 Reply Last reply
      0
      • L Offline
        L Offline
        luca
        wrote on last edited by
        #3

        Thanks Andre,
        I didn't see insertMenu(). I was looking for addSomething(..., int pos) ... :-)

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          This is a pattern in Qt. In the Qt API, add appends at the end, and insert somewhere in the middle. Keep an eye out for it, you'll spot it everywhere it makes sense :-)

          1 Reply Last reply
          0
          • L Offline
            L Offline
            luca
            wrote on last edited by
            #5

            I'm trying
            @
            QMenuBar::insertMenu ( QAction * before, QMenu * menu )
            @

            but I don't undertand very well what is :
            @
            QAction * before
            @

            I need to insert the new menu after or before another menu in the menubar, not before an action...

            1 Reply Last reply
            0
            • G Offline
              G Offline
              goetz
              wrote on last edited by
              #6

              insertMenu() and addMenu() return a QAction pointer which can be used as the first argument. You will have to save the pointer though.

              http://www.catb.org/~esr/faqs/smart-questions.html

              1 Reply Last reply
              0
              • L Offline
                L Offline
                luca
                wrote on last edited by
                #7

                Ok, I solved inserting the "Help" menu too with insertMenu() instead of addMenu() so I get a QAction that I can use for all the menus I must insert before "Help".

                Thanks.

                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