Creating Wizards in Code
Introduction
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:
setId
setWizardKind
setIcon
setDescription
setDisplayName
setCategory
setDisplayCategory
setDescriptionImage
setRequiredFeatures
setFlags
- Implementing the wizard UI
Typically, this will be a class derived from Utils::Wizard. Utils::Wizard extends QWizard with the functionality to show a progress bar on the left.
- 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.
Relevant Classes
Class | Description |
---|---|
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. |
Setters and Getters of IWizardFactory
The setters and getters listed below determine how the wizard shows up in the list of wizards in the New File or Project dialog.
Type | Parameter Name | Description |
---|---|---|
Core::IWizardFactory::WizardKind | kind | Enumeration value that indicates the type of the wizard (project or file ). |
QIcon | icon | Icon to show. |
QString | description | Descriptive text. |
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.