QMdiSubWindow Class
The QMdiSubWindow class is a window inside a QMdiArea. More…
| Header | #include <QMdiSubWindow> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::Widgets) |
| Module | Nt Widgets C++ Classes |
| Inherits | QWidget |
List of all members, including inherited members
Public Types
| enum | SubWindowOption |
| typedef | SubWindowOptions |
Public Functions
| QMdiSubWindow(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags()) | |
| ~QMdiSubWindow() | |
| void | setWidget(QWidget *widget) |
| QWidget * | widget() const |
| QMdiArea * | mdiArea() const |
| void | setOption(SubWindowOption option, bool on = true) |
| bool | testOption(SubWindowOption option) const |
| Qt::WindowStates | windowState() const |
| bool | isMaximized() const |
| bool | isMinimized() const |
Reimplemented Public Functions
| QSize | sizeHint() const |
| QSize | minimumSizeHint() const |
Public Slots
| void | showMaximized() |
| void | showMinimized() |
| void | showNormal() |
Signals
| void | aboutToActivate() |
| void | windowStateChanged(Qt::WindowStates oldState, Qt::WindowStates newState) |
Reimplemented Protected Functions
| void | paintEvent(QPaintEvent *event) |
| void | resizeEvent(QResizeEvent *event) |
| void | mousePressEvent(QMouseEvent *event) |
| void | mouseMoveEvent(QMouseEvent *event) |
| void | mouseReleaseEvent(QMouseEvent *event) |
| void | mouseDoubleClickEvent(QMouseEvent *event) |
| void | closeEvent(QCloseEvent *event) |
| void | changeEvent(QEvent *event) |
| void | focusInEvent(QFocusEvent *event) |
Detailed Description
A sub-window has a title bar with the window title and buttons that minimize, maximize and close it, and a widget under it. QMdiArea::addSubWindow() makes one for a widget:
QMdiSubWindow *window = area->addSubWindow(new QPlainTextEdit);
window->setWindowTitle("Notes");
window->show();
The user moves the sub-window by its title bar and resizes it by its edges; double-clicking the title bar maximizes it or makes it normal again. A maximized sub-window fills the area and follows its size; a minimized one is only its title bar. Closing a sub-window sends a close event to its widget, and deletes the sub-window if the widget accepts it. The window title follows that of the widget.
See also QMdiArea.
Differences from Qt
The buttons show "-", "+", "=" and "x" rather than icons, and there is no system menu, no shading (showShaded()) and no keyboard moving and resizing. The sub-window options are recorded only; moving and resizing are never shown with a rubber band. showMaximized(), showMinimized() and showNormal() are functions of the sub-window, since QWidget has no window states in Nt.
Member Type Documentation
enum QMdiSubWindow::SubWindowOption
Options of a sub-window; recorded only. SubWindowOptions is a typedef for QFlags<SubWindowOption>.
| Constant | Description |
|---|---|
QMdiSubWindow::AllowOutsideAreaHorizontally | The sub-window may be moved out of the area at the sides. |
QMdiSubWindow::AllowOutsideAreaVertically | The sub-window may be moved out of the area at the top and the bottom. |
QMdiSubWindow::RubberBandResize | Resizing shows a rubber band. |
QMdiSubWindow::RubberBandMove | Moving shows a rubber band. |
typedef QMdiSubWindow::SubWindowOptions
The SubWindowOptions type is a typedef for QFlags<SubWindowOption>. It stores an OR combination of SubWindowOption values.
Member Function Documentation
QMdiSubWindow::QMdiSubWindow(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags())
Constructs an empty sub-window with the given parent and window flags; Qt::FramelessWindowHint leaves out the frame and the title bar.
QMdiSubWindow::~QMdiSubWindow()
Destroys the sub-window and its widget; the area forgets it.
void QMdiSubWindow::aboutToActivate()
This signal is emitted just before the sub-window becomes the active one.
void QMdiSubWindow::changeEvent(QEvent *event)
Reimplements QWidget::changeEvent().
void QMdiSubWindow::closeEvent(QCloseEvent *event)
Reimplements QWidget::closeEvent().
The close event goes to the widget first; if the widget accepts it, the sub-window is hidden, leaves its area and is deleted later.
void QMdiSubWindow::focusInEvent(QFocusEvent *event)
Reimplements QWidget::focusInEvent().
Getting the focus activates the sub-window.
bool QMdiSubWindow::isMaximized() const
Returns whether the sub-window is maximized.
bool QMdiSubWindow::isMinimized() const
Returns whether the sub-window is minimized.
QMdiArea * QMdiSubWindow::mdiArea() const
Returns the area that the sub-window is in, or nullptr.
QSize QMdiSubWindow::minimumSizeHint() const
Reimplements QWidget::minimumSizeHint().
void QMdiSubWindow::mouseDoubleClickEvent(QMouseEvent *event)
Reimplements QWidget::mouseDoubleClickEvent().
Double-clicking the title bar maximizes the sub-window, or makes it normal again.
void QMdiSubWindow::mouseMoveEvent(QMouseEvent *event)
Reimplements QWidget::mouseMoveEvent().
void QMdiSubWindow::mousePressEvent(QMouseEvent *event)
Reimplements QWidget::mousePressEvent().
A press activates the sub-window, and starts moving it by the title bar or resizing it by an edge.
void QMdiSubWindow::mouseReleaseEvent(QMouseEvent *event)
Reimplements QWidget::mouseReleaseEvent().
void QMdiSubWindow::paintEvent(QPaintEvent *event)
Reimplements QWidget::paintEvent().
void QMdiSubWindow::resizeEvent(QResizeEvent *event)
Reimplements QWidget::resizeEvent().
void QMdiSubWindow::setOption(SubWindowOption option, bool on = true)
Sets option if on is true, and clears it otherwise.
void QMdiSubWindow::setWidget(QWidget *widget)
Makes widget the widget of the sub-window, under the title bar. The sub-window takes it as a child; the widget it had is deleted. The window title follows that of the widget.
See also widget().
void QMdiSubWindow::showMaximized()
Maximizes the sub-window: it fills its area, and follows the size of the area.
See also showNormal().
void QMdiSubWindow::showMinimized()
Minimizes the sub-window to its title bar.
See also showNormal().
void QMdiSubWindow::showNormal()
Makes the sub-window normal again, with the geometry it had before it was maximized or minimized.
QSize QMdiSubWindow::sizeHint() const
Reimplements QWidget::sizeHint().
bool QMdiSubWindow::testOption(SubWindowOption option) const
Returns whether option is set.
QWidget * QMdiSubWindow::widget() const
Returns the widget of the sub-window, or nullptr.
Qt::WindowStates QMdiSubWindow::windowState() const
Returns the state of the sub-window: whether it is maximized, minimized or active.
void QMdiSubWindow::windowStateChanged(Qt::WindowStates oldState, Qt::WindowStates newState)
This signal is emitted when the state of the sub-window changes from oldState to newState.