QBackingStore Class
QBackingStore 类为QWindow 提供了一个绘图区域。更多
头文件: | #include <QBackingStore> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Gui) target_link_libraries(mytarget PRIVATE Qt6::Gui) |
qmake: | QT += gui |
公共函数
QBackingStore(QWindow *window) | |
~QBackingStore() | |
void | beginPaint(const QRegion ®ion) |
void | endPaint() |
void | flush(const QRegion ®ion, QWindow *window = nullptr, const QPoint &offset = QPoint()) |
QPlatformBackingStore * | handle() const |
bool | hasStaticContents() const |
QPaintDevice * | paintDevice() |
void | resize(const QSize &size) |
bool | scroll(const QRegion &area, int dx, int dy) |
void | setStaticContents(const QRegion ®ion) |
QSize | size() const |
QRegion | staticContents() const |
QWindow * | window() const |
详细说明
QBackingStore 可使用QPainter 在 RasterSurface 类型的QWindow 上进行绘制。渲染到QWindow 的另一种方法是使用QOpenGLContext 的 OpenGL。
QBackingStore 包含窗口内容的缓冲表示,因此支持部分更新,即使用QPainter 只更新窗口内容的子区域。
如果应用程序希望在不使用 OpenGL 加速的情况下使用QPainter ,并且不需要使用QWidget 或QGraphicsView UI 栈的额外开销,则可以使用 QBackingStore。有关如何使用 QBackingStore 的示例,请参阅光栅窗口示例。
成员函数文档
[explicit]
QBackingStore::QBackingStore(QWindow *window)
为给定的顶层window 构建一个空曲面。
[noexcept]
QBackingStore::~QBackingStore()
破坏该表面。
void QBackingStore::beginPaint(const QRegion ®ion)
在给定的region 中开始在底层存储表面涂画。
应在使用paintDevice() 上色之前调用此函数。
另请参阅 endPaint() 和paintDevice()。
void QBackingStore::endPaint()
结束绘制。
应在使用paintDevice() 结束绘制后调用此函数。
另请参阅 beginPaint() 和paintDevice()。
void QBackingStore::flush(const QRegion ®ion, QWindow *window = nullptr, const QPoint &offset = QPoint())
将给定的region 从指定的window 刷新到屏幕上。
window 必须是此后援存储所代表的顶层窗口,或者是该窗口的非临时子窗口。如果传递nullptr
,就会退回到使用后援存储的顶层窗口。
如果window 是一个子窗口,则region 应为子窗口坐标,offset 应为子窗口相对于后台站顶层窗口的偏移量。
应在使用endPaint() 结束绘制后调用此函数。
QPlatformBackingStore *QBackingStore::handle() const
返回指向 QPlatformBackingStore 实现的指针
bool QBackingStore::hasStaticContents() const
返回一个布尔值,表示此窗口是否有静态内容。
QPaintDevice *QBackingStore::paintDevice()
返回此曲面的喷涂装置。
警告: 该设备仅在调用beginPaint() 和endPaint() 时有效。不应缓存返回值。
void QBackingStore::resize(const QSize &size)
将窗口表面的大小设置为size 。
另请参阅 size() 。
bool QBackingStore::scroll(const QRegion &area, int dx, int dy)
将给定的area dx 像素向右滚动,dy 向下滚动;dx 和dy 都可以是负数。
如果区域滚动成功,则返回true
;否则返回 false。
void QBackingStore::setStaticContents(const QRegion ®ion)
将region 设置为该窗口的静态内容。
另请参阅 staticContents().
QSize QBackingStore::size() const
返回窗口表面的当前大小。
QRegion QBackingStore::staticContents() const
返回QRegion ,表示窗口中包含静态内容的区域。
另请参阅 setStaticContents()。
QWindow *QBackingStore::window() const
返回与此曲面相关的顶层窗口指针。
© 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.