Is there any way to reset the property of item?
For example:
Item{
id: test
x: 10; y: 10
}
Then i set the x,y
to (100,100)
. Without change the x,y
to (10,10)
back. Any function like this test.reset()
.
My problem is: i drag an item, if it not drop in the correct area, i wanna the item return back automatically.
In general, setting a property to undefined
causes it to be reset. An example of this is Item
's anchors
grouped properties:
To clear an anchor value, set it to undefined.
Qt's property system has the concept of a resettable property:
A RESET function is optional. It is for setting the property back to its context specific default value. e.g., QWidget::cursor has the typical READ and WRITE functions, QWidget::cursor() and QWidget::setCursor(), and it also has a RESET function, QWidget::unsetCursor(), since no call to QWidget::setCursor() can mean reset to the context specific cursor. The RESET function must return void and take no parameters.
However, for your specific problem, you probably want to take a look at the Drag and Drop example. That demonstrates how to return an item to its original position.
Collected from the Internet
Please contact debug[email protected] to delete if infringement.
Comments