I'm pretty new to QML. I'm trying to create a triangle (slice of a pie) that changes size based on the number of degrees that I pass in. For instance, if I pass in 360 it should be a full circle and if I pass in 90 degrees then it should be a quarter of a circle. What object from QML can I use to achieve this?
            Asked
            
        
        
            Active
            
        
            Viewed 538 times
        
    0
            
            
        
        Kau
        
- 91
 - 2
 - 8
 
- 
                    Does this answer your question? [Draw an arc/circle sector in QML?](https://stackoverflow.com/questions/26044801/draw-an-arc-circle-sector-in-qml) – Lady Be Good Aug 18 '22 at 06:37
 
1 Answers
0
            
            
        You can use Shape to draw some custom path, for example:
Shape {
    id: shape
    width: 300
    height: 200
    antialiasing: true
    anchors.centerIn: parent
    ShapePath {
        id: path
        strokeWidth: 1
        strokeColor: "#999"
        fillColor: "#abebc6"
        startX: 0; startY: shape.height / 2
        PathLine { x: shape.width * 0.9; y: 0 }
        PathArc {
            x: shape.width * 0.9
            y: shape.height
            radiusX: shape.height;
            radiusY: shape.height
            useLargeArc: false
        }
        PathLine { x: 0; y: shape.height / 2 }
    }
}
The same can be done using Canvas
        folibis
        
- 12,048
 - 6
 - 54
 - 97
 
- 
                    Where are you using the number of degrees? The size needs to adjust based on the number of degrees. – Kau Aug 18 '22 at 11:42
 - 
                    I think it won't be difficult for to convert the angle into coordinates. I just gave an example of an implementation. – folibis Aug 18 '22 at 13:24