QSizeGrip Class

QSizeGrip 类提供了一个调整大小的句柄,用于调整顶层窗口的大小。更多

Header: #include <QSizeGrip>
CMake: find_package(Qt6 REQUIRED COMPONENTS Widgets)
target_link_libraries(mytarget PRIVATE Qt6::Widgets)
qmake: QT += widgets
继承: QWidget

公共函数

QSizeGrip(QWidget *parent)
virtual ~QSizeGrip()

重新实现的公共函数

virtual void setVisible(bool visible) override
virtual QSize sizeHint() const override

重新实现的保护函数

virtual bool event(QEvent *event) override
virtual bool eventFilter(QObject *o, QEvent *e) override
virtual void hideEvent(QHideEvent *hideEvent) override
virtual void mouseMoveEvent(QMouseEvent *event) override
virtual void mousePressEvent(QMouseEvent *event) override
virtual void mouseReleaseEvent(QMouseEvent *mouseEvent) override
virtual void moveEvent(QMoveEvent *moveEvent) override
virtual void paintEvent(QPaintEvent *event) override
virtual void showEvent(QShowEvent *showEvent) override

详细说明

该部件的工作方式与标准的 Windows 大小调整句柄类似。在 X11 版本中,如果 X11 窗口管理器不支持必要的现代后ICCCM 规范,则该调整大小句柄的工作方式通常与系统提供的调整大小句柄不同。

将此窗口部件放在窗口部件树中的任意位置,用户就可以用它来调整顶层窗口或任何设置了Qt::SubWindow 标志的窗口部件的大小。一般来说,它应位于右下角。

请注意,QStatusBar 已经使用了该窗口部件,因此如果您有状态栏(例如,您使用的是QMainWindow ),则无需明确使用该窗口部件。QDialog 也是如此,您只需调用QDialog::setSizeGripEnabled() 即可。

在某些平台上,当窗口全屏显示或最大化时,尺寸控件会自动隐藏。

注意: 在 macOS 上,尺寸标注 不再是人机界面指南的一部分,除非在QMdiSubWindow 中使用,否则不会显示。请在尺寸标注上设置另一种样式,以便在主窗口中显示。

Fusion 风格的尺寸标注截图主窗口右下角的尺寸抓手部件,以Fusion 部件样式显示。

QSizeGrip 类继承于QWidget ,并重新实现了mousePressEvent() 和mouseMoveEvent() 函数以提供调整大小功能,以及paintEvent() 函数以渲染尺寸控件。

另请参阅 QStatusBarQWidget::windowState()。

成员函数文档

[explicit] QSizeGrip::QSizeGrip(QWidget *parent)

构建一个调整大小的角,作为给定parent 的子部件。

[virtual noexcept] QSizeGrip::~QSizeGrip()

破坏这种尺寸的握把。

[override virtual protected] bool QSizeGrip::event(QEvent *event)

重实现:QWidget::event(QEvent *event).

[override virtual protected] bool QSizeGrip::eventFilter(QObject *o, QEvent *e)

重实现:QObject::eventFilter(QObject *watched, QEvent *event).

[override virtual protected] void QSizeGrip::hideEvent(QHideEvent *hideEvent)

重实现:QWidget::hideEvent(QHideEvent *event).

[override virtual protected] void QSizeGrip::mouseMoveEvent(QMouseEvent *event)

重实现:QWidget::mouseMoveEvent(QMouseEvent *event).

调整包含此 widget 的顶层 widget 的大小。鼠标移动事件通过event 参数传递。

[override virtual protected] void QSizeGrip::mousePressEvent(QMouseEvent *event)

重实现:QWidget::mousePressEvent(QMouseEvent *event).

接收窗口小部件的鼠标按下事件,并为调整大小操作做准备。鼠标按下事件通过event 参数传递。

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

重实现:QWidget::mouseReleaseEvent(QMouseEvent *event).

[override virtual protected] void QSizeGrip::moveEvent(QMoveEvent *moveEvent)

重实现:QWidget::moveEvent(QMoveEvent *event).

[override virtual protected] void QSizeGrip::paintEvent(QPaintEvent *event)

重实现:QWidget::paintEvent(QPaintEvent *event).

绘制调整大小的手柄。

调整大小的手柄通常在右下角呈现为小的对角纹理线。绘制事件通过event 参数传递。

[override virtual] void QSizeGrip::setVisible(bool visible)

重构属性访问函数:QWidget::visible

[override virtual protected] void QSizeGrip::showEvent(QShowEvent *showEvent)

重实现:QWidget::showEvent(QShowEvent *event).

[override virtual] QSize QSizeGrip::sizeHint() const

重构属性访问函数:QWidget::sizeHint

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.