Creating Wizards in Code
If the functionality provided by template-based custom wizards is not sufficient for your case, you can write wizards in code.
A wizard in Qt Creator is an instance of a class implementing the Core::IWizardFactory interface that has a creator function registered with IWizardFactory::registerFactoryCreator.
Implementing wizards requires:
- Writing a factory class that derives from Core::IWizardFactory. This is a very generic interface that does not make any assumption about what the wizard does and what its UI looks like.
- Providing a set of parameters that determine how the wizard shows up in the list of wizards in the New File or Project dialog.
When deriving from Core::IWizardFactory, the constructor has to call the following setters provided by the base class:
- Implementing the wizard UI
- Implementing the wizard functionality
It is recommended to use Core::GeneratedFile to represent files that need to be written to disk. They allow to delay writing the actual data to disk till the wizard is done.
|Core::IWizardFactory||Qt Creator wizard interface, implementations of which are registered with ExtensionSystem::PluginManager.|
|Core::GeneratedFile||A file containing name, contents, and some attributes.|
|Utils::FileWizardPage||Introductory wizard page asking for file name and path.|
|Utils::ProjectIntroPage||Introductory wizard page asking for project name and path.|
The setters and getters listed below determine how the wizard shows up in the list of wizards in the New File or Project dialog.
|Core::IWizardFactory::WizardKind||kind||Enumeration value that indicates the type of the wizard (|
|QIcon||icon||Icon to show.|
|QString||displayName||Name to be shown in the list.|
|QString||id||Unique identifier for the wizard. It also determines the order within a category.|
|QString||category||Identifier of the category under which the wizard is to be listed. It also determines the order of the categories.|
|QString||displayCategory||Description of the category.|
All wizards that have the same category set will be grouped together in the New File or Project dialog.