Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import QtQuick
- import QtQuick.Layouts
- import QtQuick.Controls
- Window {
- id: root
- width: 800
- height: 480
- visible: true
- title: qsTr("Hello World")
- AnchorDragArea {
- anchors.horizontalCenter: parent.horizontalCenter
- anchors.verticalCenter: parent.verticalCenter
- width: 600
- height: 400
- onAnchorDrag: (dx, dy) => {
- marker.x += dx
- marker.y += dy
- marker.x = Math.min(root.width-marker.width, Math.max(0, marker.x))
- marker.y = Math.min(root.height-marker.height, Math.max(0, marker.y))
- }
- }
- Rectangle {
- id: marker
- width: 10
- height: 10
- border.color: "green"
- border.width: 2
- color: "transparent"
- x: root.width/2 - width/2
- y: root.height/2 - height/2
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment