Qt 6.11 is out! See what's new in the release
blog
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,
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 assignundefinedto 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_INVOKABLEmakro 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)