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: "Join 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: 120 height: 120 scale: root.shapeScale ShapePath { id: joinTest strokeColor: "black" strokeWidth: 16 fillColor: "transparent" capStyle: ShapePath.RoundCap property int joinStyleIdx: 0 joinStyle: style(joinStyleIdx) startX: 30 startY: 30 PathLine { x: 100; y: 100 } PathLine { x: 30; y: 100 } } } Text { anchors.top: parent.top anchors.right: parent.right anchors.margins: 2 font.pixelSize: 10 text: styleText(joinTest.joinStyleIdx) } } function styleText(index: int) : string { if (index == 0) return "BevelJoin"; else if (index == 1) return "MiterJoin"; else return "RoundJoin"; } function style(index: int) : ShapePath.JoinStyle { if (index == 0) return ShapePath.BevelJoin; else if (index == 1) return ShapePath.MiterJoin; else return ShapePath.RoundJoin; } Timer { interval: 1000 repeat: true running: true onTriggered: joinTest.joinStyleIdx = (joinTest.joinStyleIdx + 1) % 3 } }