QMenuBar in QWidget windows
Solved
General and Desktop
-
Good afternoon.
Quick question: is it possible to have QMenuBar on something else than QMainWindow?
I tried to get the result but failed.
I created the QWidget base empty window and added to the constructor:ui->setupUi(this); QMenuBar *menuBar = new QMenuBar(this); QMenu *browser = new QMenu(menuBar); QAction *closeAction = new QAction("Close",browser); browser->addAction(closeAction); menuBar->insertMenu(nullptr,browser);
When I do show() and raise() this widget window it does get shown but without the menu bar... I am working on Qt 5.15.2.
-
@JonB I don't know how this didn't pop up in my google search before I asked. It works, of course.
The funny thing is that I considered using the layout (since I am prototyping now and finding out which solutions might be usable) - layouts would be used at the end anyway of course - but dropped the idea thinking "why bother for the prototype".
Thank you!