Logo Search packages:      
Sourcecode: qt4-x11 version File versions

QMenuBar * QMainWindow::menuBar (  )  const [inherited]

Returns the menu bar for the main window. This function creates and returns an empty menu bar if the menu bar does not exist.

If you want all windows in a Mac application to share one menu bar, don't use this function to create it, because the menu bar created here will have this QMainWindow as its parent. Instead, you must create a menu bar that does not have a parent, which you can then share among all the Mac windows. Create a parent-less menu bar this way:

doc/src/snippets/code/src_gui_widgets_qmenubar.cpp 1

See also:

Definition at line 442 of file qmainwindow.cpp.

References QObject::qobject_cast().

Referenced by MainWindow::createMenu(), ImageViewer::createMenus(), QMainWindow::menuWidget(), MainWindow::setupFileMenu(), and TextEdit().

    QMenuBar *menuBar = qobject_cast<QMenuBar *>(d_func()->layout->menuBar());
    if (!menuBar) {
      QMainWindow *self = const_cast<QMainWindow *>(this);
      menuBar = new QMenuBar(self);
    return menuBar;

Generated by  Doxygen 1.6.0   Back to index