我正在寻找解决这个问题的方法。我有一个矩形,我可以在4个角落拖动比例。但是当我拖动矩形时,我的鼠标图标没有停留在角落,我希望它在我拖动时留在角落。
这是我的img url
这是我的代码块。
import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Window 2.2
Window {
title: qsTr("Test Crop")
width: 640
height: 480
visible: true
property var selection: undefined
property int rulersSize: 18
property double newheight: recframe.height
property double newwidth: recframe.width
property double oldwidth: recframe.width
property double oldheight: recframe.height
Rectangle {
x:parent.width / 4
y: parent.height / 4
width: parent.width / 2
height: parent.width / 2
id: recframe
border {
width: 2
color: "steelblue"
}
color: "#354682B4"
//rec corner in top left
Rectangle {
width: 18
height: 18
color: "steelblue"
anchors.verticalCenter:parent.top
anchors.horizontalCenter: parent.left
MouseArea {
anchors.fill: parent
drag{ target: parent; axis: Drag.XAxis }
onMouseXChanged: {
if(drag.active){
newheight = newheight-mouseY
var c=recframe.scale/oldheight * newheight
recframe.scale = c
newwidth = oldwidth * newheight/ oldheight
recframe.x += (oldwidth - newwidth)/ 2
recframe.y += mouseY / 2
oldheight = newheight
oldwidth = newwidth
}
}
}
}
}
}