Guest User

Untitled

a guest
Feb 13th, 2026
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QML 0.92 KB | None | 0 0
  1. import QtQuick
  2. import QtQuick.Layouts
  3. import QtQuick.Controls
  4.  
  5. Window {
  6.     id: root
  7.     width: 800
  8.     height: 480
  9.     visible: true
  10.     title: qsTr("Hello World")
  11.  
  12.     AnchorDragArea {
  13.         anchors.horizontalCenter: parent.horizontalCenter
  14.         anchors.verticalCenter: parent.verticalCenter
  15.         width: 600
  16.         height: 400
  17.         onAnchorDrag: (dx, dy) => {
  18.                           marker.x += dx
  19.                           marker.y += dy
  20.                           marker.x = Math.min(root.width-marker.width, Math.max(0, marker.x))
  21.                           marker.y = Math.min(root.height-marker.height, Math.max(0, marker.y))
  22.                       }
  23.     }
  24.  
  25.     Rectangle {
  26.         id: marker
  27.         width: 10
  28.         height: 10
  29.         border.color: "green"
  30.         border.width: 2
  31.         color: "transparent"
  32.         x: root.width/2 - width/2
  33.         y: root.height/2 - height/2
  34.     }
  35. }
  36.  
Advertisement
Add Comment
Please, Sign In to add comment