Stacking QPushButtons on the other side of the QMenuBar

I want to copy some objects QPushButtonon the other side of mine QMenuBar.

This is what my window looks like: how it looks

And this is how I want it to look (I took a picture of the image): how i want it to look

I know that in the widget style, the motifhelp menu is aligned to the right, but I stick plastique, so for me this is not a problem.

I am using Qt4.8. Any ideas?

+5
source share
2 answers

QMenuBar has a function setCornerWidgetthat sets a widget (which can include the entire layout) as a cornet widget.

+8
source

QMainWindow::setMenuWidget() . , - , (MainWindowImpl - QMainWindow):

void MainWindowImpl::setupMenubar() {
    QWidget* menuWidget = new QWidget(this);

    QGridLayout* menuWidgetLayout = new QGridLayout(menuWidget);
    menuWidget->setLayout(menuWidgetLayout);

    // Add the menu bar and all tool buttons to the widget
    menuWidgetLayout->addWidget(theMenubar, 0, 0, 1,1);
    menuWidgetLayout->addWidget(new QToolButton(), 0, 1, 1, 1);
    menuWidgetLayout->addWidget(new QToolButton(), 0, 2, 1, 1);

    // set the custom widget as the main window menu widget
    setMenuWidget(menuWidget);
}

theMenubar QMenuBar, .

+2

All Articles