[Qt-creator] Customizing the target path for custom Qt Creator class wizard

Andrew Britton andrew.d.britton at gmail.com
Fri Aug 28 06:15:53 CEST 2015


I know my response is a few years late, but I just came across this post
trying to figure the same thing out and I have a possible solution. It
isn’t elegant but it seems to work.

Here’s my class wizard.xml which should explain it all.



<wizard version="1" kind="class" id="A.cbsd_class_template"
category="B.CBSDCustomClasses">

    <description>Creates a CBSD C++ Class Template.</description>

    <displayname>C++ Class Template</displayname>

    <icon>console.png</icon>

    <displaycategory>CBSD Custom Classes</displaycategory>

    <files>

        <file source="cbsd_class_template.cpp"
target="*%SourceFolder%/%*ClassName:l%.%CppSourceSuffix%"
openeditor="true"/>

        <file source="cbsd_class_template.h"
target="*%HeaderFolder%/*%ClassName:l%.%CppHeaderSuffix%"
openeditor="true"/>

    </files>

    <!-- Create parameter wizard page -->

    <fieldpagetitle>cbsd_class_template parameters</fieldpagetitle>

    <fields>

        <field name="ClassName">

            <fieldcontrol class="QLineEdit" validator="^[a-zA-Z0-9_]+$"
defaulttext="CBSD_class" />

            <fielddescription>Class name:</fielddescription>

        </field>

        <field name="Description">

            <fieldcontrol class="QLineEdit" validator="^[a-zA-Z0-9_
,.()]+$" defaulttext="Description of the class" />

            <fielddescription>Class Description:</fielddescription>

        </field>

        <field name="*HeaderFolder*">

            <fieldcontrol class="QLineEdit" validator="^[a-zA-Z0-9_]+$"
defaulttext="header" />

            <fielddescription>Header SubFolder Name:</fielddescription>

        </field>

        <field name="*SourceFolder*">

            <fieldcontrol class="QLineEdit" validator="^[a-zA-Z0-9_]+$"
defaulttext="source" />

            <fielddescription>Source SubFolder Name:</fielddescription>

        </field>

    </fields>

    <!-- Example of a validation rule -->

    <validationrules>

        <validationrule condition='"%ClassName%" != "cbsd_class_template"'>

            <message>%ClassName% cannot be used as class name.</message>

        </validationrule>

    </validationrules>

</wizard>



This is what I used to start my source file in the wizard



#include "*%HeaderFolder%*/%ClassName:l%.%CppHeaderSuffix%"

-- 
www.andrewbritton.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qt-creator/attachments/20150827/8bc9899d/attachment.html>


More information about the Qt-creator mailing list