Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Qt Creator: Inserting a seperator into QMenu
Forum Updated to NodeBB v4.3 + New Features

Qt Creator: Inserting a seperator into QMenu

Scheduled Pinned Locked Moved Qt Creator and other tools
7 Posts 3 Posters 7.8k 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.
  • R Offline
    R Offline
    Randall
    wrote on last edited by
    #1

    I have a very complex UI with lots of dialogs and menus. Thanks to Qt Creator and Qt Designer RAD has saved me many weeks of hand coding! Does anybody know if there a way to insert a QMenu::insertSeperator into my main window menubar from within Creator or Designer? I have lots of .ui files to create all the widgets, so I would like to avoid hand coding the menus if possible. The reason I'm asking is that I'd like to get the main window's "Help" dialog aligned to the right hand side of the menu bar (like the Motif style). I had assumed that simply setting my application's style to "motif" would do the trick, but it does not. After doing some digging it looks like QMenu::insertSeperator is exactly what I want, but for the life of me I cannot figure out how to achieve this in Qt Creator/Qt Designer. Is there any way I can achieve this? Even if I have to modify the .ui xml file outside creator I'd be happy if it achieved the desired behavior of the menu bar. Any help/advice is appreciated! Thanks!

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vinb
      wrote on last edited by
      #2

      right click on the menubar in creator and you see you can insert text or a seperator.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Randall
        wrote on last edited by
        #3

        It only gives me that option if I'm actually in the sub-menu. I want to insert a separator at the top-level of the menu. I should mention that I'm using OS X as my development environment, but my target platform is Solaris. Maybe Creator in OS X doesn't give that option because it doesn't conform with the OS X style guidelines? I've tried searching for example .ui files, but they only have separators in the sub-menus. None of them show a separator on the top-level menubar itself. Do you have an example .ui file that does this?

        1 Reply Last reply
        0
        • V Offline
          V Offline
          vinb
          wrote on last edited by
          #4

          Mayby i dont understand you right?

          Do you mean that you want to have a seperation in the horizontal view of the menubar?
          If so, is suggest that u add an empty menu field to it with text like " " or " | " ?
          I could only quess why you want to do so, but if you want a menu being shown, only when certain conditions are reached then you could code it with ".hide()" and ".show()".

          1 Reply Last reply
          0
          • R Offline
            R Offline
            Randall
            wrote on last edited by
            #5

            Maybe there is a simpler way to do this. Basically all I want is for my "Help" menu to be aligned to the far-most right, and the rest of the menu to be aligned to the left like normal. The goal was to follow the motif style behavior, where the "Help" menu is always right justified.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              sigrid
              wrote on last edited by
              #6

              Does it help to not use the native menubar on the Mac and then call setStyle(new QMotifStyle()) on the menubar? See:

              http://doc.qt.nokia.com/4.7/qt.html#ApplicationAttribute-enum

              and the following "FAQ":http://developer.qt.nokia.com/faq/answer/how_can_i_draw_one_of_my_menu_items_e.g_help_to_the_right_in_the_menubar

              1 Reply Last reply
              0
              • R Offline
                R Offline
                Randall
                wrote on last edited by
                #7

                Thanks sigrid that did the trick, but I'm using creator to build the dialog so I lose the changes everytime the .ui gets compiled. I did figure out a way to get it to work by modifing the creator .ui file directly.

                was:
                @ <addaction name="menuFile"/>
                <addaction name="menu_Config"/>
                <addaction name="menu_Status"/>
                <addaction name="menu_Protocols"/>
                <addaction name="menu_Help"/>@

                is:
                @ <addaction name="menuFile"/>
                <addaction name="menu_Config"/>
                <addaction name="menu_Status"/>
                <addaction name="menu_Protocols"/>
                <addaction name="separator"/>
                <addaction name="menu_Help"/>@

                Just add the seperator in the xml right before the "Help" menu is added to the menu bar. Thanks everyone!

                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