QtCreator Template Wizard: skips dashes in% Variable% ProjectName%

I'm trying to create a template wizard in which the project name (recorded in the "New project .." dialog box) is reset and used to create different things in C ++ (namespace, library name, whatever ..), so the generated names are not may contain dashes, begin with numbers, etc.

For example, in wizard.xml, the LIBRARYNAME variable LIBRARYNAME generated from user input, but the default is %ProjectName:l% :

 <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> 

When using validator = '^[^-]+$' regexp thingy, I can prevent users from entering dashes ('-') in the variable, but I cannot prevent them from executing when setting the %ProjectName% variable.

Is there any way to skip unwanted characters in %ProjectName% and / or other variables used by the wizard? For example, when generating "defaulttext" in xml.

I have tried using different javascript-like things so far, but nothing has worked and the documents in Template Wizards are too simple and they do not cover these things.

Now my option removes the default text in forms, but that sucks! I want to do cool things like creating a namespace name from a project name.

+5
source share
1 answer

Are regular validation rules invalid with the variable% ProjectName%? You tried to add something like:

  <validationrules> <validationrule condition='/^[^-]+$/.test("%ProjectName%")'> <message>%ProjectName% cannot be used as project name.</message> </validationrule> </validationrules> 
+3
source

Source: https://habr.com/ru/post/1207134/


All Articles