Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
When to use Q_PROPERTY
br1ghtch1p last edited by
When does one need to declare and define Q_PROPERTY in a class. Or putting the question another way around, when does a class require Q_PROPERTY?
Rolias last edited by
Well one case where you would "need" to use it is if you wanted to access a property indirectly through it's name, or wanted to have a class that could be "discovered" through its meta properties. The "help topic":http://qt-project.org/doc/qt-5/properties.html has a pretty good description.
I know when I'm using Qt Quick for my front end and I want the QML to have access to my C++ getters and setters Q_PROPERTY is the tool I reach for.