Drag rectangle width
-
Hi
I want to drag a rectangle such that its position remains same but on drag width changes in the direction of drag.basically I want to drag the blue part to left side such that yellow part width will shrink.
I tried it but cant achieve the goal. how can I do it? -
Have drag.target as blue rect. Anchor blue to right. When you drag it change the x location of blue object well.
-
Hi Sir
Now its working
I did it like this:import QtQuick 2.6 import QtQuick.Window 2.2 Window { visible: true width: 640 height: 480 title: qsTr("Hello World") property int oldmouseX; Rectangle { id: container width: 600; height: 200 color:"black" Rectangle { id:rect1 width: 100; height: 100 color: "brown" anchors.right:rect.left anchors.left:parent.left } Rectangle { id: rect width: 100; height: 100 color: "red" anchors.right:parent.right MouseArea { id:mousearea anchors.fill: parent onPressed:oldmouseX=mouseX onPositionChanged: { if (pressed) { rect.width = rect.width + ( oldmouseX-mouseX) } } } } } }