Rectangle { id: rect anchors { top: parent.top topMargin: Theme.paddingMedium horizontalCenter: parent.horizontalCenter //......other code } MouseArea { //....other code onPressed: { rect.anchors.top = undefined rect.anchors.topMargin = undefined rect.anchors.horizontalCenter = undefined } }