Qt property reset feature
Solved
QML and Qt Quick
-
Hi,
how is the RESET feature of a property called from QML?Q_PROPERTY(int counter READ counter WRITE setCounter RESET resetCounter) ... int counter() const; void setCounter(int counter); void resetCounter(); ...
In QML:
MyObject.counter = 123 // how can i call the reset function?
Thanks!
-
Hi,
how is the RESET feature of a property called from QML?Q_PROPERTY(int counter READ counter WRITE setCounter RESET resetCounter) ... int counter() const; void setCounter(int counter); void resetCounter(); ...
In QML:
MyObject.counter = 123 // how can i call the reset function?
Thanks!
@beecksche
simply assignundefined
to the property -
Hi,
how is the RESET feature of a property called from QML?Q_PROPERTY(int counter READ counter WRITE setCounter RESET resetCounter) ... int counter() const; void setCounter(int counter); void resetCounter(); ...
In QML:
MyObject.counter = 123 // how can i call the reset function?
Thanks!
@beecksche said in Qt property reset feature:
Hi,
how is the RESET feature of a property called from QML?Q_PROPERTY(int counter READ counter WRITE setCounter RESET resetCounter) ... int counter() const; void setCounter(int counter); void resetCounter(); ...
In QML:
MyObject.counter = 123 // how can i call the reset function?
Thanks!
hi, that should be easy enought to do, you'll need the
Q_INVOKABLE
makro and you're fine to go:Q_PROPERTY(int counter READ counter WRITE setCounter RESET resetCounter) int counter() const; void setCounter(int counter); Q_INVOKABLE void resetCounter();
To call the function from qml:
MyObject.resetCounter();
Edit: never mind, I read the question wrong, keep to what @raven-worx wrote x)