Correct way to reset/unset a property
Solved
General and Desktop
-
Is there a way to reset / unset a property so the system goes back to a state before setProperty has been called, psuedo example:
setProperty("simon", someData); //Assigns someData to the property "simon" unsetProperty("simon"); //Removes "simon" so it doesn't exist anymore.
[Edit] I've created a QMap in my class instead of using properties to resolve this.
-
Are you talking about dynamic properties? Then you can 'remove' them by just calling QObject::setProperty() by setting an invalid QVariant, e.g.
setProperty("simon", someData); //Assigns someData to the property "simon" setProperty("simon", QVariant()); //Removes "simon" so it doesn't exist anymore.
-
Are you talking about dynamic properties? Then you can 'remove' them by just calling QObject::setProperty() by setting an invalid QVariant, e.g.
setProperty("simon", someData); //Assigns someData to the property "simon" setProperty("simon", QVariant()); //Removes "simon" so it doesn't exist anymore.
-
@kkoehne , thank you, this could be implemented as a macro doing exactly that by improving readability.