QML: How to reset item property to defaut

JustWe

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.

Mitch

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to reset a readonly static property?

From Dev

QML,How to dynamicaly change Item of Repeater from C++

From Dev

How to set property type of qml signal?

From Dev

How to reset 'display' property for flex-item

From Dev

How to make last item in QML container fill remaining space?

From Dev

How to reset selected item of a spinner in android?

From Dev

How to find QML item by its string id?

From Dev

How to expose property of QObject pointer to QML

From Dev

How to make an item drag inside a circle in QML?

From Dev

How to access a component bound to a property in QML

From Dev

Qt / QML - Choose how many characters to be displayed in a Text item

From Dev

How to set a background for a qml item of unspecified size?

From Dev

How to drag an item outside a ListView in QML

From Dev

How to make a QML toggle button that tracks/controls any boolean property

From Dev

How to set another value on a boolean with defaut value with Entity Framework Core?

From Dev

How to change a property of a object in QML upon a hover?

From Dev

How do you check if a property is undefined in qml?

From Dev

How to reset angular filter property

From Dev

How to change property of other objects in QML

From Dev

QML,How to dynamicaly change Item of Repeater from C++

From Dev

How to set property type of qml signal?

From Dev

How to bind a property to a singleton object property from QML

From Dev

How to set a background for a qml item of unspecified size?

From Dev

How to prevent defaut behaviour of "input submit"?

From Dev

QML reset dialog with tabview

From Dev

How to set the property of an item with the index?

From Dev

How to Remove a dynamically created item from Column QML Element

From Dev

How set C++ class to an Item in qml?

From Dev

How to make visible property work immediately in QML?

Related Related

  1. 1

    How to reset a readonly static property?

  2. 2

    QML,How to dynamicaly change Item of Repeater from C++

  3. 3

    How to set property type of qml signal?

  4. 4

    How to reset 'display' property for flex-item

  5. 5

    How to make last item in QML container fill remaining space?

  6. 6

    How to reset selected item of a spinner in android?

  7. 7

    How to find QML item by its string id?

  8. 8

    How to expose property of QObject pointer to QML

  9. 9

    How to make an item drag inside a circle in QML?

  10. 10

    How to access a component bound to a property in QML

  11. 11

    Qt / QML - Choose how many characters to be displayed in a Text item

  12. 12

    How to set a background for a qml item of unspecified size?

  13. 13

    How to drag an item outside a ListView in QML

  14. 14

    How to make a QML toggle button that tracks/controls any boolean property

  15. 15

    How to set another value on a boolean with defaut value with Entity Framework Core?

  16. 16

    How to change a property of a object in QML upon a hover?

  17. 17

    How do you check if a property is undefined in qml?

  18. 18

    How to reset angular filter property

  19. 19

    How to change property of other objects in QML

  20. 20

    QML,How to dynamicaly change Item of Repeater from C++

  21. 21

    How to set property type of qml signal?

  22. 22

    How to bind a property to a singleton object property from QML

  23. 23

    How to set a background for a qml item of unspecified size?

  24. 24

    How to prevent defaut behaviour of "input submit"?

  25. 25

    QML reset dialog with tabview

  26. 26

    How to set the property of an item with the index?

  27. 27

    How to Remove a dynamically created item from Column QML Element

  28. 28

    How set C++ class to an Item in qml?

  29. 29

    How to make visible property work immediately in QML?

HotTag

Archive