6.0.0-rc4Source

QMdiSubWindow Class

The QMdiSubWindow class is a window inside a QMdiArea. More…

Header#include <QMdiSubWindow>
CMaketarget_link_libraries(app PRIVATE Nt::Widgets)
ModuleNt Widgets C++ Classes
InheritsQWidget

List of all members, including inherited members

Public Types

Public Functions

QMdiSubWindow(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags())
~QMdiSubWindow()
voidsetWidget(QWidget *widget)
QWidget *widget() const
QMdiArea *mdiArea() const
voidsetOption(SubWindowOption option, bool on = true)
booltestOption(SubWindowOption option) const
Qt::WindowStateswindowState() const
boolisMaximized() const
boolisMinimized() const

Reimplemented Public Functions

Public Slots

Signals

Reimplemented Protected Functions

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>.

ConstantDescription
QMdiSubWindow::AllowOutsideAreaHorizontallyThe sub-window may be moved out of the area at the sides.
QMdiSubWindow::AllowOutsideAreaVerticallyThe sub-window may be moved out of the area at the top and the bottom.
QMdiSubWindow::RubberBandResizeResizing shows a rubber band.
QMdiSubWindow::RubberBandMoveMoving 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

[explicit] 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.

[override] QMdiSubWindow::~QMdiSubWindow()

Destroys the sub-window and its widget; the area forgets it.

[signal] void QMdiSubWindow::aboutToActivate()

This signal is emitted just before the sub-window becomes the active one.

[override, protected] void QMdiSubWindow::changeEvent(QEvent *event)

Reimplements QWidget::changeEvent().

[override, protected] 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.

[override, protected] 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.

[override] QSize QMdiSubWindow::minimumSizeHint() const

Reimplements QWidget::minimumSizeHint().

[override, protected] void QMdiSubWindow::mouseDoubleClickEvent(QMouseEvent *event)

Reimplements QWidget::mouseDoubleClickEvent().

Double-clicking the title bar maximizes the sub-window, or makes it normal again.

[override, protected] void QMdiSubWindow::mouseMoveEvent(QMouseEvent *event)

Reimplements QWidget::mouseMoveEvent().

[override, protected] 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.

[override, protected] void QMdiSubWindow::mouseReleaseEvent(QMouseEvent *event)

Reimplements QWidget::mouseReleaseEvent().

[override, protected] void QMdiSubWindow::paintEvent(QPaintEvent *event)

Reimplements QWidget::paintEvent().

[override, protected] 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().

[slot] void QMdiSubWindow::showMaximized()

Maximizes the sub-window: it fills its area, and follows the size of the area.

See also showNormal().

[slot] void QMdiSubWindow::showMinimized()

Minimizes the sub-window to its title bar.

See also showNormal().

[slot] void QMdiSubWindow::showNormal()

Makes the sub-window normal again, with the geometry it had before it was maximized or minimized.

[override] 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.

[signal] 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.