S
S
Sergey Chistyakov2015-01-24 01:08:49
Qt
Sergey Chistyakov, 2015-01-24 01:08:49

How to put a QMenuBar so that it doesn't overlap the content of the widget?

I create a class inherited from QWidget, then I write in the constructor what I need in this widget, I write about QMenuBar there. I compile, it gives this: 257e9de16533487aaba6227121fb7f3f.pngThe code is this:

MainWidget::MainWidget(QWidget *parent)
    : QWidget(parent)
{
    QMenuBar *mb = new QMenuBar(this);
    QMenu *me = new QMenu("Hello people!");
    me->addAction("One option");
    me->addAction("Two option");
    mb->addMenu(me);

    // остальное - содержимое виджета
}

What could be the catch?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
tugo, 2015-01-24
@piro1107

Parent me to mb:

QMenuBar *mb = new QMenuBar(this);
QMenu *me = new QMenu(mb, "Hello people!");

Why don't you use Designer?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question