QPaintEvent Class
QPaintEvent 类包含油漆事件的事件参数。更多
头文件: | #include <QPaintEvent> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Gui) target_link_libraries(mytarget PRIVATE Qt6::Gui) |
qmake: | QT += gui |
继承: | QEvent |
- 所有成员(包括继承成员)的列表
- QPaintEvent 属于事件类。
公共函数
QPaintEvent(const QRect &paintRect) | |
QPaintEvent(const QRegion &paintRegion) | |
const QRect & | rect() const |
const QRegion & | region() const |
详细说明
绘制事件会发送给需要更新的部件,例如,由于覆盖的部件被移动,部件的一部分被暴露出来。
事件包含一个需要更新的region() 和一个作为该区域边界矩形的rect() 。之所以提供这两个事件,是因为许多部件无法充分利用region() ,而rect() 比region().boundingRect() 要快得多。
自动剪切
在绘制事件的处理过程中,绘制会被剪切到region() 。该裁剪由 Qt 的绘制系统执行,与应用于绘制设备上用于绘制的QPainter 的任何裁剪无关。
因此,QPainter::clipRegion() 在新构建的QPainter 上返回的值不会反映涂画系统使用的剪辑区域。
另请参阅 QPainter,QWidget::update(),QWidget::repaint() 和QWidget::paintEvent() 。
成员函数文档
[explicit]
QPaintEvent::QPaintEvent(const QRect &paintRect)
用需要更新的矩形构建一个油漆事件对象。区域由paintRect 指定。
[explicit]
QPaintEvent::QPaintEvent(const QRegion &paintRegion)
用需要更新的区域构建一个油漆事件对象。区域由paintRegion 指定。
const QRect &QPaintEvent::rect() const
返回需要更新的矩形。
另请参阅 region() 和QPainter::setClipRect()。
const QRegion &QPaintEvent::region() const
返回需要更新的区域。
另请参阅 rect() 和QPainter::setClipRegion()。
© 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.