【问题标题】:is there a way to draw on the screen using finger with Qml有没有办法用 Qml 的手指在屏幕上绘图
【发布时间】:2013-10-25 18:55:51
【问题描述】:

有没有办法用我的手指在屏幕上绘图

我正在创建一个 Blackberry-10 应用程序,比如画一些东西作为学校作业

【问题讨论】:

    标签: blackberry qml blackberry-10 blackberry-cascades


    【解决方案1】:

    如果您有可用的 Qt Quick 2.0,您可以在 QML 中使用Canvas 对象。以下示例展示了如何在有 onPressed / onPositionChanged 事件时绘制一条红线:

    import QtQuick 2.0
    Rectangle {
        property int startX;
        property int startY;
        property int finishX;
        property int finishY;
        Canvas {
            anchors.fill: parent
            onPaint: {
              var ctx = getContext("2d");   
              ctx.fillStyle = "black";
              ctx.fillRect(0, 0, width, height);
              ctx.strokeStyle = "red";
              ctx.lineWidth = 1;
              ctx.beginPath();
              ctx.moveTo(startX, startY);
              ctx.lineTo(finishX, finishY);
              ctx.stroke();
              ctx.closePath();
            }
            MouseArea {
                anchors.fill: parent
                onPressed: {
                    startX = mouseX;
                    startY = mouseY;
                }
                onPositionChanged: {
                    finishX = mouseX;
                    finishY = mouseY;
                    parent.requestPaint();
                }
            }
        }
    }
    

    【讨论】:

      【解决方案2】:

      抱歉,您打算使用 BB10,因为我不明白这个问题。

      SDK documentation 尝试这个解决方案。

      【讨论】:

      • 这似乎是 Native SDK 而不是 QML 像 OP 要求的那样。
      猜你喜欢
      • 2013-03-08
      • 2018-04-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多