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

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 445 of file qmainwindow.cpp.

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

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

Here is the caller graph for this function:

Generated by  Doxygen 1.6.0   Back to index