QSGSimpleTextureNode Class
提供 QSGSimpleTextureNode 类是为了方便使用 QML 场景图轻松绘制纹理内容。更多
Header: | #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 。不过,在通过子类化使用且应用程序知道不会涉及特殊场景图后端时,该独立类仍然有用。
成员类型文档
枚举 QSGSimpleTextureNode::TextureCoordinatesTransformFlag
flags QSGSimpleTextureNode::TextureCoordinatesTransformMode
TextureCoordinatesTransformFlag 枚举用于指定为纹理四边形生成纹理坐标的模式。
常量 | 值 | 说明 |
---|---|---|
QSGSimpleTextureNode::NoTransform | 0x00 | 纹理坐标与窗口坐标一致,即原点位于左上角。 |
QSGSimpleTextureNode::MirrorHorizontally | 0x01 | 纹理坐标在水平轴上与窗口坐标倒置 |
QSGSimpleTextureNode::MirrorVertically | 0x02 | 相对于窗口坐标,纹理坐标在纵轴上反转 |
纹理坐标转换模式(TextureCoordinatesTransformMode)类型是QFlags<TextureCoordinatesTransformFlag> 的类型定义。它存储 TextureCoordinatesTransformFlag 值的 OR 组合。
成员函数文档
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()。
© 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.