QtBase
v6.3.1
|
The QMainWindow class provides a main application window.\inmodule QtWidgets. More...
#include <qmainwindow.h>
Public Types | |
enum | DockOption { AnimatedDocks = 0x01 , AllowNestedDocks = 0x02 , AllowTabbedDocks = 0x04 , ForceTabbedDocks = 0x08 , VerticalTabs = 0x10 , GroupedDragging = 0x20 } |
Public Types inherited from QWidget | |
enum | RenderFlag { DrawWindowBackground = 0x1 , DrawChildren = 0x2 , IgnoreMask = 0x4 } |
Public Types inherited from QPaintDevice | |
enum | PaintDeviceMetric { PdmWidth = 1 , PdmHeight , PdmWidthMM , PdmHeightMM , PdmNumColors , PdmDepth , PdmDpiX , PdmDpiY , PdmPhysicalDpiX , PdmPhysicalDpiY , PdmDevicePixelRatio , PdmDevicePixelRatioScaled } |
Signals | |
void | iconSizeChanged (const QSize &iconSize) |
void | toolButtonStyleChanged (Qt::ToolButtonStyle toolButtonStyle) |
Signals inherited from QWidget | |
void | windowTitleChanged (const QString &title) |
void | windowIconChanged (const QIcon &icon) |
void | windowIconTextChanged (const QString &iconText) |
void | customContextMenuRequested (const QPoint &pos) |
Signals inherited from QObject | |
void | destroyed (QObject *=nullptr) |
void | objectNameChanged (const QString &objectName, QPrivateSignal) |
Properties | |
QSize | iconSize |
size of toolbar icons in this mainwindow. More... | |
Qt::ToolButtonStyle | toolButtonStyle |
style of toolbar buttons in this mainwindow. More... | |
DockOptions | dockOptions |
the docking behavior of QMainWindow More... | |
Properties inherited from QWidget | |
bool | modal |
whether the widget is a modal widget More... | |
Qt::WindowModality | windowModality |
which windows are blocked by the modal widget More... | |
bool | enabled |
whether the widget is enabled More... | |
QRect | geometry |
the geometry of the widget relative to its parent and excluding the window frame More... | |
QRect | frameGeometry |
geometry of the widget relative to its parent including any window frame More... | |
QRect | normalGeometry |
the geometry of the widget as it will appear when shown as a normal (not maximized or full screen) top-level widget More... | |
int | x |
the x coordinate of the widget relative to its parent including any window frame More... | |
int | y |
the y coordinate of the widget relative to its parent and including any window frame More... | |
QPoint | pos |
the position of the widget within its parent widget More... | |
QSize | frameSize |
the size of the widget including any window frame More... | |
QSize | size |
the size of the widget excluding any window frame More... | |
int | width |
the width of the widget excluding any window frame More... | |
int | height |
the height of the widget excluding any window frame More... | |
QRect | rect |
the internal geometry of the widget excluding any window frame More... | |
QRect | childrenRect |
the bounding rectangle of the widget's children More... | |
QRegion | childrenRegion |
the combined region occupied by the widget's children More... | |
QSizePolicy | sizePolicy |
the default layout behavior of the widget More... | |
QSize | minimumSize |
the widget's minimum size More... | |
QSize | maximumSize |
the widget's maximum size in pixels More... | |
int | minimumWidth |
the widget's minimum width in pixels More... | |
int | minimumHeight |
the widget's minimum height in pixels More... | |
int | maximumWidth |
the widget's maximum width in pixels More... | |
int | maximumHeight |
the widget's maximum height in pixels More... | |
QSize | sizeIncrement |
the size increment of the widget More... | |
QSize | baseSize |
the base size of the widget More... | |
QPalette | palette |
the widget's palette More... | |
QFont | font |
the font currently set for the widget More... | |
QCursor | cursor |
the cursor shape for this widget More... | |
bool | mouseTracking |
whether mouse tracking is enabled for the widget More... | |
bool | tabletTracking |
whether tablet tracking is enabled for the widget More... | |
bool | isActiveWindow |
whether this widget's window is the active window More... | |
Qt::FocusPolicy | focusPolicy |
the way the widget accepts keyboard focus More... | |
bool | focus |
whether this widget (or its focus proxy) has the keyboard input focus More... | |
Qt::ContextMenuPolicy | contextMenuPolicy |
how the widget shows a context menu More... | |
bool | updatesEnabled |
whether updates are enabled More... | |
bool | visible |
whether the widget is visible More... | |
bool | minimized |
whether this widget is minimized (iconified) More... | |
bool | maximized |
whether this widget is maximized More... | |
bool | fullScreen |
whether the widget is shown in full screen mode More... | |
QSize | sizeHint |
the recommended size for the widget More... | |
QSize | minimumSizeHint |
the recommended minimum size for the widget More... | |
bool | acceptDrops |
whether drop events are enabled for this widget More... | |
QString | windowTitle |
the window title (caption) More... | |
QIcon | windowIcon |
the widget's icon More... | |
QString | windowIconText |
the text to be displayed on the icon of a minimized window More... | |
double | windowOpacity |
The level of opacity for the window. More... | |
bool | windowModified |
whether the document shown in the window has unsaved changes More... | |
QString | accessibleName |
the widget's name as seen by assistive technologies More... | |
QString | accessibleDescription |
the widget's description as seen by assistive technologies More... | |
Qt::LayoutDirection | layoutDirection |
the layout direction for this widget. More... | |
bool | autoFillBackground |
whether the widget background is filled automatically More... | |
QString | styleSheet |
the widget's style sheet More... | |
QLocale | locale |
the widget's locale More... | |
QString | windowFilePath |
the file path associated with a widget More... | |
Qt::InputMethodHints | inputMethodHints |
What input method specific hints the widget has. More... | |
Properties inherited from QObject | |
QString | objectName |
the name of this object More... | |
The QMainWindow class provides a main application window.
\inmodule QtWidgets.
Definition at line 60 of file qmainwindow.h.
This enum contains flags that specify the docking behavior of QMainWindow.
\value AnimatedDocks Identical to the \l animated property.
\value AllowNestedDocks Identical to the \l dockNestingEnabled property.
\value AllowTabbedDocks The user can drop one dock widget "on top" of another. The two widgets are stacked and a tab bar appears for selecting which one is visible.
\value ForceTabbedDocks Each dock area contains a single stack of tabbed dock widgets. In other words, dock widgets cannot be placed next to each other in a dock area. If this option is set, AllowNestedDocks has no effect.
\value VerticalTabs The two vertical dock areas on the sides of the main window show their tabs vertically. If this option is not set, all dock areas show their tabs at the bottom. Implies AllowTabbedDocks. See also \l setTabPosition().
\value GroupedDragging When dragging the titlebar of a dock, all the tabs that are tabbed with it are going to be dragged. Implies AllowTabbedDocks. Does not work well if some QDockWidgets have restrictions in which area they are allowed. (This enum value was added in Qt 5.6.)
These options only control how dock widgets may be dropped in a QMainWindow. They do not re-arrange the dock widgets to conform with the specified options. For this reason they should be set before any dock widgets are added to the main window. Exceptions to this are the AnimatedDocks and VerticalTabs options, which may be set at any time.
Enumerator | |
---|---|
AnimatedDocks | |
AllowNestedDocks | |
AllowTabbedDocks | |
ForceTabbedDocks | |
VerticalTabs | |
GroupedDragging |
Definition at line 83 of file qmainwindow.h.
|
explicit |
Constructs a QMainWindow with the given parent and the specified widget flags.
QMainWindow sets the Qt::Window flag itself, and will hence always be created as a top-level widget.
Definition at line 366 of file qmainwindow.cpp.
QMainWindow::~QMainWindow | ( | ) |
Destroys the main window.
Definition at line 376 of file qmainwindow.cpp.
QWidget * QMainWindow::centralWidget | ( | ) | const |
Returns the central widget for the main window. This function returns zero if the central widget has not been set.
Definition at line 622 of file qmainwindow.cpp.
|
overrideprotectedvirtual |
\reimp
Reimplemented from QWidget.
Reimplemented in MainWindow.
Definition at line 1414 of file qmainwindow.cpp.
QMainWindow::DockOptions QMainWindow::dockOptions | ( | ) | const |
Definition at line 440 of file qmainwindow.cpp.
|
overrideprotectedvirtual |
\reimp
Reimplemented from QWidget.
Reimplemented in Window, ScreenWatcherMainWindow, Window, Window, Window, Window, and Window.
Definition at line 1299 of file qmainwindow.cpp.
QSize QMainWindow::iconSize | ( | ) | const |
Definition at line 446 of file qmainwindow.cpp.
This signal is emitted when the size of the icons used in the window is changed. The new icon size is passed in iconSize.
You can connect this signal to other components to help maintain a consistent appearance for your application.
bool QMainWindow::restoreState | ( | const QByteArray & | state, |
int | version = 0 |
||
) |
Restores the state of this mainwindow's toolbars and dockwidgets. Also restores the corner settings too. The version number is compared with that stored in state. If they do not match, the mainwindow's state is left unchanged, and this function returns false
; otherwise, the state is restored, and this function returns true
.
To restore geometry saved using QSettings, you can use code like this:
Definition at line 1282 of file qmainwindow.cpp.
QByteArray QMainWindow::saveState | ( | int | version = 0 | ) | const |
Saves the current state of this mainwindow's toolbars and dockwidgets. This includes the corner settings which can be set with setCorner(). The version number is stored as part of the data.
The \l{QObject::objectName}{objectName} property is used to identify each QToolBar and QDockWidget. You should make sure that this property is unique for each QToolBar and QDockWidget you add to the QMainWindow
To restore the saved state, pass the return value and version number to restoreState().
To save the geometry when the window closes, you can implement a close event like this:
Definition at line 1255 of file qmainwindow.cpp.
Sets the given widget to be the main window's central widget.
Note: QMainWindow takes ownership of the widget pointer and deletes it at the appropriate time.
Definition at line 633 of file qmainwindow.cpp.
void QMainWindow::setDockOptions | ( | DockOptions | options | ) |
Definition at line 449 of file qmainwindow.cpp.
void QMainWindow::setToolButtonStyle | ( | Qt::ToolButtonStyle | toolButtonStyle | ) |
QWidget * QMainWindow::takeCentralWidget | ( | ) |
Removes the central widget from this main window.
The ownership of the removed widget is passed to the caller.
Definition at line 650 of file qmainwindow.cpp.
Qt::ToolButtonStyle QMainWindow::toolButtonStyle | ( | ) | const |
Definition at line 474 of file qmainwindow.cpp.
|
signal |
This signal is emitted when the style used for tool buttons in the window is changed. The new style is passed in toolButtonStyle.
You can connect this signal to other components to help maintain a consistent appearance for your application.
|
readwrite |
the docking behavior of QMainWindow
The default value is AnimatedDocks | AllowTabbedDocks.
Definition at line 221 of file qmainwindow.h.
|
readwrite |
size of toolbar icons in this mainwindow.
The default is the default tool bar icon size of the GUI style. Note that the icons used must be at least of this size as the icons are only scaled down.
Definition at line 221 of file qmainwindow.h.
|
readwrite |
style of toolbar buttons in this mainwindow.
To have the style of toolbuttons follow the system settings, set this property to Qt::ToolButtonFollowStyle. On Unix, the user settings from the desktop environment will be used. On other platforms, Qt::ToolButtonFollowStyle means icon only.
The default is Qt::ToolButtonIconOnly.
Definition at line 221 of file qmainwindow.h.