当前位置:网站首页>QT creator add custom new file / Project Template Wizard

QT creator add custom new file / Project Template Wizard

2022-07-07 23:52:00 Raring_ Ringtail

Qt Creator Add custom new file / Project Template Wizard

Translated from :https://doc.qt.io/qtcreator/creator-project-wizards.html

If you have a team that is building large applications or developing multiple applications , You may want to standardize the way team members create projects and documents .

You can copy the new wizard template in the template folder to create your own project wizard and file wizard . When you click File > New File or Project They will be New The dialog box displays .

In the customized new wizard , You can customize a series of wizard page user interfaces . The value filled in by the user in the wizard is assigned to the field name . Field names and values are then used during file creation .

Wizard type

In a project wizard , You can specify the files needed for a project . You can add wizard pages to allow developers to specify settings for the project .

The file wizard is similar to the project wizard , But it does not contain any project files .

It is recommended that you create one based on JSON Wizard for . It is based on XML Superset of wizard . More on :
Translation notes :(Qt Creator The steps and detailed documents of the new wizard are mainly in the following two articles , I translated it based on JSON Of )

Find the location of the wizard template

Wizard templates are located in subfolders of the following folder :

  • share/qtcreator/templates/wizards

  • /opt/Qt5.13.0/Tools/QtCreator/share/qtcreator/templates/wizards

  • Local user configuration folder

    Linux And macOS System :$HOME/.config/QtProject/qtcreator/templates/wizards

    Windows System : %APPDATA%\QtProject\qtcreator\templates\wizards

Be careful : If you're using a macOS, You can Qt Creator.app/Contents/Resources/templates/wizards Find

Some skills of wizard development

Qt Creator There are some actions that can improve the wizard development process . They are not bound to shortcut keys by default , So it can't trigger . To enable them , You can set it after entering the shortcut key :Tools > Options > Environment > Keyboard > Wizard

The following actions can help the wizard develop :

operation describe
Inspect Triggering this operation will open a window , List all defined fields and variables in the wizard when the operation is triggered . for example , Each time this operation is triggered, a new modeless window opens , You can compare the status of different wizard pages .
Factory.Reset Triggering this operation will make Qt Creator Forget all the guide factories , Make it open in File > New File or Project Reload all wizard definitions . So you can change the wizard definition , Don't have to restart Qt Creator You can see the effect .

Detailed output

When developing custom wizards ( Including based on JSON Based on XML Wizard for ), It is recommended to start Qt Creator When combined with -customwizard-verbose Parameters . In this way, each wizard being set will produce the following output :
Be careful :

Checking "/home/jsmith/.config/QtProject/qtcreator/templates/wizards/mywizard"
for wizard.json.
* Configuration found and parsed.

There is... In the output message wizard.json The name of the folder where the file is located . If no files are found , This message will not be displayed .

If there is an error in the file , For example, invalid icon address , The following information will be displayed :

Checking "/home/jsmith/.config/QtProject/qtcreator/templates/wizards/mywizard"
for wizard.json.
* Configuration found and parsed.
* Failed to create: Icon file
"/home/jsmith/.config/QtProject/qtcreator/templates/wizards/mywizard/../.. /global/genericfilewizard.png" not found.

see Use command line options Get more information about command line parameters .


Welcome to my official account. : Notes on Jiangda

原网站

版权声明
本文为[Raring_ Ringtail]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202130554126207.html