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

Britton, Andrew D Andrew.Britton at cbs.com
Fri Aug 28 06:14:35 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%"


Andrew Britton
Senior Tools Developer

[cid:17F963B2-FFD1-4953-A9CC-67657C6F3ED5]
7800 Beverly Blvd, Ste.112
Los Angeles, CA 90036
323+575+2310
cbsdvfx.com<http://cbsdvfx.com/>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qt-creator/attachments/20150828/ab906d8a/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 8460 bytes
Desc: image001.png
URL: <http://lists.qt-project.org/pipermail/qt-creator/attachments/20150828/ab906d8a/attachment.png>


More information about the Qt-creator mailing list