【问题标题】:Draw a line in a circular path in QML?在 QML 的圆形路径中画一条线?
【发布时间】:2016-10-20 03:38:28
【问题描述】:

我想在圆形路径中画一条线,当它在该圆形路径中移动时,这条线的长度应该增加(从 0 到完整的圆周)。 有什么解决办法吗?

【问题讨论】:

    标签: qt qml


    【解决方案1】:

    你可以使用Canvas

    Canvas {
        id: mycanvas
        width: 200
        height: 200
        onPaint: {
            var ctx = getContext("2d");
            ctx.beginPath();
            ctx.arc(x, y, radius, startAngle, endAngle, anticlockwise);
            ctx.stroke();
        }
    }
    

    您可以在documentation 中找到有关arc 方法的说明:您只需在您的QML 中定义startAngleendAngle 并在您想要移动或增加行时更新它们。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-12-19
      • 1970-01-01
      • 1970-01-01
      • 2018-05-23
      • 2016-03-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多