I've created a custom template for Qt Creator wizard which contains three files:
Now I'd also like to include a class to the project when the project is created. This class (including .h
and .cpp
files) should be named based on the user's input in the wizard.
I already managed to create the wizard for asking the class's name:
<fields>
<field mandatory="true" name="CLASS">
<fieldcontrol class="QLineEdit" defaulttext="MyClass" />
<fielddescription>Class name:</fielddescription>
</field>
</fields>
Now how do I create .h
and .cpp
files from the user input?
Ok, similar to the link you posted, what you want to do seems to be in the documentation already
Since you have your field named CLASS:
<field mandatory="true" name="CLASS">
You then use that field as the target of a file:
<files>
<file source="default.cpp" target="%CLASS:l%..%CppSourceSuffix%" openeditor="true" />
<file source="default.h" target="%CLASS:l%.%CppHeaderSuffix%" openeditor="true" />
</files>
Maybe you can try to modify an existing template first instead of creating from scratch?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.