C

Qt Quick Ultralite shapes Example

/****************************************************************************** ** ** Copyright (C) 2021 The Qt Company Ltd. ** Contact: https://www.qt.io/licensing/ ** ** This file is part of the Qt Quick Ultralite module. ** ** $QT_BEGIN_LICENSE:COMM$ ** ** Commercial License Usage ** Licensees holding valid commercial Qt licenses may use this file in ** accordance with the commercial license agreement provided with the ** Software or, alternatively, in accordance with the terms contained in ** a written agreement between you and The Qt Company. For licensing terms ** and conditions see http://www.qt.io/terms-conditions. For further ** information use the contact form at http://www.qt.io/contact-us. ** ** $QT_END_LICENSE$ ** ******************************************************************************/
import QtQuick 2.15 import QtQuick.Shapes 1.0 ShapesEntry { id: root text: "Cap styles" Rectangle { color: "lightGray" anchors.top: parent.top anchors.horizontalCenter: parent.horizontalCenter anchors.margins: root.contentMargins width: root.contentHeight height: root.contentHeight Shape { anchors.centerIn: parent width: 200 height: 100 scale: root.shapeScale ShapePath { id: capTest strokeColor: "black" strokeWidth: 20 fillColor: "transparent" property int capStyleIdx: 0 capStyle: style(capTest.capStyleIdx) startX: 50; startY: 30 PathSvg { path: "Q 10 80 60 80 L 140 80 Q 190 80 150 30" } } } Text { anchors.top: parent.top anchors.right: parent.right anchors.margins: 2 font.pixelSize: 10 text: styleText(capTest.capStyleIdx) } } function styleText(index: int) : string { if (index == 0) return "FlatCap"; else if (index == 1) return "SquareCap"; else return "RoundCap"; } function style(index: int) : ShapePath.CapStyle { if (index == 0) return ShapePath.FlatCap; else if (index == 1) return ShapePath.SquareCap; else return ShapePath.RoundCap; } Timer { interval: 1000 repeat: true running: true onTriggered: capTest.capStyleIdx = (capTest.capStyleIdx + 1) % 3 } }