Class: QgsAbstractLayoutUndoCommand

Base class for commands to undo/redo layout and layout object changes.

Note

This is an abstract class, with methods which must be implemented by a subclass.

The following methods must be implemented: restoreState(), saveState()

Class Hierarchy

Inheritance diagram of qgis.core.QgsAbstractLayoutUndoCommand

Base classes

QUndoCommand

Abstract Methods

restoreState

Restores the state of the object from the specified stateDoc.

saveState

Saves the state of the object to the specified stateDoc.

Methods

afterState

Returns the after state for the layout.

beforeState

Returns the before state for the layout.

saveAfterState

Saves current layout state as after state.

saveBeforeState

Saves current layout state as before state.

setAfterState

Manually sets the after state for the command.

Virtual Methods

In PyQGIS, only methods marked as virtual can be safely overridden in a Python subclass of QgsAbstractLayoutUndoCommand. See the FAQ for more details.

containsChange

Returns True if both the before and after states are valid and different.

class qgis.core.QgsAbstractLayoutUndoCommand[source]

Bases: QUndoCommand

__init__(text: str | None, id: int = 0, parent: QUndoCommand | None = None)

Constructor for QgsLayoutUndoCommand. 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.

Parameters:
  • text (Optional[str])

  • id (int = 0)

  • parent (Optional[QUndoCommand] = None)

afterState(self) QDomDocument[source]

Returns the after state for the layout.

See also

saveAfterState()

See also

beforeState()

Return type:

QDomDocument

beforeState(self) QDomDocument[source]

Returns the before state for the layout.

See also

afterState()

Return type:

QDomDocument

virtual containsChange(self) bool[source]

Returns True if both the before and after states are valid and different.

Return type:

bool

abstract restoreState(self, stateDoc: QDomDocument)[source]

Restores the state of the object from the specified stateDoc.

Subclasses must implement this to handle restoring their current state from the encapsulated state.

See also

saveState()

Parameters:

stateDoc (QDomDocument)

saveAfterState(self)[source]

Saves current layout state as after state.

See also

afterState()

saveBeforeState(self)[source]

Saves current layout state as before state.

See also

beforeState()

See also

saveAfterState()

abstract saveState(self, stateDoc: QDomDocument)[source]

Saves the state of the object to the specified stateDoc.

Subclasses must implement this to handle encapsulating their current state into a DOM document.

See also

restoreState()

Parameters:

stateDoc (QDomDocument)

setAfterState(self, stateDoc: QDomDocument)[source]

Manually sets the after state for the command. Generally this should not be called directly.

Parameters:

stateDoc (QDomDocument)