qtquick的canvas是怎么回事,例子弄进去怎么没反应……
qt吧
全部回复
仅看楼主
level 12
xsjqqq123 楼主
这一句中的var ctx = canvas.getContext('2d')原话是object Canvas::getContext(string
contextId, any),它有什么用?2d是画布的环境?但有些比如ctx.rect。ctx.fill(),在参考中找不到这个方法啊,是不是html5能用的,qtquick教能直接用?
import QtQuick 2.0
Rectangle {
id: root
width: 360; height: 360
color: "#3C3C3C"
Canvas {
id: canvas
width: 300; height: 300
anchors.centerIn: parent
onPaint: {
// get the drawing context
var ctx = canvas.getContext('2d')
// create a rectangle path
ctx.rect(50, 50, 200, 200)
// setup fill color
ctx.fillStyle = "#FFF0A5"
// fill path
ctx.fill()
// setup line width and stroke color
ctx.lineWidth = 4
ctx.strokeStyle = "#468966"
// stroke path
ctx.stroke()
}
}
}
2013年04月13日 15点04分 1
level 14
2013年04月13日 16点04分 2
level 14
2013年04月13日 16点04分 3
level 14
Canvas
qt-project.org/doc/qt-5.0/qtquick/qml-qtquick2-canvas.html
2013年04月13日 16点04分 4
level 14
2013年04月13日 16点04分 6
level 14
@xsjqqq123
6L 有详细的入门文档
2013年04月13日 16点04分 7
level 14
2013年04月13日 16点04分 8
多谢大哥……
2013年04月14日 10点04分
1