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 New Project dialog.
When deriving from Core::IWizardFactory, the constructor has to call the following setters provided by the base class:
- 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.
|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 New 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 New Project dialog.
© 2023 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.