3

My menu items were added through the UI designer. I can't seem to find a proper solution. I've asked on IRC and this solution How do I set QMenu to align to the right of a toolbar? was not clear to me.

Is there a simple way to do this by accessing the UI code in the MainWindow constructor? Or any other pointers?

Community
  • 1
  • 1
k_dog345
  • 43
  • 3
  • possible duplicate of [How do I set QMenu to align to the right of a toolbar?](http://stackoverflow.com/questions/1575687/how-do-i-set-qmenu-to-align-to-the-right-of-a-toolbar) – sashoalm Feb 10 '15 at 10:58

2 Answers2

3

To add a menu to the right side of menu bar, you can add a new QMenuBar containing the desired menu as the right corner widget using setCornerWidget :

QMenuBar *bar = new QMenuBar(ui->menuBar);

QMenu *menuHelp = new QMenu("Help", bar);
bar->addMenu(menuHelp);

ui->menuBar->setCornerWidget(bar);
Nejat
  • 31,784
  • 12
  • 106
  • 138
0

If you use QtDesigner, there's a "Property Editor" which lists all property of your current selected item.

If you select a menubar, there is one "layoutDirection" property, choose "LeftToRight" or "RightToLeft"

enter image description here

If you are manually set it. Just using like this:

 QApplication app(argc, argv);
 app.setLayoutDirection(Qt::RightToLeft);
BigTailWolf
  • 1,028
  • 6
  • 17
  • 2
    This put all of my menu items on the right side. I need only my "About" menu item to be on the right.... – k_dog345 Feb 10 '15 at 14:23