QMdiSubWindow Class

The QMdiSubWindowQMdiArea 子窗口类. 更多...

头文件: #include <QMdiSubWindow>
qmake: QT += widgets
开始支持版本: Qt 4.3
基类: QWidget

公有类型

enum SubWindowOption { RubberBandResize, RubberBandMove }
flags SubWindowOptions

属性

公有函数

QMdiSubWindow(QWidget *parent = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags())
~QMdiSubWindow()
bool isShaded() const
int keyboardPageStep() const
int keyboardSingleStep() const
QMdiArea *mdiArea() const
void setKeyboardPageStep(int step)
void setKeyboardSingleStep(int step)
void setOption(SubWindowOption option, bool on = true)
void setSystemMenu(QMenu *systemMenu)
void setWidget(QWidget *widget)
QMenu *systemMenu() const
bool testOption(SubWindowOption option) const
QWidget *widget() const

重新实现的公有函数

virtual QSize minimumSizeHint() const
virtual QSize sizeHint() const

公有槽函数

void showShaded()
void showSystemMenu()
  • 19 个公有槽函数继承自 QWidget
  • 1 个公有槽函数继承自 QObject

信号

void aboutToActivate()
void windowStateChanged(Qt::WindowStates oldState, Qt::WindowStates newState)

重新实现的受保护函数

virtual void changeEvent(QEvent *changeEvent)
virtual void childEvent(QChildEvent *childEvent)
virtual void closeEvent(QCloseEvent *closeEvent)
virtual void contextMenuEvent(QContextMenuEvent *contextMenuEvent)
virtual bool event(QEvent *event)
virtual bool eventFilter(QObject *object, QEvent *event)
virtual void focusInEvent(QFocusEvent *focusInEvent)
virtual void focusOutEvent(QFocusEvent *focusOutEvent)
virtual void hideEvent(QHideEvent *hideEvent)
virtual void keyPressEvent(QKeyEvent *keyEvent)
virtual void leaveEvent(QEvent *leaveEvent)
virtual void mouseDoubleClickEvent(QMouseEvent *mouseEvent)
virtual void mouseMoveEvent(QMouseEvent *mouseEvent)
virtual void mousePressEvent(QMouseEvent *mouseEvent)
virtual void mouseReleaseEvent(QMouseEvent *mouseEvent)
virtual void moveEvent(QMoveEvent *moveEvent)
virtual void paintEvent(QPaintEvent *paintEvent)
virtual void resizeEvent(QResizeEvent *resizeEvent)
virtual void showEvent(QShowEvent *showEvent)
virtual void timerEvent(QTimerEvent *timerEvent)
  • 35 个受保护的函数继承自 QWidget
  • 9 个受保护的函数继承自 QObject
  • 1 个受保护的函数继承自 QPaintDevice

其他继承的成员

  • 1 个公有变量继承自 QObject
  • 5 个静态公有成员继承自 QWidget
  • 10 个静态公有成员继承自 QObject
  • 35 个受保护的函数继承自 QWidget
  • 9 个受保护的函数继承自 QObject
  • 1 个受保护的函数继承自 QPaintDevice
  • 1 个受保护的槽函数继承自 QWidget
  • 2 个受保护的变量继承自 QObject
  • 1 protected type inherited from QPaintDevice

详细描述

QMdiSubWindowQMdiArea 子窗口类.

QMdiSubWindow 表示 QMdiArea 的顶级窗口, 它带有标题栏, 内部widget, 窗口边框, 大小调节部件(取决于当前样式). QMdiSubWindow 有自己的布局, 它由标题栏和中心区域的widget组成.

创建 QMdiSubWindow 的常用方式是调用 QMdiArea::addSubWindow() . 你也可以先创建一个QMdiSubWindow, 再调用 setWidget() 设置内部widget.

操作QMdiSubWindow时, 你可以调用与常用顶级窗口相同的API (如., show(), hide(), showMaximized(), setWindowTitle()).

子窗口处理

QMdiSubWindow 还支持MDI特定的子窗口行为.

默认情况下, QMdiSubWindow 在MDI区域视口移动时, 每个MDI窗口都是可见的, 但是你也可以指定透明窗口移动和调整大小行为, 在这些操作期间,仅更新子窗口的轮廓. 调用 setOption() 启用此行为.

isShaded() 函数的作用是查看子窗口当前是否有阴影 (即., 窗口被折叠, 仅显示标题栏). 调用 showShaded()开启着色模式. 窗口状态改变(如., 最小化或还原)时, QMdiSubWindow 会发出 windowStateChanged() 信号. 窗口激活前, QMdiSubWindow 会发出 aboutToActivate() 信号.

键盘交互时, 窗口随键盘移动和调整大小. 你可以通过窗口的系统菜单进入此模式. keyboardSingleStepkeyboardPageStep 属性控制widget的按键事件移动或调整大小的距离. 按下shift键时, 使用页步; 否则使用单步.

你也可以使用键盘激活窗口. 同时按下control和tab键, 将激活下一个 (使用当前 WindowOrder) 子窗口. 通过按control,shift和tab, 你可以激活上一个窗口. 这相当于调用 activateNextSubWindow()activatePreviousSubWindow(). 注意: 这些快捷键覆盖全局快捷键, 但不覆盖 QMdiArea快捷键.

参见 QMdiArea.

成员类型

enum QMdiSubWindow::SubWindowOption
flags QMdiSubWindow::SubWindowOptions

This enum describes options that customize the behavior of QMdiSubWindow.

ConstantValueDescription
QMdiSubWindow::RubberBandResize0x4If you enable this option, a rubber band control is used to represent the subwindow's outline, and the user resizes this instead of the subwindow itself. As a result, the subwindow maintains its original position and size until the resize operation has been completed, at which time it will receive a single QResizeEvent. By default, this option is disabled.
QMdiSubWindow::RubberBandMove0x8If you enable this option, a rubber band control is used to represent the subwindow's outline, and the user moves this instead of the subwindow itself. As a result, the subwindow remains in its original position until the move operation has completed, at which time a QMoveEvent is sent to the window. By default, this option is disabled.

The SubWindowOptions type is a typedef for QFlags<SubWindowOption>. It stores an OR combination of SubWindowOption values.

属性

keyboardPageStep : int

sets how far a widget should move or resize when using the keyboard page keys.

When in keyboard-interactive mode, you can use the arrow and page keys to either move or resize the window. This property controls the page keys. The common way to enter keyboard interactive mode is to enter the subwindow menu, and select either "resize" or "move".

The default keyboard page step value is 20 pixels.

访问函数:

int keyboardPageStep() const
void setKeyboardPageStep(int step)

参见 keyboardSingleStep.

keyboardSingleStep : int

sets how far a widget should move or resize when using the keyboard arrow keys.

When in keyboard-interactive mode, you can use the arrow and page keys to either move or resize the window. This property controls the arrow keys. The common way to enter keyboard interactive mode is to enter the subwindow menu, and select either "resize" or "move".

The default keyboard single step value is 5 pixels.

访问函数:

int keyboardSingleStep() const
void setKeyboardSingleStep(int step)

参见 keyboardPageStep.

成员函数

QMdiSubWindow::QMdiSubWindow(QWidget *parent = Q_NULLPTR, Qt::WindowFlags flags = Qt::WindowFlags())

Constructs a new QMdiSubWindow widget. The parent and flags arguments are passed to QWidget's constructor.

Instead of using addSubWindow(), it is also simply possible to use setParent() when you add the subwindow to a QMdiArea.

Note that only QMdiSubWindows can be set as children of QMdiArea; you cannot, for instance, write:


  //bad code
  QMdiArea mdiArea;
  QTextEdit editor(&mdiArea); // invalid child widget

参见 QMdiArea::addSubWindow().

QMdiSubWindow::~QMdiSubWindow()

Destroys the subwindow.

参见 QMdiArea::removeSubWindow().

[signal] void QMdiSubWindow::aboutToActivate()

QMdiSubWindow emits this signal immediately before it is activated. After the subwindow has been activated, the QMdiArea that manages the subwindow will also emit the subWindowActivated() signal.

参见 QMdiArea::subWindowActivated().

[virtual protected] void QMdiSubWindow::changeEvent(QEvent *changeEvent)

重新实现 QWidget::changeEvent().

[virtual protected] void QMdiSubWindow::childEvent(QChildEvent *childEvent)

重新实现 QObject::childEvent().

[virtual protected] void QMdiSubWindow::closeEvent(QCloseEvent *closeEvent)

重新实现 QWidget::closeEvent().

[virtual protected] void QMdiSubWindow::contextMenuEvent(QContextMenuEvent *contextMenuEvent)

重新实现 QWidget::contextMenuEvent().

[virtual protected] bool QMdiSubWindow::event(QEvent *event)

重新实现 QObject::event().

[virtual protected] bool QMdiSubWindow::eventFilter(QObject *object, QEvent *event)

重新实现 QObject::eventFilter().

[virtual protected] void QMdiSubWindow::focusInEvent(QFocusEvent *focusInEvent)

重新实现 QWidget::focusInEvent().

[virtual protected] void QMdiSubWindow::focusOutEvent(QFocusEvent *focusOutEvent)

重新实现 QWidget::focusOutEvent().

[virtual protected] void QMdiSubWindow::hideEvent(QHideEvent *hideEvent)

重新实现 QWidget::hideEvent().

bool QMdiSubWindow::isShaded() const

Returns true if this window is shaded; otherwise returns false.

A window is shaded if it is collapsed so that only the title bar is visible.

[virtual protected] void QMdiSubWindow::keyPressEvent(QKeyEvent *keyEvent)

重新实现 QWidget::keyPressEvent().

[virtual protected] void QMdiSubWindow::leaveEvent(QEvent *leaveEvent)

重新实现 QWidget::leaveEvent().

QMdiArea *QMdiSubWindow::mdiArea() const

Returns the area containing this sub-window, or 0 if there is none.

This function was introduced in Qt 4.4.

参见 QMdiArea::addSubWindow().

[virtual] QSize QMdiSubWindow::minimumSizeHint() const

重新实现 QWidget::minimumSizeHint().

[virtual protected] void QMdiSubWindow::mouseDoubleClickEvent(QMouseEvent *mouseEvent)

重新实现 QWidget::mouseDoubleClickEvent().

[virtual protected] void QMdiSubWindow::mouseMoveEvent(QMouseEvent *mouseEvent)

重新实现 QWidget::mouseMoveEvent().

[virtual protected] void QMdiSubWindow::mousePressEvent(QMouseEvent *mouseEvent)

重新实现 QWidget::mousePressEvent().

[virtual protected] void QMdiSubWindow::mouseReleaseEvent(QMouseEvent *mouseEvent)

重新实现 QWidget::mouseReleaseEvent().

[virtual protected] void QMdiSubWindow::moveEvent(QMoveEvent *moveEvent)

重新实现 QWidget::moveEvent().

[virtual protected] void QMdiSubWindow::paintEvent(QPaintEvent *paintEvent)

重新实现 QWidget::paintEvent().

[virtual protected] void QMdiSubWindow::resizeEvent(QResizeEvent *resizeEvent)

重新实现 QWidget::resizeEvent().

Warning: When maximizing or restoring a subwindow, the resulting call to this function may have an invalid QResizeEvent::oldSize().

void QMdiSubWindow::setOption(SubWindowOption option, bool on = true)

If on is true, option is enabled on the subwindow; otherwise it is disabled. See SubWindowOption for the effect of each option.

参见 SubWindowOption and testOption().

void QMdiSubWindow::setSystemMenu(QMenu *systemMenu)

Sets systemMenu as the current system menu for this subwindow.

By default, each QMdiSubWindow has a standard system menu.

QActions for the system menu created by QMdiSubWindow will automatically be updated depending on the current window state; e.g., the minimize action will be disabled after the window is minimized.

QActions added by the user are not updated by QMdiSubWindow.

QMdiSubWindow takes ownership of systemMenu; you do not have to delete it. Any existing menus will be deleted.

参见 systemMenu() and showSystemMenu().

void QMdiSubWindow::setWidget(QWidget *widget)

Sets widget as the internal widget of this subwindow. The internal widget is displayed in the center of the subwindow beneath the title bar.

QMdiSubWindow takes temporary ownership of widget; you do not have to delete it. Any existing internal widget will be removed and reparented to the root window.

参见 widget().

[virtual protected] void QMdiSubWindow::showEvent(QShowEvent *showEvent)

重新实现 QWidget::showEvent().

[slot] void QMdiSubWindow::showShaded()

Calling this function makes the subwindow enter the shaded mode. When the subwindow is shaded, only the title bar is visible.

Although shading is not supported by all styles, this function will still show the subwindow as shaded, regardless of whether support for shading is available. However, when used with styles without shading support, the user will be unable to return from shaded mode through the user interface (e.g., through a shade button in the title bar).

参见 isShaded().

[slot] void QMdiSubWindow::showSystemMenu()

Shows the system menu below the system menu icon in the title bar.

参见 setSystemMenu() and systemMenu().

[virtual] QSize QMdiSubWindow::sizeHint() const

重新实现 QWidget::sizeHint().

QMenu *QMdiSubWindow::systemMenu() const

Returns a pointer to the current system menu, or zero if no system menu is set. QMdiSubWindow provides a default system menu, but you can also set the menu with setSystemMenu().

参见 setSystemMenu() and showSystemMenu().

bool QMdiSubWindow::testOption(SubWindowOption option) const

Returns true if option is enabled; otherwise returns false.

参见 SubWindowOption and setOption().

[virtual protected] void QMdiSubWindow::timerEvent(QTimerEvent *timerEvent)

重新实现 QObject::timerEvent().

QWidget *QMdiSubWindow::widget() const

Returns the current internal widget.

参见 setWidget().

[signal] void QMdiSubWindow::windowStateChanged(Qt::WindowStates oldState, Qt::WindowStates newState)

QMdiSubWindow emits this signal after the window state changes. oldState is the window state before it changed, and newState is the new, current state.