![]() |
CopperSpice API
1.9.2
|
List of widgets used to create the main window. More...
Classes | |
class | QAction |
Stores information about a process or command which can be added to a menu or a toolbar More... | |
class | QActionGroup |
Groups actions together More... | |
class | QDockWidget |
Widget that can be docked inside a QMainWindow or floated as a top-level window More... | |
class | QMainWindow |
QMainWindow class provides the main GUI application window More... | |
class | QMdiArea |
Area in which MDI windows are displayed More... | |
class | QMdiSubWindow |
Subwindow class for QMdiArea More... | |
class | QMenu |
Provides a menu widget for use in menu bars, context menus, and other popup menus More... | |
class | QMenuBar |
Horizontal menu bar More... | |
class | QSizeGrip |
Resize top level windows More... | |
class | QStatusBar |
Horizontal area for presenting status information More... | |
class | QToolBar |
Provides a movable panel that contains a set of controls More... | |
class | QWidgetAction |
Used to add custom widgets for classes like a QToolbar which support actions More... | |
These classes provide the components which can be used on the top level application window like menus, toolbars, and a status bar.
CopperSpice provides the following classes for managing main windows and user interface components.
In this example we will declare a new class called MyMainWIndow which inherits from QMainWindow. A menu, toolbar, and a dock widget will be added.
To add a menu to the main window first create the menu actions and then add them to the menu. The QMainWindow::menuBar() method automatically creates the menu bar the first time it is called. You can also call QMainWindow::setMenuBar() to use a custom menu bar.
Next a toolbar is created as a child of the main window.
In this example the toolbar is restricted to the top and bottom toolbar areas of the main window. It is initially placed in the top toolbar area. The actions specified by newAct
and openAct
will be displayed both on the toolbar and in the file menu.
The last step is to create a dock widget as a child of the main window and then add widgets as children of the dock widget.
In this example the dock widget can only be placed in the left and right dock areas. It is initially placed in the left dock area. The QMainWindow API allows the programmer to customize which dock widget areas occupy the four corners of the main window. The default can be changed by calling QMainWindow::setCorner().
The following diagram shows the configuration produced by the above example. The left and right dock widgets will occupy the top and bottom corners of the main window in this layout.
Once all of the main window components have been set up, the central widget is created and set by using code similar to the following code. The central widget can be any subclass of QWidget.