QGIS API Documentation 3.41.0-Master (af5edcb665c)
|
Base class for layouts, which can contain items such as maps, labels, scalebars, etc. More...
#include <qgslayout.h>
Public Types | |
enum | UndoCommand { UndoLayoutDpi , UndoNone = -1 } |
Layout undo commands, used for collapsing undo commands. More... | |
enum | ZValues { ZPage = 0 , ZItem = 1 , ZGrid = 9997 , ZGuide = 9998 , ZSmartGuide = 9999 , ZMouseHandles = 10000 , ZViewTool = 10001 , ZSnapIndicator = 10002 } |
Preset item z-values, to ensure correct stacking. More... | |
Public Slots | |
void | refresh () |
Forces the layout, and all items contained within it, to refresh. | |
void | updateBounds () |
Updates the scene bounds of the layout. | |
Signals | |
void | backgroundTaskCountChanged (int total) |
Emitted whenever the total number of background tasks running in items from the layout changes. | |
void | changed () |
Emitted when properties of the layout change. | |
void | itemAdded (QgsLayoutItem *item) |
Emitted when an item was added to the layout. | |
void | refreshed () |
Emitted when the layout has been refreshed and items should also be refreshed and updated. | |
void | selectedItemChanged (QgsLayoutItem *selected) |
Emitted whenever the selected item changes. | |
void | variablesChanged () |
Emitted whenever the expression variables stored in the layout have been changed. | |
Public Member Functions | |
QgsLayout (QgsProject *project) | |
Construct a new layout linked to the specified project. | |
~QgsLayout () override | |
bool | accept (QgsStyleEntityVisitorInterface *visitor) const |
Accepts the specified style entity visitor, causing it to visit all style entities associated with the layout. | |
QList< QgsLayoutItem * > | addItemsFromXml (const QDomElement &parentElement, const QDomDocument &document, const QgsReadWriteContext &context, QPointF *position=nullptr, bool pasteInPlace=false) |
Add items from an XML representation to the layout. | |
void | addLayoutItem (QgsLayoutItem *item) |
Adds an item to the layout. | |
void | addMultiFrame (QgsLayoutMultiFrame *multiFrame) |
Adds a multiFrame to the layout. | |
void | clear () |
Clears the layout. | |
QgsLayout * | clone () const |
Creates a clone of the layout. | |
QgsLayoutMeasurement | convertFromLayoutUnits (double length, Qgis::LayoutUnit unit) const |
Converts a length measurement from the layout's native units to a specified target unit. | |
QgsLayoutPoint | convertFromLayoutUnits (QPointF point, Qgis::LayoutUnit unit) const |
Converts a point from the layout's native units to a specified target unit. | |
QgsLayoutSize | convertFromLayoutUnits (QSizeF size, Qgis::LayoutUnit unit) const |
Converts a size from the layout's native units to a specified target unit. | |
QPointF | convertToLayoutUnits (const QgsLayoutPoint &point) const |
Converts a point into the layout's native units. | |
QSizeF | convertToLayoutUnits (const QgsLayoutSize &size) const |
Converts a size into the layout's native units. | |
double | convertToLayoutUnits (QgsLayoutMeasurement measurement) const |
Converts a measurement into the layout's native units. | |
QgsAbstractLayoutUndoCommand * | createCommand (const QString &text, int id=0, QUndoCommand *parent=nullptr) override |
Creates a new layout undo command with the specified text and parent. | |
QgsExpressionContext | createExpressionContext () const override |
Creates an expression context relating to the layout's current state. | |
QStringList | customProperties () const |
Returns list of keys stored in custom properties for the layout. | |
QVariant | customProperty (const QString &key, const QVariant &defaultValue=QVariant()) const |
Read a custom property from the layout. | |
void | deselectAll () |
Clears any selected items in the layout. | |
QgsLayoutGridSettings & | gridSettings () |
Returns a reference to the layout's grid settings, which stores settings relating to grid appearance, spacing and offsets. | |
const QgsLayoutGridSettings & | gridSettings () const |
Returns a reference to the layout's grid settings, which stores settings relating to grid appearance, spacing and offsets. | |
QgsLayoutItemGroup * | groupItems (const QList< QgsLayoutItem * > &items) |
Creates a new group from a list of layout items and adds the group to the layout. | |
QgsLayoutGuideCollection & | guides () |
Returns a reference to the layout's guide collection, which manages page snap guides. | |
const QgsLayoutGuideCollection & | guides () const |
Returns a reference to the layout's guide collection, which manages page snap guides. | |
void | initializeDefaults () |
Initializes an empty layout, e.g. | |
QgsLayoutItem * | itemById (const QString &id) const |
Returns a layout item given its id. | |
QgsLayoutItem * | itemByTemplateUuid (const QString &uuid) const |
Returns the layout item with matching template uuid unique identifier, or nullptr if a matching item could not be found. | |
QgsLayoutItem * | itemByUuid (const QString &uuid, bool includeTemplateUuids=false) const |
Returns the layout item with matching uuid unique identifier, or nullptr if a matching item could not be found. | |
QgsLayoutModel * | itemsModel () |
Returns the items model attached to the layout. | |
QRectF | layoutBounds (bool ignorePages=false, double margin=0.0) const |
Calculates the bounds of all non-gui items in the layout. | |
QgsLayoutItem * | layoutItemAt (QPointF position, bool ignoreLocked=false, double searchTolerance=0) const |
Returns the topmost layout item at a specified position. | |
QgsLayoutItem * | layoutItemAt (QPointF position, const QgsLayoutItem *belowItem, bool ignoreLocked=false, double searchTolerance=0) const |
Returns the topmost layout item at a specified position which is below a specified item. | |
template<class T > | |
void | layoutItems (QList< T * > &itemList) const |
Returns a list of layout items of a specific type. | |
template<class T > | |
void | layoutObjects (QList< T * > &objectList) const |
Returns a list of layout objects (items and multiframes) of a specific type. | |
QList< QgsLayoutItem * > | loadFromTemplate (const QDomDocument &document, const QgsReadWriteContext &context, bool clearExisting=true, bool *ok=nullptr) |
Load a layout template document. | |
bool | lowerItem (QgsLayoutItem *item, bool deferUpdate=false) |
Lowers an item down the z-order. | |
bool | moveItemToBottom (QgsLayoutItem *item, bool deferUpdate=false) |
Lowers an item down to the bottom of the z-order. | |
bool | moveItemToTop (QgsLayoutItem *item, bool deferUpdate=false) |
Raises an item up to the top of the z-order. | |
QgsLayoutMultiFrame * | multiFrameByUuid (const QString &uuid, bool includeTemplateUuids=false) const |
Returns the layout multiframe with matching uuid unique identifier, or nullptr if a matching multiframe could not be found. | |
QList< QgsLayoutMultiFrame * > | multiFrames () const |
Returns a list of multi frames contained in the layout. | |
QgsLayoutPageCollection * | pageCollection () |
Returns a pointer to the layout's page collection, which stores and manages page items in the layout. | |
const QgsLayoutPageCollection * | pageCollection () const |
Returns a pointer to the layout's page collection, which stores and manages page items in the layout. | |
QRectF | pageItemBounds (int page, bool visibleOnly=false) const |
Returns the bounding box of the items contained on a specified page. | |
QgsProject * | project () const |
The project associated with the layout. | |
bool | raiseItem (QgsLayoutItem *item, bool deferUpdate=false) |
Raises an item up the z-order. | |
virtual bool | readXml (const QDomElement &layoutElement, const QDomDocument &document, const QgsReadWriteContext &context) |
Sets the collection's state from a DOM element. | |
QgsLayoutItemMap * | referenceMap () const |
Returns the map item which will be used to generate corresponding world files when the layout is exported. | |
void | reloadSettings () |
Refreshes the layout when global layout related options change. | |
void | removeCustomProperty (const QString &key) |
Remove a custom property from the layout. | |
void | removeLayoutItem (QgsLayoutItem *item) |
Removes an item from the layout. | |
void | removeMultiFrame (QgsLayoutMultiFrame *multiFrame) |
Removes a multiFrame from the layout (but does not delete it). | |
QgsLayoutRenderContext & | renderContext () |
Returns a reference to the layout's render context, which stores information relating to the current rendering settings for the layout. | |
const QgsLayoutRenderContext & | renderContext () const |
Returns a reference to the layout's render context, which stores information relating to the current rendering settings for the layout. | |
QgsLayoutReportContext & | reportContext () |
Returns a reference to the layout's report context, which stores information relating to the current reporting context for the layout. | |
const QgsLayoutReportContext & | reportContext () const |
Returns a reference to the layout's report context, which stores information relating to the current reporting context for the layout. | |
bool | saveAsTemplate (const QString &path, const QgsReadWriteContext &context) const |
Saves the layout as a template at the given file path. | |
QList< QgsLayoutItem * > | selectedLayoutItems (bool includeLockedItems=true) |
Returns list of selected layout items. | |
void | setCustomProperty (const QString &key, const QVariant &value) |
Set a custom property for the layout. | |
void | setReferenceMap (QgsLayoutItemMap *map) |
Sets the map item which will be used to generate corresponding world files when the layout is exported. | |
void | setSelectedItem (QgsLayoutItem *item) |
Clears any selected items and sets item as the current selection. | |
void | setUnits (Qgis::LayoutUnit units) |
Sets the native measurement units for the layout. | |
QgsLayoutSnapper & | snapper () |
Returns a reference to the layout's snapper, which stores handles layout snap grids and lines and snapping points to the nearest matching point. | |
const QgsLayoutSnapper & | snapper () const |
Returns a reference to the layout's snapper, which stores handles layout snap grids and lines and snapping points to the nearest matching point. | |
QgsLayoutUndoStack * | undoStack () |
Returns a pointer to the layout's undo stack, which manages undo/redo states for the layout and it's associated objects. | |
const QgsLayoutUndoStack * | undoStack () const |
Returns a pointer to the layout's undo stack, which manages undo/redo states for the layout and it's associated objects. | |
QList< QgsLayoutItem * > | ungroupItems (QgsLayoutItemGroup *group) |
Ungroups items by removing them from an item group and removing the group from the layout. | |
Qgis::LayoutUnit | units () const |
Returns the native units for the layout. | |
void | updateZValues (bool addUndoCommands=true) |
Resets the z-values of items based on their position in the internal z order list. | |
virtual QDomElement | writeXml (QDomDocument &document, const QgsReadWriteContext &context) const |
Returns the layout's state encapsulated in a DOM element. | |
Public Member Functions inherited from QgsExpressionContextGenerator | |
virtual | ~QgsExpressionContextGenerator ()=default |
Public Member Functions inherited from QgsLayoutUndoObjectInterface | |
virtual | ~QgsLayoutUndoObjectInterface ()=default |
Static Public Attributes | |
static const QgsSettingsEntryStringList * | settingsSearchPathForTemplates = new QgsSettingsEntryStringList( QStringLiteral( "search-paths-for-templates" ), QgsSettingsTree::sTreeLayout, QStringList(), QObject::tr( "Search path for templates" ) ) |
Settings entry search path for templates. | |
Friends | |
class | QgsCompositionConverter |
class | QgsLayoutItemAddItemCommand |
class | QgsLayoutItemDeleteUndoCommand |
class | QgsLayoutItemGroupUndoCommand |
class | QgsLayoutItemUndoCommand |
class | QgsLayoutModel |
class | QgsLayoutMultiFrame |
class | QgsLayoutUndoCommand |
Base class for layouts, which can contain items such as maps, labels, scalebars, etc.
While the raw QGraphicsScene API can be used to render the contents of a QgsLayout to a QPainter, it is recommended to instead use a QgsLayoutExporter to handle rendering layouts instead. QgsLayoutExporter automatically takes care of the intracacies of preparing the layout and paint devices for correct exports, respecting various user settings such as the layout context DPI.
Definition at line 48 of file qgslayout.h.
Layout undo commands, used for collapsing undo commands.
Enumerator | |
---|---|
UndoLayoutDpi | Change layout default DPI. |
UndoNone | No command suppression. |
Definition at line 68 of file qgslayout.h.
enum QgsLayout::ZValues |
Preset item z-values, to ensure correct stacking.
Definition at line 55 of file qgslayout.h.
QgsLayout::QgsLayout | ( | QgsProject * | project | ) |
Construct a new layout linked to the specified project.
If the layout is a "new" layout (as opposed to a layout which will restore a previous state from XML) then initializeDefaults() should be called on the new layout.
Definition at line 46 of file qgslayout.cpp.
|
override |
Definition at line 60 of file qgslayout.cpp.
bool QgsLayout::accept | ( | QgsStyleEntityVisitorInterface * | visitor | ) | const |
Accepts the specified style entity visitor, causing it to visit all style entities associated with the layout.
Returns true
if the visitor should continue visiting other objects, or false
if visiting should be canceled.
Definition at line 814 of file qgslayout.cpp.
QList< QgsLayoutItem * > QgsLayout::addItemsFromXml | ( | const QDomElement & | parentElement, |
const QDomDocument & | document, | ||
const QgsReadWriteContext & | context, | ||
QPointF * | position = nullptr , |
||
bool | pasteInPlace = false |
||
) |
Add items from an XML representation to the layout.
Used for project file reading and pasting items from clipboard.
The position argument is optional, and if it is not specified the items will be restored to their original position from the XML serialization. If specified, the items will be positioned such that the top-left bounds of all added items is located at this position.
The pasteInPlace argument determines whether the serialized position should be respected, but remapped to the origin of the page corresponding to the page at position.
A list of the newly added items is returned.
Definition at line 1014 of file qgslayout.cpp.
void QgsLayout::addLayoutItem | ( | QgsLayoutItem * | item | ) |
Adds an item to the layout.
This should be called instead of the base class addItem() method. Ownership of the item is transferred to the layout.
Definition at line 564 of file qgslayout.cpp.
void QgsLayout::addMultiFrame | ( | QgsLayoutMultiFrame * | multiFrame | ) |
Adds a multiFrame to the layout.
The object is owned by the layout until removeMultiFrame() is called.
Definition at line 596 of file qgslayout.cpp.
|
signal |
Emitted whenever the total number of background tasks running in items from the layout changes.
|
signal |
Emitted when properties of the layout change.
This signal is only emitted for settings directly managed by the layout, and is not emitted when child items change.
void QgsLayout::clear | ( | ) |
Clears the layout.
Calling this method removes all items and pages from the layout.
Definition at line 121 of file qgslayout.cpp.
QgsLayout * QgsLayout::clone | ( | ) | const |
Creates a clone of the layout.
Ownership of the return layout is transferred to the caller.
Definition at line 93 of file qgslayout.cpp.
QgsLayoutMeasurement QgsLayout::convertFromLayoutUnits | ( | double | length, |
Qgis::LayoutUnit | unit | ||
) | const |
Converts a length measurement from the layout's native units to a specified target unit.
Definition at line 368 of file qgslayout.cpp.
QgsLayoutPoint QgsLayout::convertFromLayoutUnits | ( | QPointF | point, |
Qgis::LayoutUnit | unit | ||
) | const |
Converts a point from the layout's native units to a specified target unit.
Definition at line 378 of file qgslayout.cpp.
QgsLayoutSize QgsLayout::convertFromLayoutUnits | ( | QSizeF | size, |
Qgis::LayoutUnit | unit | ||
) | const |
Converts a size from the layout's native units to a specified target unit.
Definition at line 373 of file qgslayout.cpp.
QPointF QgsLayout::convertToLayoutUnits | ( | const QgsLayoutPoint & | point | ) | const |
Converts a point into the layout's native units.
Definition at line 363 of file qgslayout.cpp.
QSizeF QgsLayout::convertToLayoutUnits | ( | const QgsLayoutSize & | size | ) | const |
Converts a size into the layout's native units.
Definition at line 358 of file qgslayout.cpp.
double QgsLayout::convertToLayoutUnits | ( | QgsLayoutMeasurement | measurement | ) | const |
Converts a measurement into the layout's native units.
Definition at line 353 of file qgslayout.cpp.
|
overridevirtual |
Creates a new layout undo command with the specified text and parent.
The id argument can be used to specify an id number for the source event - this is used to determine whether QUndoCommand command compression can apply to the command.
Implements QgsLayoutUndoObjectInterface.
Definition at line 757 of file qgslayout.cpp.
|
overridevirtual |
Creates an expression context relating to the layout's current state.
The context includes scopes for global, project, layout and layout context properties.
Implements QgsExpressionContextGenerator.
Reimplemented in QgsPrintLayout.
Definition at line 419 of file qgslayout.cpp.
QStringList QgsLayout::customProperties | ( | ) | const |
Returns list of keys stored in custom properties for the layout.
Definition at line 449 of file qgslayout.cpp.
QVariant QgsLayout::customProperty | ( | const QString & | key, |
const QVariant & | defaultValue = QVariant() |
||
) | const |
Read a custom property from the layout.
key | property key |
defaultValue | default value to return if property with matching key does not exist |
Definition at line 439 of file qgslayout.cpp.
void QgsLayout::deselectAll | ( | ) |
Clears any selected items in the layout.
Call this method rather than QGraphicsScene::clearSelection, as the latter does not correctly emit signals to allow the layout's model to update.
Definition at line 179 of file qgslayout.cpp.
|
inline |
Returns a reference to the layout's grid settings, which stores settings relating to grid appearance, spacing and offsets.
Definition at line 419 of file qgslayout.h.
|
inline |
Returns a reference to the layout's grid settings, which stores settings relating to grid appearance, spacing and offsets.
Definition at line 425 of file qgslayout.h.
QgsLayoutItemGroup * QgsLayout::groupItems | ( | const QList< QgsLayoutItem * > & | items | ) |
Creates a new group from a list of layout items and adds the group to the layout.
If grouping was not possible, nullptr
will be returned.
Definition at line 762 of file qgslayout.cpp.
QgsLayoutGuideCollection & QgsLayout::guides | ( | ) |
Returns a reference to the layout's guide collection, which manages page snap guides.
Definition at line 409 of file qgslayout.cpp.
const QgsLayoutGuideCollection & QgsLayout::guides | ( | ) | const |
Returns a reference to the layout's guide collection, which manages page snap guides.
Definition at line 414 of file qgslayout.cpp.
void QgsLayout::initializeDefaults | ( | ) |
Initializes an empty layout, e.g.
by adding a default page to the layout. This should be called after creating a new layout.
Definition at line 112 of file qgslayout.cpp.
|
signal |
Emitted when an item was added to the layout.
QgsLayoutItem * QgsLayout::itemById | ( | const QString & | id | ) | const |
Returns a layout item given its id.
Since item IDs are not necessarely unique, this function returns the first matching item found.
Definition at line 276 of file qgslayout.cpp.
QgsLayoutItem * QgsLayout::itemByTemplateUuid | ( | const QString & | uuid | ) | const |
Returns the layout item with matching template uuid unique identifier, or nullptr
if a matching item could not be found.
Unlike itemByUuid(), this method ONLY checks template UUIDs for a match.
Template UUIDs are valid only for items which have been added to an existing layout from a template. In this case the template UUID is the original item UUID at the time the template was created, vs the item's uuid() which returns the current instance of the item's unique identifier.
Note that template UUIDs are only available while a layout is being restored from XML.
Definition at line 263 of file qgslayout.cpp.
QgsLayoutItem * QgsLayout::itemByUuid | ( | const QString & | uuid, |
bool | includeTemplateUuids = false |
||
) | const |
Returns the layout item with matching uuid unique identifier, or nullptr
if a matching item could not be found.
If includeTemplateUuids is true
, then item's template UUID will also be tested when trying to match the uuid. This may differ from the item's UUID for items which have been added to an existing layout from a template. In this case the template UUID returns the original item UUID at the time the template was created, vs the item's uuid() which returns the current instance of the item's unique identifier. Note that template UUIDs are only available while a layout is being restored from XML.
Definition at line 248 of file qgslayout.cpp.
QgsLayoutModel * QgsLayout::itemsModel | ( | ) |
Returns the items model attached to the layout.
Definition at line 147 of file qgslayout.cpp.
QRectF QgsLayout::layoutBounds | ( | bool | ignorePages = false , |
double | margin = 0.0 |
||
) | const |
Calculates the bounds of all non-gui items in the layout.
Ignores snap lines, mouse handles and other cosmetic items.
ignorePages | set to true to ignore page items |
margin | optional marginal (in percent, e.g., 0.05 = 5% ) to add around items |
Definition at line 493 of file qgslayout.cpp.
QgsLayoutItem * QgsLayout::layoutItemAt | ( | QPointF | position, |
bool | ignoreLocked = false , |
||
double | searchTolerance = 0 |
||
) | const |
Returns the topmost layout item at a specified position.
Ignores paper items. If ignoreLocked is set to true
any locked items will be ignored. Since QGIS 3.34 the searchTolerance parameter was added, which can be used to specify a search tolerance in layout units.
Definition at line 303 of file qgslayout.cpp.
QgsLayoutItem * QgsLayout::layoutItemAt | ( | QPointF | position, |
const QgsLayoutItem * | belowItem, | ||
bool | ignoreLocked = false , |
||
double | searchTolerance = 0 |
||
) | const |
Returns the topmost layout item at a specified position which is below a specified item.
Ignores paper items. If ignoreLocked is set to true
any locked items will be ignored. Since QGIS 3.34 the searchTolerance parameter was added, which can be used to specify a search tolerance in layout units.
Definition at line 308 of file qgslayout.cpp.
|
inline |
Returns a list of layout items of a specific type.
Definition at line 120 of file qgslayout.h.
|
inline |
Returns a list of layout objects (items and multiframes) of a specific type.
Definition at line 139 of file qgslayout.h.
QList< QgsLayoutItem * > QgsLayout::loadFromTemplate | ( | const QDomDocument & | document, |
const QgsReadWriteContext & | context, | ||
bool | clearExisting = true , |
||
bool * | ok = nullptr |
||
) |
Load a layout template document.
By default this method will clear all items from the existing layout and real all layout settings from the template. Setting clearExisting to false
will only add new items from the template, without overwriting the existing items or layout settings.
If ok is specified, it will be set to true
if the load was successful.
Returns a list of loaded items.
Definition at line 633 of file qgslayout.cpp.
bool QgsLayout::lowerItem | ( | QgsLayoutItem * | item, |
bool | deferUpdate = false |
||
) |
Lowers an item down the z-order.
Returns true
if the item was successfully lowered.
If deferUpdate is true
, the scene will not be visibly updated to reflect the new stacking order. This allows multiple raiseItem() calls to be made in sequence without the cost of updating the scene for each one.
Definition at line 209 of file qgslayout.cpp.
bool QgsLayout::moveItemToBottom | ( | QgsLayoutItem * | item, |
bool | deferUpdate = false |
||
) |
Lowers an item down to the bottom of the z-order.
Returns true
if the item was successfully lowered. If deferUpdate is true
, the scene will not be visibly updated to reflect the new stacking order. This allows multiple raiseItem() calls to be made in sequence without the cost of updating the scene for each one.
Definition at line 235 of file qgslayout.cpp.
bool QgsLayout::moveItemToTop | ( | QgsLayoutItem * | item, |
bool | deferUpdate = false |
||
) |
Raises an item up to the top of the z-order.
Returns true
if the item was successfully raised.
If deferUpdate is true
, the scene will not be visibly updated to reflect the new stacking order. This allows multiple raiseItem() calls to be made in sequence without the cost of updating the scene for each one.
Definition at line 222 of file qgslayout.cpp.
QgsLayoutMultiFrame * QgsLayout::multiFrameByUuid | ( | const QString & | uuid, |
bool | includeTemplateUuids = false |
||
) | const |
Returns the layout multiframe with matching uuid unique identifier, or nullptr
if a matching multiframe could not be found.
If includeTemplateUuids is true
, then the multiframe's QgsLayoutMultiFrame::templateUuid() will also be tested when trying to match the uuid. Template UUIDs are valid only for items which have been added to an existing layout from a template. In this case the template UUID is the original item UUID at the time the template was created, vs the item's uuid() which returns the current instance of the item's unique identifier. Note that template UUIDs are only available while a layout is being restored from XML.
Definition at line 290 of file qgslayout.cpp.
QList< QgsLayoutMultiFrame * > QgsLayout::multiFrames | ( | ) | const |
Returns a list of multi frames contained in the layout.
Definition at line 610 of file qgslayout.cpp.
QgsLayoutPageCollection * QgsLayout::pageCollection | ( | ) |
Returns a pointer to the layout's page collection, which stores and manages page items in the layout.
Definition at line 483 of file qgslayout.cpp.
const QgsLayoutPageCollection * QgsLayout::pageCollection | ( | ) | const |
Returns a pointer to the layout's page collection, which stores and manages page items in the layout.
Definition at line 488 of file qgslayout.cpp.
QRectF QgsLayout::pageItemBounds | ( | int | page, |
bool | visibleOnly = false |
||
) | const |
Returns the bounding box of the items contained on a specified page.
A page number of 0 represents the first page in the layout.
Set visibleOnly to true
to only include visible items.
The returned bounds are in layout units.
Definition at line 538 of file qgslayout.cpp.
QgsProject * QgsLayout::project | ( | ) | const |
The project associated with the layout.
Used to get access to layers, map themes, relations and various other bits. It is never nullptr
.
Definition at line 142 of file qgslayout.cpp.
bool QgsLayout::raiseItem | ( | QgsLayoutItem * | item, |
bool | deferUpdate = false |
||
) |
Raises an item up the z-order.
Returns true
if the item was successfully raised.
If deferUpdate is true
, the scene will not be visibly updated to reflect the new stacking order. This allows multiple raiseItem() calls to be made in sequence without the cost of updating the scene for each one.
Definition at line 196 of file qgslayout.cpp.
|
virtual |
Sets the collection's state from a DOM element.
layoutElement is the DOM node corresponding to the layout.
Reimplemented in QgsPrintLayout.
Definition at line 975 of file qgslayout.cpp.
QgsLayoutItemMap * QgsLayout::referenceMap | ( | ) | const |
Returns the map item which will be used to generate corresponding world files when the layout is exported.
If no map was explicitly set via setReferenceMap(), the largest map in the layout will be returned (or nullptr
if there are no maps in the layout).
Definition at line 454 of file qgslayout.cpp.
|
slot |
Forces the layout, and all items contained within it, to refresh.
For instance, this causes maps to redraw and rebuild cached images, html items to reload their source url, and attribute tables to refresh their contents. Calling this also triggers a recalculation of all data defined attributes within the layout.
Definition at line 829 of file qgslayout.cpp.
|
signal |
Emitted when the layout has been refreshed and items should also be refreshed and updated.
void QgsLayout::reloadSettings | ( | ) |
Refreshes the layout when global layout related options change.
Definition at line 403 of file qgslayout.cpp.
void QgsLayout::removeCustomProperty | ( | const QString & | key | ) |
Remove a custom property from the layout.
key | property key |
Definition at line 444 of file qgslayout.cpp.
void QgsLayout::removeLayoutItem | ( | QgsLayoutItem * | item | ) |
Removes an item from the layout.
This should be called instead of the base class removeItem() method. The item will also be deleted.
Definition at line 580 of file qgslayout.cpp.
void QgsLayout::removeMultiFrame | ( | QgsLayoutMultiFrame * | multiFrame | ) |
Removes a multiFrame from the layout (but does not delete it).
Definition at line 605 of file qgslayout.cpp.
QgsLayoutRenderContext & QgsLayout::renderContext | ( | ) |
Returns a reference to the layout's render context, which stores information relating to the current rendering settings for the layout.
Definition at line 383 of file qgslayout.cpp.
const QgsLayoutRenderContext & QgsLayout::renderContext | ( | ) | const |
Returns a reference to the layout's render context, which stores information relating to the current rendering settings for the layout.
Definition at line 388 of file qgslayout.cpp.
QgsLayoutReportContext & QgsLayout::reportContext | ( | ) |
Returns a reference to the layout's report context, which stores information relating to the current reporting context for the layout.
Definition at line 393 of file qgslayout.cpp.
const QgsLayoutReportContext & QgsLayout::reportContext | ( | ) | const |
Returns a reference to the layout's report context, which stores information relating to the current reporting context for the layout.
Definition at line 398 of file qgslayout.cpp.
bool QgsLayout::saveAsTemplate | ( | const QString & | path, |
const QgsReadWriteContext & | context | ||
) | const |
Saves the layout as a template at the given file path.
Returns true
if save was successful.
Definition at line 615 of file qgslayout.cpp.
|
signal |
Emitted whenever the selected item changes.
If nullptr
, no item is selected.
QList< QgsLayoutItem * > QgsLayout::selectedLayoutItems | ( | bool | includeLockedItems = true | ) |
Returns list of selected layout items.
If includeLockedItems is set to true
, then locked items will also be included in the returned list.
Definition at line 152 of file qgslayout.cpp.
void QgsLayout::setCustomProperty | ( | const QString & | key, |
const QVariant & | value | ||
) |
Set a custom property for the layout.
key | property key. If a property with the same key already exists it will be overwritten. |
value | property value |
Definition at line 431 of file qgslayout.cpp.
void QgsLayout::setReferenceMap | ( | QgsLayoutItemMap * | map | ) |
Sets the map item which will be used to generate corresponding world files when the layout is exported.
Definition at line 477 of file qgslayout.cpp.
void QgsLayout::setSelectedItem | ( | QgsLayoutItem * | item | ) |
Clears any selected items and sets item as the current selection.
Definition at line 169 of file qgslayout.cpp.
|
inline |
Sets the native measurement units for the layout.
These also form the default unit for measurements for the layout.
Definition at line 322 of file qgslayout.h.
|
inline |
Returns a reference to the layout's snapper, which stores handles layout snap grids and lines and snapping points to the nearest matching point.
Definition at line 407 of file qgslayout.h.
|
inline |
Returns a reference to the layout's snapper, which stores handles layout snap grids and lines and snapping points to the nearest matching point.
Definition at line 413 of file qgslayout.h.
QgsLayoutUndoStack * QgsLayout::undoStack | ( | ) |
Returns a pointer to the layout's undo stack, which manages undo/redo states for the layout and it's associated objects.
Definition at line 710 of file qgslayout.cpp.
const QgsLayoutUndoStack * QgsLayout::undoStack | ( | ) | const |
Returns a pointer to the layout's undo stack, which manages undo/redo states for the layout and it's associated objects.
Definition at line 715 of file qgslayout.cpp.
QList< QgsLayoutItem * > QgsLayout::ungroupItems | ( | QgsLayoutItemGroup * | group | ) |
Ungroups items by removing them from an item group and removing the group from the layout.
Child items will remain in the layout and will not be deleted.
Returns a list of the items removed from the group, or an empty list if ungrouping was not successful.
Definition at line 789 of file qgslayout.cpp.
|
inline |
Returns the native units for the layout.
Definition at line 329 of file qgslayout.h.
|
slot |
Updates the scene bounds of the layout.
Definition at line 1213 of file qgslayout.cpp.
void QgsLayout::updateZValues | ( | bool | addUndoCommands = true | ) |
Resets the z-values of items based on their position in the internal z order list.
This should be called after any stacking changes which deferred z-order updates.
Definition at line 944 of file qgslayout.cpp.
|
signal |
Emitted whenever the expression variables stored in the layout have been changed.
|
virtual |
Returns the layout's state encapsulated in a DOM element.
Reimplemented in QgsPrintLayout.
Definition at line 848 of file qgslayout.cpp.
|
friend |
Definition at line 780 of file qgslayout.h.
|
friend |
Definition at line 773 of file qgslayout.h.
|
friend |
Definition at line 774 of file qgslayout.h.
|
friend |
Definition at line 777 of file qgslayout.h.
|
friend |
Definition at line 775 of file qgslayout.h.
|
friend |
Definition at line 778 of file qgslayout.h.
|
friend |
Definition at line 779 of file qgslayout.h.
|
friend |
Definition at line 776 of file qgslayout.h.
|
static |
Settings entry search path for templates.
Definition at line 663 of file qgslayout.h.