Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import QtQuick 2.7
- //import Qt.WebSockets 1.0
- Item {
- id: root
- width: 1200
- height: 816
- Canvas {
- id: canvas
- anchors.fill: parent
- onPaint: {
- console.log(mouseArea.mousePos)
- var ctx = canvas.getContext('2d')
- ctx.clearRect(0, 0, canvas.width, canvas.height)
- ctx.beginPath()
- ctx.strokeStyle = "#FF000"
- ctx.lineWidth = 1
- ctx.moveTo(0, 0)
- ctx.lineTo(mouseArea.mousePos.x, mouseArea.mousePos.y)
- ctx.closePath()
- ctx.stroke()
- }
- }
- MouseArea {
- id: mouseArea
- property var mousePos: Qt.point(0, 0)
- hoverEnabled: true
- anchors.fill: parent
- onMouseXChanged: {
- mousePos.x = mouse.x
- canvas.requestPaint()
- }
- onMouseYChanged: {
- mousePos.y = mouse.y
- canvas.requestPaint()
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement