本页内容

QSGFlatColorMaterial Class

QSGFlatColorMaterial 类提供了一种在场景图中渲染纯色几何体的便捷方法。更多内容...

头文件: #include <QSGFlatColorMaterial>
CMake: find_package(Qt6 REQUIRED COMPONENTS Quick)
target_link_libraries(mytarget PRIVATE Qt6::Quick)
qmake: QT += quick
继承自: QSGMaterial

公共函数

QSGFlatColorMaterial()
const QColor &color() const
void setColor(const QColor &color)

详细说明

警告:此 实用类仅在使用Qt Quick 场景图的默认后端时才有效。

纯色材质将使用纯色填充几何体中的每个像素。该颜色可以包含透明度。

要使用平涂材质渲染的几何体,必须在QSGGeometry 对象的属性位置 0 中包含顶点,才能正确渲染。QSGGeometry::defaultAttributes_Point2D() 返回与该材质兼容的属性集。

纯色材质在更新其渲染状态时,会同时考虑当前不透明度和当前矩阵。

成员函数文档

QSGFlatColorMaterial::QSGFlatColorMaterial()

创建一个新的纯色材质。

默认颜色为白色。

const QColor &QSGFlatColorMaterial::color() const

返回此纯色材质的颜色。

默认颜色为白色。

另请参阅 setColor()。

void QSGFlatColorMaterial::setColor(const QColor &color)

将此纯色材质的颜色设置为color 。

另请参阅 color()。

© 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.