Qt Quick Shapes QML Types

要使用该模块中的类型,请使用以下行导入该模块:

import QtQuick.Shapes

Qt Quick 形状提供了在 场景中绘制任意形状的工具。 可由 和 等定义子形状的基本构件构建。然后,可以用纯色或渐变色填充子形状,还可以定义轮廓描边。Qt Quick Shapes lines curves

Qt Quick 形状 "还支持更高级别的路径元素类型,如 和 。目前支持的元素类型有, , , , , 和 。text SVG path descriptions PathMove PathLine PathQuad PathCubic PathArc PathText PathSvg

Qt Quick 形状会对形状进行三角化处理,并在 GPU 上渲染相应的三角形。因此,改变元素的控制点会导致受影响路径的重新三角剖分,这需要一定的性能代价。此外,曲线在渲染前会被压平,因此对形状应用很高的缩放比例可能会出现假象,即可以看到曲线是由一连串较小的直线表示的。

注: 默认情况下,Qt Quick "形状 "依赖多重采样来实现抗锯齿。可以使用QSurfaceFormat 中的相应设置为整个应用程序或窗口启用此功能。也可以通过将layer.enabled 属性设置为 true 并调整layer.samples 属性,仅为形状启用此功能。在后一种情况下,多重采样将不会应用于整个场景,但形状将通过中间的屏幕外缓冲区进行渲染。另外,也可以将preferredRendererType 属性设置为Shape.CurveRenderer 。这种方法内置了抗锯齿功能,通常能以更高的质量渲染形状,但需要付出额外的性能代价。

如需了解更多信息,"形状 "示例展示了如何实现不同类型的形状、填充和描边,而 "天气预报 "示例则展示了形状在用户界面中的不同应用方式。

ConicalGradient

锥形渐变

LinearGradient

线性渐变

RadialGradient

径向渐变

Shape

渲染路径

ShapeGradient

形状填充渐变的基本类型

ShapePath

描述路径以及用于描边和填充的相关属性

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