QGIS API Documentation  2.99.0-Master (c42dad3)
Public Slots | Signals | Public Member Functions | Static Public Member Functions | Properties | List of all members
QgsProject Class Reference

Reads and writes project states. More...

#include <qgsproject.h>

Inheritance diagram for QgsProject:
Inheritance graph
[legend]

Public Slots

void setDirty (bool b=true)
 Flag the project as dirty (modified). More...
 

Signals

void avoidIntersectionsListChanged ()
 Emitted whenever avoidIntersectionsList has changed. More...
 
void fileNameChanged ()
 Emitted when the file name of the project changes. More...
 
void homePathChanged ()
 Emitted when the home path of the project changes. More...
 
void layerLoaded (int i, int n)
 Emitted when a layer from a projects was read. More...
 
void loadingLayer (const QString &)
 
void mapThemeCollectionChanged ()
 Emitted when the map theme collection changes. More...
 
void nonIdentifiableLayersChanged (QStringList nonIdentifiableLayers)
 Emitted when the list of layer which are excluded from map identification changes. More...
 
void oldProjectVersionWarning (const QString &)
 emitted when an old project file is read. More...
 
void projectSaved ()
 emitted when the project file has been written and closed More...
 
void readMapLayer (QgsMapLayer *mapLayer, const QDomElement &layerNode)
 Emitted, after the basic initialization of a layer from the project file is done. More...
 
void readProject (const QDomDocument &)
 emitted when project is being read More...
 
void snappingConfigChanged ()
 emitted whenever the configuration for snapping has changed More...
 
void topologicalEditingChanged ()
 Emitted when the topological editing flag has changed. More...
 
void transactionGroupsChanged ()
 Emitted whenever a new transaction group has been created or a transaction group has been removed. More...
 
void variablesChanged ()
 Emitted whenever the expression variables stored in the project have been changed. More...
 
void writeMapLayer (QgsMapLayer *mapLayer, QDomElement &layerElem, QDomDocument &doc)
 Emitted, when a layer is being saved. More...
 
void writeProject (QDomDocument &)
 emitted when project is being written More...
 

Public Member Functions

 ~QgsProject ()
 
QgsUnitTypes::AreaUnit areaUnits () const
 Convenience function to query default area measurement units for project. More...
 
bool autoTransaction () const
 Transactional editing means that on supported datasources (postgres databases) the edit state of all tables that originate from the same database are synchronized and executed in a server side transaction. More...
 
QStringList avoidIntersectionsList () const
 A list of layers with which intersections should be avoided. More...
 
void clear ()
 Clear the project - removes all settings and resets it back to an empty, default state. More...
 
QgsLayerTreeGroupcreateEmbeddedGroup (const QString &groupName, const QString &projectFilePath, const QStringList &invisibleLayers)
 Create layer group instance defined in an arbitrary project file. More...
 
bool createEmbeddedLayer (const QString &layerId, const QString &projectFilePath, QList< QDomNode > &brokenNodes, QList< QPair< QgsVectorLayer *, QDomElement > > &vectorLayerList, bool saveFlag=true)
 Creates a maplayer instance defined in an arbitrary project file. More...
 
QgsExpressionContext createExpressionContext () const override
 This method needs to be reimplemented in all classes which implement this interface and return an expression context. More...
 
QgsCoordinateReferenceSystem crs () const
 Returns the project's native coordinate reference system. More...
 
QgsUnitTypes::DistanceUnit distanceUnits () const
 Convenience function to query default distance measurement units for project. More...
 
void dumpProperties () const
 Dump out current project properties to stderr. More...
 
QString ellipsoid () const
 Returns a proj string representing the project's ellipsoid setting, eg "WGS84". More...
 
QStringList entryList (const QString &scope, const QString &key) const
 Return keys with values – do not return keys that contain other keys. More...
 
QString error () const
 Return error message from previous read/write. More...
 
bool evaluateDefaultValues () const
 Should default values be evaluated on provider side when requested and not when committed. More...
 
QFileInfo fileInfo () const
 Returns QFileInfo object for the project's associated file. More...
 
QString fileName () const
 Returns the project's file name. More...
 
QString homePath () const
 Return project's home path. More...
 
bool isDirty () const
 Returns true if the project has been modified since the last write() More...
 
QString layerIsEmbedded (const QString &id) const
 Returns project file path if layer is embedded from other project file. Returns empty string if layer is not embedded. More...
 
QgsLayerTreeRegistryBridgelayerTreeRegistryBridge () const
 Return pointer to the helper class that synchronizes map layer registry with layer tree. More...
 
QgsLayerTreeGrouplayerTreeRoot () const
 Return pointer to the root (invisible) node of the project's layer tree. More...
 
QgsMapThemeCollectionmapThemeCollection ()
 Returns pointer to the project's map theme collection. More...
 
QStringList nonIdentifiableLayers () const
 Get the list of layers which currently should not be taken into account on map identification. More...
 
bool read (const QFileInfo &file)
 Reads a project file. More...
 
bool read ()
 Reads the current project file. More...
 
bool read (QDomNode &layerNode)
 Reads the layer described in the associated DOM node. More...
 
bool readBoolEntry (const QString &scope, const QString &key, bool def=false, bool *ok=nullptr) const
 
double readDoubleEntry (const QString &scope, const QString &key, double def=0, bool *ok=nullptr) const
 
QString readEntry (const QString &scope, const QString &key, const QString &def=QString::null, bool *ok=nullptr) const
 
QStringList readListEntry (const QString &scope, const QString &key, const QStringList &def=QStringList(), bool *ok=nullptr) const
 Key value accessors. More...
 
int readNumEntry (const QString &scope, const QString &key, int def=0, bool *ok=nullptr) const
 
QString readPath (QString filename) const
 Turn filename read from the project file to an absolute path. More...
 
QgsRelationManagerrelationManager () const
 
bool removeEntry (const QString &scope, const QString &key)
 Remove the given key. More...
 
void setAreaUnits (QgsUnitTypes::AreaUnit unit)
 Sets the default area measurement units for the project. More...
 
void setAutoTransaction (bool autoTransaction)
 Transactional editing means that on supported datasources (postgres databases) the edit state of all tables that originate from the same database are synchronized and executed in a server side transaction. More...
 
void setAvoidIntersectionsList (const QStringList &avoidIntersectionsList)
 A list of layers with which intersections should be avoided. More...
 
void setBadLayerHandler (QgsProjectBadLayerHandler *handler)
 Change handler for missing layers. More...
 
void setCrs (const QgsCoordinateReferenceSystem &crs)
 Sets the project's native coordinate reference system. More...
 
void setDistanceUnits (QgsUnitTypes::DistanceUnit unit)
 Sets the default distance measurement units for the project. More...
 
void setEllipsoid (const QString &ellipsoid)
 Sets the project's ellipsoid from a proj string representation, eg "WGS84". More...
 
void setEvaluateDefaultValues (bool evaluateDefaultValues)
 Defines if default values should be evaluated on provider side when requested and not when committed. More...
 
void setFileName (const QString &name)
 Sets the file name associated with the project. More...
 
void setNonIdentifiableLayers (const QList< QgsMapLayer *> &layers)
 Set a list of layers which should not be taken into account on map identification. More...
 
void setNonIdentifiableLayers (const QStringList &layerIds)
 Set a list of layers which should not be taken into account on map identification. More...
 
void setSnappingConfig (const QgsSnappingConfig &snappingConfig)
 The snapping configuration for this project. More...
 
void setTitle (const QString &title)
 Sets the project's title. More...
 
void setTopologicalEditing (bool enabled)
 Convenience function to set topological editing. More...
 
void setVariables (const QgsStringMap &variables)
 A map of custom project variables. More...
 
QgsSnappingConfig snappingConfig () const
 The snapping configuration for this project. More...
 
QStringList subkeyList (const QString &scope, const QString &key) const
 Return keys with keys – do not return keys that contain only values. More...
 
QString title () const
 Returns the project's title. More...
 
bool topologicalEditing () const
 Convenience function to query topological editing status. More...
 
QMap< QPair< QString, QString >, QgsTransactionGroup * > transactionGroups ()
 Map of transaction groups. More...
 
QgsStringMap variables () const
 A map of custom project variables. More...
 
bool write (const QFileInfo &file)
 Writes the project to a file. More...
 
bool write ()
 Writes the project to its current associated file (see fileName() ). More...
 
bool writeEntry (const QString &scope, const QString &key, bool value)
 Write a boolean entry to the project file. More...
 
bool writeEntry (const QString &scope, const QString &key, double value)
 Write a double entry to the project file. More...
 
bool writeEntry (const QString &scope, const QString &key, int value)
 Write an integer entry to the project file. More...
 
bool writeEntry (const QString &scope, const QString &key, const QString &value)
 Write a string entry to the project file. More...
 
bool writeEntry (const QString &scope, const QString &key, const QStringList &value)
 Write a string list entry to the project file. More...
 
QString writePath (const QString &filename, const QString &relativeBasePath=QString::null) const
 Prepare a filename to save it to the project file. More...
 
- Public Member Functions inherited from QgsExpressionContextGenerator
virtual ~QgsExpressionContextGenerator ()
 

Static Public Member Functions

static QgsProjectinstance ()
 Returns the QgsProject singleton instance. More...
 

Properties

QStringList avoidIntersectionsList
 
QgsCoordinateReferenceSystem crs
 
QString fileName
 
QString homePath
 
QgsMapThemeCollection mapThemeCollection
 
QStringList nonIdentifiableLayers
 
QgsSnappingConfig snappingConfig
 

Detailed Description

Reads and writes project states.

Note

Has two general kinds of state to make persistent. (I.e., to read and write.) First, QGIS proprietary information. Second plug-in information.

A singleton since there shall only be one active project at a time; and provides canonical location for plug-ins and main app to find/set properties.

Definition at line 75 of file qgsproject.h.

Constructor & Destructor Documentation

§ ~QgsProject()

QgsProject::~QgsProject ( )

Definition at line 340 of file qgsproject.cpp.

Member Function Documentation

§ areaUnits()

QgsUnitTypes::AreaUnit QgsProject::areaUnits ( ) const

Convenience function to query default area measurement units for project.

Note
added in QGIS 2.14
See also
distanceUnits()

Definition at line 2088 of file qgsproject.cpp.

§ autoTransaction()

bool QgsProject::autoTransaction ( ) const

Transactional editing means that on supported datasources (postgres databases) the edit state of all tables that originate from the same database are synchronized and executed in a server side transaction.

Note
Added in QGIS 2.16

Definition at line 2165 of file qgsproject.cpp.

§ avoidIntersectionsList()

QStringList QgsProject::avoidIntersectionsList ( ) const

A list of layers with which intersections should be avoided.

Note
Added in QGIS 3.0

§ avoidIntersectionsListChanged

void QgsProject::avoidIntersectionsListChanged ( )
signal

Emitted whenever avoidIntersectionsList has changed.

Note
Added in QGIS 3.0

§ clear()

void QgsProject::clear ( )

Clear the project - removes all settings and resets it back to an empty, default state.

Note
added in 2.4

Definition at line 441 of file qgsproject.cpp.

§ createEmbeddedGroup()

QgsLayerTreeGroup * QgsProject::createEmbeddedGroup ( const QString &  groupName,
const QString &  projectFilePath,
const QStringList &  invisibleLayers 
)

Create layer group instance defined in an arbitrary project file.

Note
: added in version 2.4

Definition at line 1937 of file qgsproject.cpp.

§ createEmbeddedLayer()

bool QgsProject::createEmbeddedLayer ( const QString &  layerId,
const QString &  projectFilePath,
QList< QDomNode > &  brokenNodes,
QList< QPair< QgsVectorLayer *, QDomElement > > &  vectorLayerList,
bool  saveFlag = true 
)

Creates a maplayer instance defined in an arbitrary project file.

Caller takes ownership

Returns
the layer or 0 in case of error
Note
not available in Python bindings

Definition at line 1787 of file qgsproject.cpp.

§ createExpressionContext()

QgsExpressionContext QgsProject::createExpressionContext ( ) const
overridevirtual

This method needs to be reimplemented in all classes which implement this interface and return an expression context.

Note
Added in QGIS 3.0

Implements QgsExpressionContextGenerator.

Definition at line 1035 of file qgsproject.cpp.

§ crs()

QgsCoordinateReferenceSystem QgsProject::crs ( ) const

Returns the project's native coordinate reference system.

Note
added in QGIS 2.18
See also
setCrs()
ellipsoid()

§ distanceUnits()

QgsUnitTypes::DistanceUnit QgsProject::distanceUnits ( ) const

Convenience function to query default distance measurement units for project.

Note
added in QGIS 2.14
See also
setDistanceUnits()
areaUnits()

Definition at line 2070 of file qgsproject.cpp.

§ dumpProperties()

void QgsProject::dumpProperties ( ) const

Dump out current project properties to stderr.

Definition at line 1549 of file qgsproject.cpp.

§ ellipsoid()

QString QgsProject::ellipsoid ( ) const

Returns a proj string representing the project's ellipsoid setting, eg "WGS84".

See also
setEllipsoid()
crs()
Note
added in QGIS 2.18

Definition at line 430 of file qgsproject.cpp.

§ entryList()

QStringList QgsProject::entryList ( const QString &  scope,
const QString &  key 
) const

Return keys with values – do not return keys that contain other keys.

Note
equivalent to QSettings entryList()

Definition at line 1515 of file qgsproject.cpp.

§ error()

QString QgsProject::error ( ) const

Return error message from previous read/write.

Definition at line 1761 of file qgsproject.cpp.

§ evaluateDefaultValues()

bool QgsProject::evaluateDefaultValues ( ) const

Should default values be evaluated on provider side when requested and not when committed.

Note
added in 2.16

Definition at line 2040 of file qgsproject.cpp.

§ fileInfo()

QFileInfo QgsProject::fileInfo ( ) const

Returns QFileInfo object for the project's associated file.

See also
fileName()
Note
added in QGIS 2.9

Definition at line 406 of file qgsproject.cpp.

§ fileName()

QString QgsProject::fileName ( ) const

Returns the project's file name.

This is the file which contains the project's XML representation.

See also
setFileName()
fileInfo()

§ fileNameChanged

void QgsProject::fileNameChanged ( )
signal

Emitted when the file name of the project changes.

§ homePath()

QString QgsProject::homePath ( ) const

Return project's home path.

Returns
home path of project (or QString::null if not set)

§ homePathChanged

void QgsProject::homePathChanged ( )
signal

Emitted when the home path of the project changes.

§ instance()

QgsProject * QgsProject::instance ( )
static

Returns the QgsProject singleton instance.

Definition at line 348 of file qgsproject.cpp.

§ isDirty()

bool QgsProject::isDirty ( ) const

Returns true if the project has been modified since the last write()

Definition at line 374 of file qgsproject.cpp.

§ layerIsEmbedded()

QString QgsProject::layerIsEmbedded ( const QString &  id) const

Returns project file path if layer is embedded from other project file. Returns empty string if layer is not embedded.

Definition at line 1777 of file qgsproject.cpp.

§ layerLoaded

void QgsProject::layerLoaded ( int  i,
int  n 
)
signal

Emitted when a layer from a projects was read.

Parameters
icurrent layer
nnumber of layers

§ layerTreeRegistryBridge()

QgsLayerTreeRegistryBridge* QgsProject::layerTreeRegistryBridge ( ) const
inline

Return pointer to the helper class that synchronizes map layer registry with layer tree.

Note
added in 2.4

Definition at line 390 of file qgsproject.h.

§ layerTreeRoot()

QgsLayerTreeGroup * QgsProject::layerTreeRoot ( ) const

Return pointer to the root (invisible) node of the project's layer tree.

Note
added in 2.4

Definition at line 2120 of file qgsproject.cpp.

§ loadingLayer

void QgsProject::loadingLayer ( const QString &  )
signal

§ mapThemeCollection()

QgsMapThemeCollection* QgsProject::mapThemeCollection ( )

Returns pointer to the project's map theme collection.

Note
added in QGIS 2.12
renamed in QGIS 3.0, formerly QgsVisibilityPresetCollection

§ mapThemeCollectionChanged

void QgsProject::mapThemeCollectionChanged ( )
signal

Emitted when the map theme collection changes.

This only happens when the map theme collection is reset. Any pointer previously received from mapThemeCollection() must no longer be used after this signal is emitted. You must still connect to signals from the map theme collection if you want to be notified about new map themes being added and map themes being removed.

Note
Added in QGIS 3.0

§ nonIdentifiableLayers()

QStringList QgsProject::nonIdentifiableLayers ( ) const

Get the list of layers which currently should not be taken into account on map identification.

§ nonIdentifiableLayersChanged

void QgsProject::nonIdentifiableLayersChanged ( QStringList  nonIdentifiableLayers)
signal

Emitted when the list of layer which are excluded from map identification changes.

§ oldProjectVersionWarning

void QgsProject::oldProjectVersionWarning ( const QString &  )
signal

emitted when an old project file is read.

§ projectSaved

void QgsProject::projectSaved ( )
signal

emitted when the project file has been written and closed

§ read() [1/3]

bool QgsProject::read ( const QFileInfo &  file)

Reads a project file.

Parameters
filename of project file to read
Note
Any current plug-in state is erased
Calling read() performs the following operations:
  • Gets the extents
  • Creates maplayers
  • Registers maplayers
Note
it's presumed that the caller has already reset the map canvas, map registry, and legend

Definition at line 758 of file qgsproject.cpp.

§ read() [2/3]

bool QgsProject::read ( )

Reads the current project file.

Note
Any current plug-in state is erased
Calling read() performs the following operations:
  • Gets the extents
  • Creates maplayers
  • Registers maplayers
Note
it's presumed that the caller has already reset the map canvas, map registry, and legend

Shows a warning when an old project file is read.

Definition at line 765 of file qgsproject.cpp.

§ read() [3/3]

bool QgsProject::read ( QDomNode &  layerNode)

Reads the layer described in the associated DOM node.

Parameters
layerNoderepresents a QgsProject DOM node that encodes a specific layer.

QgsProject raises an exception when one of the QgsProject::read() implementations fails. Since the read()s are invoked from qgisapp, then qgisapp handles the exception. It prompts the user for the new location of the data, if any. If there is a new location, the DOM node associated with the layer has its datasource tag corrected. Then that node is passed to this member function to be re-opened.

Definition at line 1124 of file qgsproject.cpp.

§ readBoolEntry()

bool QgsProject::readBoolEntry ( const QString &  scope,
const QString &  key,
bool  def = false,
bool *  ok = nullptr 
) const

Definition at line 1484 of file qgsproject.cpp.

§ readDoubleEntry()

double QgsProject::readDoubleEntry ( const QString &  scope,
const QString &  key,
double  def = 0,
bool *  ok = nullptr 
) const

Definition at line 1464 of file qgsproject.cpp.

§ readEntry()

QString QgsProject::readEntry ( const QString &  scope,
const QString &  key,
const QString &  def = QString::null,
bool *  ok = nullptr 
) const

Definition at line 1413 of file qgsproject.cpp.

§ readListEntry()

QStringList QgsProject::readListEntry ( const QString &  scope,
const QString &  key,
const QStringList &  def = QStringList(),
bool *  ok = nullptr 
) const

Key value accessors.

keys would be the familiar QSettings-like '/' delimited entries, implying a hierarchy of keys and corresponding values

Definition at line 1386 of file qgsproject.cpp.

§ readMapLayer

void QgsProject::readMapLayer ( QgsMapLayer mapLayer,
const QDomElement &  layerNode 
)
signal

Emitted, after the basic initialization of a layer from the project file is done.

You can use this signal to read additional information from the project file.

Parameters
mapLayerThe map layer which is being initialized
layerNodeThe layer node from the project file

§ readNumEntry()

int QgsProject::readNumEntry ( const QString &  scope,
const QString &  key,
int  def = 0,
bool *  ok = nullptr 
) const

Definition at line 1437 of file qgsproject.cpp.

§ readPath()

QString QgsProject::readPath ( QString  filename) const

Turn filename read from the project file to an absolute path.

Definition at line 1554 of file qgsproject.cpp.

§ readProject

void QgsProject::readProject ( const QDomDocument &  )
signal

emitted when project is being read

§ relationManager()

QgsRelationManager * QgsProject::relationManager ( ) const

Definition at line 2115 of file qgsproject.cpp.

§ removeEntry()

bool QgsProject::removeEntry ( const QString &  scope,
const QString &  key 
)

Remove the given key.

Definition at line 1505 of file qgsproject.cpp.

§ setAreaUnits()

void QgsProject::setAreaUnits ( QgsUnitTypes::AreaUnit  unit)

Sets the default area measurement units for the project.

Note
added in QGIS 2.18
See also
areaUnits()
setDistanceUnits()

Definition at line 2101 of file qgsproject.cpp.

§ setAutoTransaction()

void QgsProject::setAutoTransaction ( bool  autoTransaction)

Transactional editing means that on supported datasources (postgres databases) the edit state of all tables that originate from the same database are synchronized and executed in a server side transaction.

Make sure that this is only called when all layers are not in edit mode.

Note
Added in QGIS 2.16

Definition at line 2170 of file qgsproject.cpp.

§ setAvoidIntersectionsList()

void QgsProject::setAvoidIntersectionsList ( const QStringList &  avoidIntersectionsList)

A list of layers with which intersections should be avoided.

Note
Added in QGIS 3.0

Definition at line 1029 of file qgsproject.cpp.

§ setBadLayerHandler()

void QgsProject::setBadLayerHandler ( QgsProjectBadLayerHandler handler)

Change handler for missing layers.

Deletes old handler and takes ownership of the new one.

Definition at line 1771 of file qgsproject.cpp.

§ setCrs()

void QgsProject::setCrs ( const QgsCoordinateReferenceSystem crs)

Sets the project's native coordinate reference system.

Note
added in QGIS 2.18
See also
crs()
setEllipsoid()

Definition at line 422 of file qgsproject.cpp.

§ setDirty

void QgsProject::setDirty ( bool  b = true)
slot

Flag the project as dirty (modified).

If this flag is set, the user will be asked to save changes to the project before closing the current project.

Note
added in 2.4
promoted to public slot in 2.16

Definition at line 379 of file qgsproject.cpp.

§ setDistanceUnits()

void QgsProject::setDistanceUnits ( QgsUnitTypes::DistanceUnit  unit)

Sets the default distance measurement units for the project.

Note
added in QGIS 2.18
See also
distanceUnits()
setAreaUnits()

Definition at line 2083 of file qgsproject.cpp.

§ setEllipsoid()

void QgsProject::setEllipsoid ( const QString &  ellipsoid)

Sets the project's ellipsoid from a proj string representation, eg "WGS84".

See also
ellipsoid()
setCrs()
Note
added in QGIS 2.18

Definition at line 435 of file qgsproject.cpp.

§ setEvaluateDefaultValues()

void QgsProject::setEvaluateDefaultValues ( bool  evaluateDefaultValues)

Defines if default values should be evaluated on provider side when requested and not when committed.

Note
added in 2.16

Definition at line 2045 of file qgsproject.cpp.

§ setFileName()

void QgsProject::setFileName ( const QString &  name)

Sets the file name associated with the project.

This is the file which contains the project's XML representation.

Parameters
nameproject file name
See also
fileName()

Definition at line 384 of file qgsproject.cpp.

§ setNonIdentifiableLayers() [1/2]

void QgsProject::setNonIdentifiableLayers ( const QList< QgsMapLayer *> &  layers)

Set a list of layers which should not be taken into account on map identification.

Definition at line 2130 of file qgsproject.cpp.

§ setNonIdentifiableLayers() [2/2]

void QgsProject::setNonIdentifiableLayers ( const QStringList &  layerIds)

Set a list of layers which should not be taken into account on map identification.

Definition at line 2153 of file qgsproject.cpp.

§ setSnappingConfig()

void QgsProject::setSnappingConfig ( const QgsSnappingConfig snappingConfig)

The snapping configuration for this project.

Note
Added in QGIS 3.0

Definition at line 614 of file qgsproject.cpp.

§ setTitle()

void QgsProject::setTitle ( const QString &  title)

Sets the project's title.

Parameters
titlenew title
Note
added in 2.4
See also
title()

Definition at line 357 of file qgsproject.cpp.

§ setTopologicalEditing()

void QgsProject::setTopologicalEditing ( bool  enabled)

Convenience function to set topological editing.

Definition at line 2059 of file qgsproject.cpp.

§ setVariables()

void QgsProject::setVariables ( const QgsStringMap variables)

A map of custom project variables.

Be careful not to set generated variables.

Definition at line 1000 of file qgsproject.cpp.

§ snappingConfig()

QgsSnappingConfig QgsProject::snappingConfig ( ) const

The snapping configuration for this project.

Note
Added in QGIS 3.0

§ snappingConfigChanged

void QgsProject::snappingConfigChanged ( )
signal

emitted whenever the configuration for snapping has changed

§ subkeyList()

QStringList QgsProject::subkeyList ( const QString &  scope,
const QString &  key 
) const

Return keys with keys – do not return keys that contain only values.

Note
equivalent to QSettings subkeyList()

Definition at line 1532 of file qgsproject.cpp.

§ title()

QString QgsProject::title ( ) const

Returns the project's title.

See also
setTitle()

Definition at line 368 of file qgsproject.cpp.

§ topologicalEditing()

bool QgsProject::topologicalEditing ( ) const

Convenience function to query topological editing status.

Definition at line 2065 of file qgsproject.cpp.

§ topologicalEditingChanged

void QgsProject::topologicalEditingChanged ( )
signal

Emitted when the topological editing flag has changed.

Note
Added in QGIS 3.0

§ transactionGroups()

QMap< QPair< QString, QString >, QgsTransactionGroup * > QgsProject::transactionGroups ( )

Map of transaction groups.

QPair( providerKey, connString ) -> transactionGroup

Note
Added in QGIS 2.16
Not available in python bindings

Definition at line 2183 of file qgsproject.cpp.

§ transactionGroupsChanged

void QgsProject::transactionGroupsChanged ( )
signal

Emitted whenever a new transaction group has been created or a transaction group has been removed.

Note
Added in QGIS 3.0

§ variables()

QgsStringMap QgsProject::variables ( ) const

A map of custom project variables.

To get all available variables including generated ones use QgsExpressionContextUtils::projectScope() instead.

Definition at line 995 of file qgsproject.cpp.

§ variablesChanged

void QgsProject::variablesChanged ( )
signal

Emitted whenever the expression variables stored in the project have been changed.

Note
added in QGIS 3.0

§ write() [1/2]

bool QgsProject::write ( const QFileInfo &  file)

Writes the project to a file.

Parameters
filedestination file
Note
calling this implicitly sets the project's filename (see setFileName() )
isDirty() will be set to false if project is successfully written
Returns
true if project was written successfully

Definition at line 1148 of file qgsproject.cpp.

§ write() [2/2]

bool QgsProject::write ( )

Writes the project to its current associated file (see fileName() ).

Note
isDirty() will be set to false if project is successfully written
Returns
true if project was written successfully

Definition at line 1155 of file qgsproject.cpp.

§ writeEntry() [1/5]

bool QgsProject::writeEntry ( const QString &  scope,
const QString &  key,
bool  value 
)

Write a boolean entry to the project file.

Keys are '/'-delimited entries, implying a hierarchy of keys and corresponding values

Note
The key string must be valid xml tag names in order to be saved to the file.
available in python bindings as writeEntryBool

Definition at line 1351 of file qgsproject.cpp.

§ writeEntry() [2/5]

bool QgsProject::writeEntry ( const QString &  scope,
const QString &  key,
double  value 
)

Write a double entry to the project file.

Keys are '/'-delimited entries, implying a hierarchy of keys and corresponding values

Note
The key string must be valid xml tag names in order to be saved to the file.
available in python bindings as writeEntryDouble

Definition at line 1358 of file qgsproject.cpp.

§ writeEntry() [3/5]

bool QgsProject::writeEntry ( const QString &  scope,
const QString &  key,
int  value 
)

Write an integer entry to the project file.

Keys are '/'-delimited entries, implying a hierarchy of keys and corresponding values

Note
The key string must be valid xml tag names in order to be saved to the file.

Definition at line 1365 of file qgsproject.cpp.

§ writeEntry() [4/5]

bool QgsProject::writeEntry ( const QString &  scope,
const QString &  key,
const QString &  value 
)

Write a string entry to the project file.

Keys are '/'-delimited entries, implying a hierarchy of keys and corresponding values

Note
The key string must be valid xml tag names in order to be saved to the file.

Definition at line 1372 of file qgsproject.cpp.

§ writeEntry() [5/5]

bool QgsProject::writeEntry ( const QString &  scope,
const QString &  key,
const QStringList &  value 
)

Write a string list entry to the project file.

Keys are '/'-delimited entries, implying a hierarchy of keys and corresponding values

Note
The key string must be valid xml tag names in order to be saved to the file.

Definition at line 1379 of file qgsproject.cpp.

§ writeMapLayer

void QgsProject::writeMapLayer ( QgsMapLayer mapLayer,
QDomElement &  layerElem,
QDomDocument &  doc 
)
signal

Emitted, when a layer is being saved.

You can use this method to save additional information to the layer.

Parameters
mapLayerThe map layer which is being initialized
layerElemThe layer element from the project file
docThe document

§ writePath()

QString QgsProject::writePath ( const QString &  filename,
const QString &  relativeBasePath = QString::null 
) const

Prepare a filename to save it to the project file.

Creates an absolute or relative path according to the project settings. Paths written to the project file should be prepared with this method.

Definition at line 1662 of file qgsproject.cpp.

§ writeProject

void QgsProject::writeProject ( QDomDocument &  )
signal

emitted when project is being written

Property Documentation

§ avoidIntersectionsList

QStringList QgsProject::avoidIntersectionsList
readwrite

Definition at line 84 of file qgsproject.h.

§ crs

QgsCoordinateReferenceSystem QgsProject::crs
readwrite

Definition at line 81 of file qgsproject.h.

§ fileName

QString QgsProject::fileName
readwrite

Definition at line 79 of file qgsproject.h.

§ homePath

QString QgsProject::homePath
read

Definition at line 80 of file qgsproject.h.

§ mapThemeCollection

QgsMapThemeCollection * QgsProject::mapThemeCollection
read

Definition at line 82 of file qgsproject.h.

§ nonIdentifiableLayers

QStringList QgsProject::nonIdentifiableLayers
readwrite

Definition at line 78 of file qgsproject.h.

§ snappingConfig

QgsSnappingConfig QgsProject::snappingConfig
readwrite

Definition at line 83 of file qgsproject.h.


The documentation for this class was generated from the following files: