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:

    • 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

Core::IWizardFactoryQt Creator wizard interface, implementations of which are registered with ExtensionSystem::PluginManager.
Core::GeneratedFileA file containing name, contents, and some attributes.
Utils::FileWizardPageIntroductory wizard page asking for file name and path.
Utils::ProjectIntroPageIntroductory 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.

TypeParameter NameDescription
Core::IWizardFactory::WizardKindkindEnumeration value that indicates the type of the wizard (project or file).
QIconiconIcon to show.
QStringdescriptionDescriptive text.
QStringdisplayNameName to be shown in the list.
QStringidUnique identifier for the wizard. It also determines the order within a category.
QStringcategoryIdentifier of the category under which the wizard is to be listed. It also determines the order of the categories.
QStringdisplayCategoryDescription of the category.

All wizards that have the same category set will be grouped together in the New File or Project dialog.