1

Does Qt support interaction with the native menu bar of an arbitrary window (i. e. QWidget) on Windows and Linux?

It looks like Qt treats the menu as just another child widget to be placed on the parent window. That is, to have a menu bar , I must reserve some space for it in the window's client area. That makes no sense on Mac, with its menu on the top of the screen. On Windows, it makes little sense - the menu, as implemented by the system, is outside of the client area. Not sure what's the native model on Linux.

Seva Alekseyev
  • 59,826
  • 25
  • 160
  • 281

1 Answers1

1

Qt supports native menues on Mac and on Windows. It may seem when looking at the forms in Qt Designer, that Qt menues on Mac are non-standard, but they aren't. Qt had made a great deal to deal with menue differences between the supported platforms and they work very well.

WolfgangP
  • 3,195
  • 27
  • 37
  • Good to know. So, how do I assign or access the native menu bar of a window? setMenuBar() is only defined for QLayout and QMainWindow, not for a generic QWidget. – Seva Alekseyev Nov 28 '10 at 21:48
  • Menus are only feasible for QLayout / QMainWindow. If you need a context-sensitive menue for a widget, add a QAction via QWidget::addAction and set QWidget::setContextMenuPolicy(Qt::ActionsContextMenu). – WolfgangP Nov 28 '10 at 22:04
  • How come? Every QWidget can be a top-level window. Every top-level window can have a menu in Windows. – Seva Alekseyev Nov 29 '10 at 03:10