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 [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to reset 'display' property for flex-item

From Dev

How to reset a readonly static property?

From Dev

How to reset angular filter property

From Dev

How to prevent defaut behaviour of "input submit"?

From Dev

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

From Dev

How to find QML item by its string id?

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 set a background for a qml item of unspecified size?

From Dev

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

From Dev

How to access a component bound to a property in QML

From Dev

How to expose property of QObject pointer to QML

From Dev

How to set property type of qml signal?

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 change property of other objects in QML

From Dev

How to set property type of qml signal?

From Dev

How to make visible property work immediately in QML?

From Dev

How to reset selected item of a spinner in android?

From Dev

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

From Dev

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

From Dev

QML reset dialog with tabview

From Dev

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

From Dev

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

From Dev

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

From Dev

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

From Dev

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

From Dev

How to Remove a dynamically created item from Column QML Element

From Dev

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

Related Related

  1. 1

    How to reset 'display' property for flex-item

  2. 2

    How to reset a readonly static property?

  3. 3

    How to reset angular filter property

  4. 4

    How to prevent defaut behaviour of "input submit"?

  5. 5

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

  6. 6

    How to find QML item by its string id?

  7. 7

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

  8. 8

    How to drag an item outside a ListView in QML

  9. 9

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

  10. 10

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

  11. 11

    How to access a component bound to a property in QML

  12. 12

    How to expose property of QObject pointer to QML

  13. 13

    How to set property type of qml signal?

  14. 14

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

  15. 15

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

  16. 16

    How to change property of other objects in QML

  17. 17

    How to set property type of qml signal?

  18. 18

    How to make visible property work immediately in QML?

  19. 19

    How to reset selected item of a spinner in android?

  20. 20

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

  21. 21

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

  22. 22

    QML reset dialog with tabview

  23. 23

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

  24. 24

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

  25. 25

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

  26. 26

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

  27. 27

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

  28. 28

    How to Remove a dynamically created item from Column QML Element

  29. 29

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

HotTag

Archive