Extending Qt Creator Manual | Project

Extending Qt Creator Manual 4.4.0

# Project Class

(ProjectExplorer::Project)

The Project class implements a project node in the project explorer. More...

Header: | #include <Project>

- List of all members, including inherited members

## Public Types

enum | FilesMode { SourceFiles, GeneratedFiles, AllFiles }
enum | ModelRoles { FilePathRole, EnabledRole }
enum | RestoreResult { Ok, Error, UserAbort }

## Public Functions

| Project(const QString &mimeType, const Utils::FileName &fileName, const ProjectDocument::ProjectCallback &callback = {})
| ~Project() override
Target * | activeTarget() const
void | addTarget(Target *target)
virtual void | configureAsExampleProject(const QSet<Core::Id> &platforms)
ContainerNode * | containerNode() const
Target * | createTarget(Kit *k)
QString | displayName() const
Core::IDocument * | document() const
EditorConfiguration * | editorConfiguration() const
QStringList | files(FilesMode fileMode, const std::function<bool( const Node * ) > &filter = {}) const
virtual QStringList | filesGeneratedFrom(const QString &sourceFile) const
bool | hasActiveBuildSettings() const
Core::Id | id() const
virtual bool | knowsAllBuildExecutables() const
Utils::MacroExpander * | macroExpander() const
QVariant | namedSettings(const QString &name) const
virtual bool | needsConfiguration() const
virtual bool | needsSpecialDeployment() const
Kit::Predicate | preferredKitPredicate() const
Core::Context | projectContext() const
Utils::FileName | projectDirectory() const
Utils::FileName | projectFilePath() const
virtual ProjectImporter * | projectImporter() const
Core::Context | projectLanguages() const
bool | removeTarget(Target *target)
Kit::Predicate | requiredKitPredicate() const
virtual bool | requiresTargetPanel() const
RestoreResult | restoreSettings(QString *errorMessage)
Target * | restoreTarget(const QVariantMap &data)
virtual ProjectNode * | rootProjectNode() const
void | saveSettings()
void | setNamedSettings(const QString &name, const QVariant &value)
void | setup(QList<const BuildInfo *> infoList)
virtual bool | supportsKit(Kit *k, QString *errorMessage = nullptr) const
Target * | target(Core::Id id) const
Target * | target(Kit *k) const
QList<Target *> | targets() const
virtual QVariantMap | toMap() const

## Signals

void | aboutToRemoveTarget(ProjectExplorer::Target *target)
void | aboutToSaveSettings()
void | activeTargetChanged(ProjectExplorer::Target *target)
void | addedTarget(ProjectExplorer::Target *target)
void | buildConfigurationEnabledChanged()
void | buildDirectoryChanged()
void | displayNameChanged()
void | environmentChanged()
void | fileListChanged()
void | parsingFinished()
void | projectContextUpdated()
void | projectLanguagesUpdated()
void | removedTarget(ProjectExplorer::Target *target)
void | settingsLoaded()

## Static Public Members

bool | copySteps(Target *sourceTarget, Target *newTarget)
QString | makeUnique(const QString &preferredName, const QStringList &usedNames)
Utils::FileName | projectDirectory(const Utils::FileName &top)

## Protected Functions

void | addProjectLanguage(Core::Id id)
virtual RestoreResult | fromMap(const QVariantMap &map, QString *errorMessage)
virtual void | projectLoaded()
void | removeProjectLanguage(Core::Id id)
void | setDisplayName(const QString &name)
void | setId(Core::Id id)
void | setPreferredKitPredicate(const Kit::Predicate &predicate)
void | setProjectContext(Core::Context context)
void | setProjectLanguage(Core::Id id, bool enabled)
void | setProjectLanguages(Core::Context language)
void | setRequiredKitPredicate(const Kit::Predicate &predicate)
void | setRootProjectNode(ProjectNode *root)
virtual bool | setupTarget(Target *t)

## Detailed Description

The Project class implements a project node in the project explorer.

## Member Type Documentation

### enum Project::FilesMode

### enum Project::ModelRoles

### enum Project::RestoreResult

## Member Function Documentation

### Project::Project(const QString &mimeType, const Utils::FileName &fileName, const ProjectDocument::ProjectCallback &callback = {})

Copy constructor.

### Project::~Project()

Destroys the instance of Project.

### `[signal]` void Project::aboutToRemoveTarget(ProjectExplorer::Target *target)

### `[signal]` void Project::aboutToSaveSettings()

### Target *Project::activeTarget() const

### `[signal]` void Project::activeTargetChanged(ProjectExplorer::Target *target)

### `[protected]` void Project::addProjectLanguage(Core::Id id)

### void Project::addTarget(Target *target)

### `[signal]` void Project::addedTarget(ProjectExplorer::Target *target)

### `[signal]` void Project::buildConfigurationEnabledChanged()

A convenience signal emitted if activeBuildConfiguration emits isEnabledChanged() or if the active build configuration changes (including due to the active target changing).

### `[signal]` void Project::buildDirectoryChanged()

### `[virtual]` void Project::configureAsExampleProject(const QSet<Core::Id> &platforms)

### ContainerNode *Project::containerNode() const

### `[static]` bool Project::copySteps(Target *sourceTarget, Target *newTarget)

### Target *Project::createTarget(Kit *k)

### QString Project::displayName() const

See also setDisplayName().

### `[signal]` void Project::displayNameChanged()

### Core::IDocument *Project::document() const

### EditorConfiguration *Project::editorConfiguration() const

### `[signal]` void Project::environmentChanged()

A convenience signal emitted if activeBuildConfiguration emits environmentChanged or if the active build configuration changes (including due to the active target changing).

### `[signal]` void Project::fileListChanged()

### QStringList Project::files(FilesMode fileMode, const std::function<bool( const Node * ) > &filter = {}) const

### `[virtual]` QStringList Project::filesGeneratedFrom(const QString &sourceFile) const

### `[virtual protected]` RestoreResult Project::fromMap(const QVariantMap &map, QString *errorMessage)

### bool Project::hasActiveBuildSettings() const

### Core::Id Project::id() const

See also setId().

### `[virtual]` bool Project::knowsAllBuildExecutables() const

### Utils::MacroExpander *Project::macroExpander() const

### `[static]` QString Project::makeUnique(const QString &preferredName, const QStringList &usedNames)

### QVariant Project::namedSettings(const QString &name) const

See also setNamedSettings().

### `[virtual]` bool Project::needsConfiguration() const

### `[virtual]` bool Project::needsSpecialDeployment() const

### `[signal]` void Project::parsingFinished()

### Kit::Predicate Project::preferredKitPredicate() const

See also setPreferredKitPredicate().

### Core::Context Project::projectContext() const

See also setProjectContext().

### `[signal]` void Project::projectContextUpdated()

### Utils::FileName Project::projectDirectory() const

Returns the directory that contains the project.

This includes the absolute path.

### `[static]` Utils::FileName Project::projectDirectory(const Utils::FileName &top)

Returns the directory that contains the file top.

This includes the absolute path.

### Utils::FileName Project::projectFilePath() const

### `[virtual]` ProjectImporter *Project::projectImporter() const

### Core::Context Project::projectLanguages() const

See also setProjectLanguages().

### `[signal]` void Project::projectLanguagesUpdated()

### `[virtual protected]` void Project::projectLoaded()

### `[protected]` void Project::removeProjectLanguage(Core::Id id)

### bool Project::removeTarget(Target *target)

### `[signal]` void Project::removedTarget(ProjectExplorer::Target *target)

### Kit::Predicate Project::requiredKitPredicate() const

See also setRequiredKitPredicate().

### `[virtual]` bool Project::requiresTargetPanel() const

### RestoreResult Project::restoreSettings(QString *errorMessage)

### Target *Project::restoreTarget(const QVariantMap &data)

### `[virtual]` ProjectNode *Project::rootProjectNode() const

See also setRootProjectNode().

### void Project::saveSettings()

### `[protected]` void Project::setDisplayName(const QString &name)

See also displayName().

### `[protected]` void Project::setId(Core::Id id)

See also id().

### void Project::setNamedSettings(const QString &name, const QVariant &value)

See also namedSettings().

### `[protected]` void Project::setPreferredKitPredicate(const Kit::Predicate &predicate)

See also preferredKitPredicate().

### `[protected]` void Project::setProjectContext(Core::Context context)

See also projectContext().

### `[protected]` void Project::setProjectLanguage(Core::Id id, bool enabled)

### `[protected]` void Project::setProjectLanguages(Core::Context language)

See also projectLanguages().

### `[protected]` void Project::setRequiredKitPredicate(const Kit::Predicate &predicate)

See also requiredKitPredicate().

### `[protected]` void Project::setRootProjectNode(ProjectNode *root)

See also rootProjectNode().

### `[signal]` void Project::settingsLoaded()

### void Project::setup(QList<const BuildInfo *> infoList)

### `[virtual protected]` bool Project::setupTarget(Target *t)

### `[virtual]` bool Project::supportsKit(Kit *k, QString *errorMessage = nullptr) const

### Target *Project::target(Core::Id id) const

### Target *Project::target(Kit *k) const

### QList<Target *> Project::targets() const

### `[virtual]` QVariantMap Project::toMap() const

Serializes all data into a QVariantMap.

This map is then saved in the .user file of the project. Just put all your data into the map.

Note: Do not forget to call your base class' toMap function.

Note: Do not forget to call setActiveBuildConfiguration when creating new build configurations.