Pregunta

I've created a custom template for Qt Creator wizard which contains three files:

  • main.cpp
  • project.pro
  • wizard.xml

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?

¿Fue útil?

Solución

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?

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top