Menu bar

Most applications hold a set of clickable(s) that reveal a list of another set of actions that expose more functionality to the user. The most popular among these are the File, Edit, and Help menus.

In Qt, menu bars occupy the very top of the window. We shall create a short program to make use of the menu bar.

Three files must be created in a newly created folder. These are as follows:

  • main.cpp
  • mainwindow.h
  • mainwindow.cpp

The main.cpp file will remain as before in terms of content. Therefore, copy the main.cpp file from the previous section. Let's examine the mainwindow.h file:

#ifndef MAINWINDOW_H#define MAINWINDOW_H#include <QMainWindow>#include <QApplication>#include <QAction>#include <QtGui>#include <QAction>#include <QMenuBar> ...

Get Getting Started with Qt 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.