Details
-
Suggestion
-
Resolution: Done
-
Not Evaluated
-
None
-
None
-
5b5ae971045adebe40209150cf9e1cac6cc62191 (qt-creator/qt-creator/master)
Description
I’ve been wishing for more flexibility in the feature that implements properties. (Right-click on a Q_PROPERTY declaration, and choose Refactor | Generate Missing Q_PROPERTY Members.) I have noticed a few use cases where it doesn’t help as much as it could.
1) It always writes the accessors as inline functions, so I then have to refactor again to move at least the setters to the .cpp file. (Sometimes I keep the getters inline.)
2) It always writes them in widget-programming style: the setter is a slot, and the signal has a parameter with the changed value. In Qt Quick we don’t use slots much, and signals don’t have parameters (but I’m not sure of the exact explanation why widgets need signal parameters and QtQuick doesn’t).
3) If my public class has a private class, there are no refactoring tools that have any clue about that. It’s so tedious to move and rename the new variables (remove the m_ prefix) and remove signal parameters and move the inline functions to the private class all at the same time, that I’m typically better off to duplicate an existing pair of setters.
4) Maybe it could write qdoc comments too?
So I think maybe it should first pop up a dialog with a few checkboxes. And perhaps the use case can be detected heuristically to pre-set the checkboxes: if the #includes bring in QtQuick or QML stuff, the signals won't need parameters; if a private class is declared, probably we want to put the variables and accessors there; otherwise, by default, the setters should be in the .cpp and the getters should be in the header. But have checkboxes for all these things.
Attachments
Issue Links
- relates to
-
QTCREATORBUG-20157 Add Refactor/"Quick Fix" to generate the boilerplate Q_PROPERTY code
- Closed
For Gerrit Dashboard: QTCREATORBUG-21804 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
310832,43 | CppEditor: Introduce QuickFix settings and unify getter/setter generation | master | qt-creator/qt-creator | Status: MERGED | +2 | 0 |