Currently I have QMenuBar with three QActions and it looks like this:
but I would like to get this (get some QActions right-aligned):
Is there a way to do this?
Well one possible solution is here. But it involves implementing your own style (QStyle as I recall). However here is a snippet that I have just tried on mainwindow class:
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow) {
ui->setupUi(this);
QMenuBar *barLeft = new QMenuBar;
QMenuBar *barRight = new QMenuBar;
barLeft->addAction("Foo Left 1");
barLeft->addAction("Foo Left 2");
barRight->addAction("Foo Left 1");
barRight->addAction("Foo Left 2");
QHBoxLayout *mainMenuLayout = new QHBoxLayout;
mainMenuLayout->addWidget(barLeft);
mainMenuLayout->addWidget(barRight);
mainMenuLayout->setAlignment(barLeft, Qt::AlignLeft);
mainMenuLayout->setAlignment(barRight, Qt::AlignRight);
QWidget *central = new QWidget;
central->setLayout(mainMenuLayout);
setCentralWidget(central);
}
This should be suitable.