user2494298
user2494298

Reputation: 299

Creating Menu's Qt

Looking at http://qt-project.org/doc/qt-5.0/qtwidgets/mainwindows-menus.html they have a call to menuBar(), what is this and where does it come from? When I try to use the code below in Qt I get "->must point to class/struct/union/generic type" error

file = menuBar()->addMenu(tr("File"));

Upvotes: 0

Views: 236

Answers (1)

aldo
aldo

Reputation: 2987

In the example, MainWindow is a subclass of QMainWindow (see the declaration near the top)

class MainWindow : public QMainWindow

Therefore the line

fileMenu = menuBar()->addMenu(tr("&File"));

within the method

void MainWindow::createMenus()

is a reference to the menuBar() method of the base class QMainWindow.

Upvotes: 3

Related Questions