QSGSimpleTextureNode Class
提供 QSGSimpleTextureNode 类是为了方便用户通过 QML 场景图轻松绘制带纹理的内容。更多内容...
| 头文件: | #include <QSGSimpleTextureNode> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Quick) target_link_libraries(mytarget PRIVATE Qt6::Quick) |
| qmake: | QT += quick |
| 继承自: | QSGGeometryNode |
公共类型
| enum | TextureCoordinatesTransformFlag { NoTransform, MirrorHorizontally, MirrorVertically } |
| flags | TextureCoordinatesTransformMode |
公共函数
| QSGSimpleTextureNode() | |
| virtual | ~QSGSimpleTextureNode() override |
| QSGTexture::Filtering | filtering() const |
| bool | ownsTexture() const |
| QRectF | rect() const |
| void | setFiltering(QSGTexture::Filtering filtering) |
| void | setOwnsTexture(bool owns) |
| void | setRect(const QRectF &r) |
| void | setRect(qreal x, qreal y, qreal w, qreal h) |
| void | setSourceRect(const QRectF &r) |
| void | setSourceRect(qreal x, qreal y, qreal w, qreal h) |
| void | setTexture(QSGTexture *texture) |
| void | setTextureCoordinatesTransform(QSGSimpleTextureNode::TextureCoordinatesTransformMode mode) |
| QRectF | sourceRect() const |
| QSGTexture * | texture() const |
| QSGSimpleTextureNode::TextureCoordinatesTransformMode | textureCoordinatesTransform() const |
详细描述
警告: 简单纹理节点类 必须先拥有纹理,才能被添加到场景图中进行渲染。
警告:此 实用类仅在与Qt Quick 场景图的默认或软件后端一起运行时才有效。作为替代方案,建议通过QQuickWindow::createImageNode()使用QSGImageNode 。不过,当通过子类化使用且应用程序确定不会涉及任何特殊的场景图后端时,此独立类仍然很有用。
成员类型文档
enum QSGSimpleTextureNode::TextureCoordinatesTransformFlag
flags QSGSimpleTextureNode::TextureCoordinatesTransformMode
TextureCoordinatesTransformFlag 枚举用于指定为带纹理的四边形生成纹理坐标所采用的模式。
| 常量 | 值 | 描述 |
|---|---|---|
QSGSimpleTextureNode::NoTransform | 0x00 | 纹理坐标以窗口坐标为基准,即原点位于左上角。 |
QSGSimpleTextureNode::MirrorHorizontally | 0x01 | 纹理坐标在水平轴上相对于窗口坐标被反转 |
QSGSimpleTextureNode::MirrorVertically | 0x02 | 纹理坐标在垂直轴上相对于窗口坐标进行了反转 |
TextureCoordinatesTransformMode 类型是QFlags<TextureCoordinatesTransformFlag> 的 typedef。它存储 TextureCoordinatesTransformFlag 值的按“或”运算组合。
成员函数文档
QSGSimpleTextureNode::QSGSimpleTextureNode()
创建一个新的简单纹理节点
[override virtual noexcept] QSGSimpleTextureNode::~QSGSimpleTextureNode()
删除纹理节点
QSGTexture::Filtering QSGSimpleTextureNode::filtering() const
返回当前设置在此纹理节点上的过滤器
另请参阅 setFiltering()。
bool QSGSimpleTextureNode::ownsTexture() const
如果节点获得了纹理的所有权,则返回true ;否则返回false 。
另请参阅 setOwnsTexture()。
QRectF QSGSimpleTextureNode::rect() const
返回此纹理节点的目标矩形。
另请参阅 setRect()。
void QSGSimpleTextureNode::setFiltering(QSGTexture::Filtering filtering)
将此纹理节点使用的过滤器设置为“filtering ”。
若需平滑缩放,请使用QSGTexture::Linear ;若需标准缩放,请使用QSGTexture::Nearest 。
另请参阅 filtering()。
void QSGSimpleTextureNode::setOwnsTexture(bool owns)
将节点是否拥有纹理所有权设置为owns 。
默认情况下,该节点不会拥有该纹理的所有权。
另请参阅 ownsTexture() 和setTexture()。
void QSGSimpleTextureNode::setRect(const QRectF &r)
将此纹理节点的目标矩形设置为r 。
另请参阅 rect()。
void QSGSimpleTextureNode::setRect(qreal x, qreal y, qreal w, qreal h)
将此纹理节点的矩形起始位置设置为 (x,y),宽度为w ,高度为h 。
这是一个重载函数。
void QSGSimpleTextureNode::setSourceRect(const QRectF &r)
将此纹理节点的源矩形设置为r 。
另请参阅 sourceRect()。
void QSGSimpleTextureNode::setSourceRect(qreal x, qreal y, qreal w, qreal h)
将此纹理节点的矩形设置为从坐标 (x,y) 开始显示其纹理,其宽度为w ,高度为h ,相对于QSGTexture::textureSize 。
这是一个重载函数。
void QSGSimpleTextureNode::setTexture(QSGTexture *texture)
将此纹理节点的纹理设置为texture 。
使用setOwnsTexture() 来设置该节点是否应拥有该纹理的所有权。默认情况下,该节点不拥有所有权。
警告: 纹理节点 必须先拥有纹理,才能被添加到场景图中进行渲染。
另请参阅 texture()。
void QSGSimpleTextureNode::setTextureCoordinatesTransform(QSGSimpleTextureNode::TextureCoordinatesTransformMode mode)
将用于生成纹理坐标的方法设置为mode 。这可用于获得纹理的正确方向。当使用第三方 OpenGL 库将内容渲染到纹理时,通常需要这样做,因为 OpenGL 的 y 轴相对于Qt Quick 而言是倒置的。
另请参阅 textureCoordinatesTransform()。
QRectF QSGSimpleTextureNode::sourceRect() const
返回此纹理节点的源矩形区域。
另请参阅 setSourceRect()。
QSGTexture *QSGSimpleTextureNode::texture() const
返回此纹理节点的纹理
另请参阅 setTexture()。
QSGSimpleTextureNode::TextureCoordinatesTransformMode QSGSimpleTextureNode::textureCoordinatesTransform() const
返回用于为本节点生成纹理坐标的模式。
另请参阅 setTextureCoordinatesTransform()。
© 2026 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.