Some details about Qt properties system
As I promised, in this post I shall tell you about some details of Qt properties system. Most probably, you’ll find it useful if you are only familiar but haven’t used Qt properties much in your code yet. Using them is a good way to start integrating your application to QtQuick, where, as far as I know, Qt properties are mostly used. Correct me, if I’m not accurate. I shan’t explain you what Qt properties are, so if you don’t know about them, you may want to read the following article: http://doc.qt.io/qt-5/properties.html. This post actually will be quite short.
When reading the documentation, I’ve found out for myself that getters and setters are not properly explained. My main question was:
“Will be my custom READ and WRITE functions called if I use obj->property(...)
or obj->setProperty(..., ...)
in the code?”
Spoiler: the short answer is yes.
In my project I use the following code:
So calling both
and
will bring desirable side effects. The same applies to READ functions.
That’s all. Thanks for reading!