Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QtCreator template wizard: skipping dashes in %ProjectName% variable

Tags:

xml

qt

qt-creator

I'm trying to create a template wizard in which the project name (captured in the "New Project.." dialogs) is downcased and used to generate different things in C++ (a namespace, a library name, whatever..), so the generated names cannot contain dashes, begin with numbers, etc.

For instance, in wizard.xml, the variable LIBRARYNAME is generated from user input, BUT it takes a downcased %ProjectName:l% as default:

<fieldpagetitle>Project Configuration</fieldpagetitle>
    <fields>
    <!-- Library name -->
        <field mandatory="true" name="LIBRARYNAME">
            <fieldcontrol class="QLineEdit" validator='^[^-]+$'
                          defaulttext="%ProjectName:l%" />
            <fielddescription>Name for created library (all lowercase)</fielddescription>
        </field>

With the validator = '^[^-]+$' regexp thingy I can prevent users from introducing dashes ('-') in the variable BUT I can't prevent them doing the same when setting the %ProjectName% variable.

Is there any possible way of skipping undesired symbols in %ProjectName% and/or other variables used by the wizard? For instance when generating the "defaulttext" in the xml.

I have tried using different javascript-like things so far, but nothing worked and the docs on Template Wizards are too simple and they don't cover these things.

Right now my option is removing the default text in the forms, but that sucks!!! I want to do cool things like generating a namespace name from the project name.

like image 555
Яois Avatar asked Oct 20 '22 22:10

Яois


1 Answers

Does the normal validation rules not work with %ProjectName% variable?? Have you tried adding something like :

 <validationrules>
    <validationrule condition='/^[^-]+$/.test("%ProjectName%")'>
        <message>%ProjectName% cannot be used as project name.</message>
    </validationrule>
 </validationrules>
like image 132
jester Avatar answered Oct 22 '22 20:10

jester