Qt Creator: Inserting a seperator into QMenu
-
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!
-
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?
-
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()". -
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.
-
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
-
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!