Qt Main Windows And Actions

Objectives

Know how to use QMainWindow
Know how to implement a menu
Be able to use tool bars and status bars
Understand the concept of Actions
Know how to use QVariant to store data in Actions
Understand the usage of scrolled areas

QMainWindow

  • Main application window.
  • It provides a framework for building an application's user interface.
  • It has its own layout to which you can add QToolBars, QDockWidgets, a QMenuBar and a QStatusBar.
mainwindowlayout.png
  • A main window without a central widget is not supported.

QMenu

  • The QMenu class provides a menu widget for use in menu bars, context menus, and other popup menus.
  • Use QMenuBar::addMenu() to insert a menu into a menu bar.

QToolBar

  • The QToolBar class provides a movable panel that contains a set of controls.
  • Use QMainWindow::addToolBar() to add a toolbar.

QStatusBar

  • The QStatusBar class provides a horizontal bar suitable for presenting status information.
  • QMainWindow::statusBar() returns a pointer to the status bar.

QAction

  • The QAction class provides an abstract user interface action that can be inserted into widgets.
  • The same action can be used in a menu, toolbar buttons, and keyboard shortcuts.

Qt QAction Example

QVariant

  • The QVariant class acts like a union for the most common Qt data types.
  • A QVariant object holds a single value of a single type() at a time.

Qt QVariant Example

QScrollArea

  • The QScrollArea class provides a scrolling view onto another widget.

Qt QScrollArea Example

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Share Alike 2.5 License.