Reputation: 53
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?
Upvotes: 4
Views: 2933
Reputation: 32635
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);
Upvotes: 3
Reputation: 1028
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"
If you are manually set it. Just using like this:
QApplication app(argc, argv);
app.setLayoutDirection(Qt::RightToLeft);
Upvotes: 0