IWizardFactory Class

class Core::IWizardFactory

The IWizardFactory class is the base class for all wizard factories. More...

Header: #include <coreplugin/iwizardfactory.h>
Inherits: QObject
Inherited By:

Core::BaseFileWizardFactory

Public Types

enum WizardFlag { PlatformIndependent, ForceCapitalLetterForFileName }
flags WizardFlags
enum WizardKind { FileWizard, ProjectWizard }

Public Functions

QString category() const
QString description() const
QString displayCategory() const
QString displayName() const
QIcon icon() const
Utils::Id id() const
Core::IWizardFactory::WizardKind kind() const
Utils::Wizard *runWizard(const Utils::FilePath &path, QWidget *parent, Utils::Id platform, const QVariantMap &variables, bool showWizard = true)

Detailed Description

Note: Instead of using this class, we recommend that you create JSON-based wizards, as instructed in Adding New Custom Wizards.

The wizard interface is a very thin abstraction for the wizards in File > New File and New Project. Basically, it defines what to show to the user in the wizard selection dialogs, and a hook that is called if the user selects the wizard.

Wizards can then perform any operations they like, including showing dialogs and creating files. Often it is not necessary to create your own wizard from scratch. Use one of the predefined wizards and adapt it to your needs.

To make your wizard known to the system, add your IWizardFactory instance to the plugin manager's object pool in your plugin's initialize function:

void MyPlugin::initialize()
{
    // ... do setup
    addAutoReleasedObject(new MyWizardFactory);
    // ... do more setup
}

See also Core::BaseFileWizardFactory and Core::BaseFileWizard.

Member Type Documentation

enum IWizardFactory::WizardFlag
flags IWizardFactory::WizardFlags

Holds information about the created projects and files.

ConstantValueDescription
Core::IWizardFactory::PlatformIndependent0x01The wizard creates projects that run on all platforms.
Core::IWizardFactory::ForceCapitalLetterForFileName0x02The wizard uses an initial capital letter for the names of new files.

The WizardFlags type is a typedef for QFlags<WizardFlag>. It stores an OR combination of WizardFlag values.

enum IWizardFactory::WizardKind

Used to specify what kind of objects the wizard creates. This information is used to show e.g. only wizards that create projects when selecting a New Project menu item.

ConstantValueDescription
Core::IWizardFactory::FileWizard0x01The wizard creates one or more files.
Core::IWizardFactory::ProjectWizard0x02The wizard creates a new project.

Member Function Documentation

QString IWizardFactory::category() const

Returns a category ID to add the wizard to.

QString IWizardFactory::description() const

Returns a translated description to show when this wizard is selected in the dialog.

QString IWizardFactory::displayCategory() const

Returns the translated string of the category, how it should appear in the dialog.

QString IWizardFactory::displayName() const

Returns the translated name of the wizard, how it should appear in the dialog.

QIcon IWizardFactory::icon() const

Returns an icon to show in the wizard selection dialog.

Utils::Id IWizardFactory::id() const

Returns an arbitrary id that is used for sorting within the category.

Core::IWizardFactory::WizardKind IWizardFactory::kind() const

Returns what kind of objects are created by the wizard.

Utils::Wizard *IWizardFactory::runWizard(const Utils::FilePath &path, QWidget *parent, Utils::Id platform, const QVariantMap &variables, bool showWizard = true)

Creates the wizard that the user selected for execution on the operating system platform with variables.

Any dialogs the wizard opens should use the given parent. The path argument is a suggestion for the location where files should be created. The wizard should fill this in its path selection elements as a default path.

When showWizard is false, the wizard instance is created and set up but not actually shown.

Copyright © The Qt Company Ltd. and other contributors. 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.