Details
-
Sub-task
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
None
Description
It would be useful to have a feature that automatically creates field definitions.
E.g. if you write:
this->mLabel = new QLabel();
and then call such an feature "auto create private field" for mLabel, it should:
- infer from the assignment that the type of mLabel must be QLabel*
- determine which class this belong to
- automatically create a private field "QLabel* mLabel" in the header
- create a forward class definition "class QLabel;" before the this-class in the header
- include the <QLabel>-header in the cpp
The last two steps should of course only be performed, if the definitions aren't already there, and if the type is a pointer. For non pointer types, Qt Creator has to include the required header in the corresponding header. It is also important that it finds the correct header (for non qt-types it could look at the includes of other files in the project), and that it chooses between struct/class forward definitions.
This could also be done for different classes than the this-class above. E.g:
MyStrangeClass foo;
foo->bar = new QLabel();
could auto create a field QLabel* bar in the class MyStrangeClass.
(this is like 1532, but for fields instead of methods)