Qt3DRender::QPaintedTextureImage Class
class Qt3DRender::QPaintedTextureImage可通过QPainter 写入的QAbstractTextureImage... 更多......
头文件: | #include <QPaintedTextureImage> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS 3drender) target_link_libraries(mytarget PRIVATE Qt6::3drender) |
qmake: | QT += 3drender |
继承: | Qt3DRender::QAbstractTextureImage |
状态: | 已废弃 |
属性
公共功能
公共插槽
信号
void | heightChanged(int w) |
void | sizeChanged(QSize size) |
void | widthChanged(int w) |
受保护功能
virtual void | paint(QPainter *painter) = 0 |
详细说明
QPaintedTextureImage 提供了一种通过QPainter 指定纹理图像(以及 OpenGL 纹理)的方法。纹理图像的宽度和高度可通过宽度和高度或大小属性指定。
必须对 QPaintedTextureImage 进行子类化,并实现虚拟paint() 函数。每次在 QPaintedTextureImage 上调用update() 时,都会调用paint() 函数并上传生成的图像。
QPaintedTextureImage 必须附加到某个QAbstractTexture 。
属性文档
height : int
此属性用于保存纹理图像的高度。高度必须大于或等于 1。
访问功能:
int | height() const |
void | setHeight(int h) |
通知信号:
void | heightChanged(int w) |
size : QSize
此属性用于保存纹理图像的大小。
访问功能:
QSize | size() const |
void | setSize(QSize size) |
Notifier 信号:
void | sizeChanged(QSize size) |
width : int
此属性用于保存纹理图像的宽度。宽度必须大于或等于 1。
访问功能:
int | width() const |
void | setWidth(int w) |
Notifier 信号:
void | widthChanged(int w) |
成员函数 文档
[pure virtual protected]
void QPaintedTextureImage::paint(QPainter *painter)
使用指定的QPainter 对象绘制纹理图像painter 。
QPainter OpenGL 将图像的左上角视为原点,而 OpenGL 则将纹理的左下角视为原点。考虑到这种差异,一种简单的方法是在绘制任何其他图像之前,在绘制器上设置一个自定义视口:
painter->setViewport(0, height(), width(), -height()); ...
[slot]
void QPaintedTextureImage::setHeight(int h)
设置纹理图像的高度(h )。如果尺寸发生变化,则触发更新。
注: 属性height 的设置函数。
另请参阅 height().
[slot]
void QPaintedTextureImage::setSize(QSize size)
设置纹理图像的宽度和高度。如果size 发生变化,则触发更新。
注: 属性size 的设置函数。
另请参阅 size().
[slot]
void QPaintedTextureImage::setWidth(int w)
设置纹理图像的宽度(w )。如果尺寸发生变化,则触发更新。
注: 属性width 的设置函数。
另请参阅 width().
void QPaintedTextureImage::update(const QRect &rect = QRect())
立即触发绘制纹理的paint() 函数,进而将新图像上传到 GPU。如果要对绘制的纹理进行多次更改,请考虑等到所有更改完成后再调用 update,以尽量减少所需的重绘次数。
参数rect 目前未使用。
© 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.