Unsolved Working with Q_PROPERTY and exposing the back end to the front end.
-
So when I create a variable and expose it to the front end like so:
Q_PROPERTY(bool connected READ connected WRITE setConnected NOTIFY connectedChanged)
I can call the
setConnected
from the front end or does it automatically get called when I callconnected
? -
I believe the answer is that it calls that for me. For instance:
object.connected = true
is going to call the
setConnected
(setter) of theQ_PROPERTY
. Whereas, saying something like:if(object.connected === true)
is going to call
connected
(getter) of theQ_PROPERTY
, correct? In other words, unless I plan on changing the value ofconnected
from QML then I do not need aWRITE
.Thanks for the correction @LeLev
-
hi
@RobM said in Working with Q_PROPERTY and exposing the back end to the front end.:
In other words, unless I plan on changing the value of connected from QML then I do not need a WRITE.
yes that is correct, if you don't have the WRITE method then it will become like a read-only property