本页内容

Core::IWizardFactory Class

class Core::IWizardFactory

IWizardFactory 类是所有向导工厂的基类。更多内容...

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

Core::BaseFileWizardFactory

公共类型

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

公共函数

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, Utils::Id platform, const QVariantMap &variables, bool showWizard = true)

详细说明

注意: 我们建议您不要使用此类,而是按照 《添加新的自定义向导》中的说明,创建基于 JSON 的向导。

向导接口是对File >New File 和New Project 中向导的一种非常轻量级的抽象。基本上,它定义了在向导选择对话框中向用户显示的内容,以及当用户选择该向导时被调用的钩子。

随后,向导可以执行任何所需操作,包括显示对话框和创建文件。通常情况下,没有必要从头开始创建自己的向导。请使用预定义的向导之一,并根据您的需求进行调整。

要让系统识别您的向导,请在插件的 initialize 函数中,将您的 IWizardFactory 实例添加到插件管理器的对象池中:

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

另请参阅 Core::BaseFileWizardFactory 和Core::BaseFileWizard 。

成员类型文档

enum IWizardFactory::WizardFlag
flags IWizardFactory::WizardFlags

保存有关已创建项目和文件的信息。

常量值描述
Core::IWizardFactory::PlatformIndependent0x01向导会创建可在所有平台上运行的项目。
Core::IWizardFactory::ForceCapitalLetterForFileName0x02向导会为新文件的名称使用首字母大写。

WizardFlags 类型是QFlags<WizardFlag> 的 typedef。它存储 WizardFlag 值的按“或”运算组合。

enum IWizardFactory::WizardKind

用于指定向导将创建何种对象。此信息用于实现以下功能:例如,在选择“New Project ”菜单项时,仅显示可创建项目的向导。

常量值描述
Core::IWizardFactory::FileWizard0x01向导将创建一个或多个文件。
Core::IWizardFactory::ProjectWizard0x02向导将创建一个新项目。

成员函数文档

QString IWizardFactory::category() const

返回要将向导添加到的类别 ID。

QString IWizardFactory::description() const

返回一段翻译后的说明文本,用于在对话框中选中此向导时显示。

QString IWizardFactory::displayCategory() const

返回该分类的翻译字符串,即该字符串在对话框中应显示的内容。

QString IWizardFactory::displayName() const

返回向导的翻译名称,即该名称在对话框中应显示的名称。

QIcon IWizardFactory::icon() const

返回一个图标,用于在向导选择对话框中显示。

Utils::Id IWizardFactory::id() const

返回一个用于在该类别内进行排序的任意 ID。

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

返回向导创建的对象类型。

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

使用 `variables` 在操作系统 `platform ` 上创建用户选择要执行的向导。

path 参数是建议的文件创建位置。向导应将其作为默认路径填入其路径选择控件中。

当showWizard 为false 时,将创建并配置向导实例,但不会实际显示该实例。

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.