I have an application with a QMainWindow subclass which has a menubar at the top. I have a child widget which is in a dockwidget. The child widget has a QTextEdit in it. It is organized with QVBoxLayout. The problem is that I can't get the menubar to show up.

I tried this code from qmainwindow.cpp (not sure the const_cast stuff is necessary)
Qt Code:
  1. MyWidget *self = const_cast<MyWidget*>(this);
  2. mMenuBar = new QMenuBar(self);
To copy to clipboard, switch view to plain text mode 

And then:

Qt Code:
  1. QVBoxLayout *mainLayout = new QVBoxLayout;
  2. mainLayout->setMenuBar(mMenuBar);
  3. mainLayout->addWidget(mTextEdit);
To copy to clipboard, switch view to plain text mode 

But it doesn't show up.