Details
-
Suggestion
-
Resolution: Done
-
Not Evaluated
-
None
-
None
-
5b5ae971045adebe40209150cf9e1cac6cc62191 (qt-creator/qt-creator/master)
Description
When we do "Refactor / Generate Missing Q_PROPERTY Members...", Qt Creator puts the corresponding setters in the public slots area of the class.
In most case, when I (and I think I'm not the only one) want to expose a property, I don't want to expose its accessors, I want them to be abstracted by the property system, that's the whole reason to use it for me.
When I use a Q_PROPERTY, it's in general to expose a property to QML, and after generating the boilerplate, I have to move the setters from "public slots" to "public"
Examples in the Qt source where properties' setters are not slots:
https://code.woboq.org/qt5/qtdeclarative/src/quick/items/qquickrectangle_p.h.html#66
https://code.woboq.org/qt5/qtbase/src/corelib/itemmodels/qabstractproxymodel.h.html#56 for something not related to Qt Quick
In some cases, it makes sense to have setters as slots (like in QLabel), but I think it should be a conscious decision to define those as slots and not the default.
This doesn't have a high priority but the fix should be simple enough, modify
https://code.woboq.org/qt5/qt-creator/src/plugins/cppeditor/cppquickfixes.cpp.html#4466 and the corresponding test.
This would add some quality of life and encourage Qt best practices.
The question is whether we want to change this behavior.