要使用此模块中的类型,采用以下行 import 模块:
import QtQuick.Shapes
Qt Quick Shapes provides tools for drawing arbitrary shapes in a Qt Quick scene. 形状 can be constructed from basic building blocks like lines and curves that define sub-shapes. The sub-shapes can then be filled with solid colors or gradients, and an outline stroke can be defined.
Qt Quick Shapes also supports higher level path element types, such as text and SVG path descriptions . The currently supported element types is: PathMove , PathLine , PathQuad , PathCubic , PathArc , PathText and PathSvg .
Qt Quick Shapes triangulates the shapes and renders the corresponding triangles on the GPU. Therefore, altering the control points of elements will lead to re-triangulation of the affected paths, at some performance cost. In addition, curves are flattened before they are rendered, so applying a very high scale to the shape may show artifacts where it is visible that the curves are represented by a sequence of smaller, straight lines.
注意:
By default, Qt Quick Shapes relies on multi-sampling for anti-aliasing. This can be enabled for the entire application or window using the corresponding settings in
QSurfaceFormat
. It can also be enabled for only the shape, by setting its
layer.enabled
property to true and then adjusting the
layer.samples
property. In the latter case, multi-sampling will not be applied to the entire scene, but the shape will be rendered via an intermediate off-screen buffer. Alternatively, the
preferredRendererType
property can be set to
Shape.CurveRenderer
. This has anti-aliasing built in and generally renders the shapes at a higher quality, but at some additional performance cost.
For further information, the Shapes example shows how to implement different types of shapes, fills and strokes, and the Weather Forecast Example shows examples of different ways shapes might be useful in a user interface.
Conical gradient | |
Linear gradient | |
Radial gradient | |
Renders a path | |
Base type of Shape fill gradients | |
Describes a Path and associated properties for stroking and filling |