Class: QgsLayoutCustomDropHandler

Abstract base class that may be implemented to handle new types of data to be dropped or pasted in QGIS layouts.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsLayoutCustomDropHandler

Base classes

QObject

Methods

handleFileDrop

Called when the specified file has been dropped onto a QGIS layout.

handlePaste

Called when the specified MIME data has been pasted onto a QGIS layout.

class qgis.gui.QgsLayoutCustomDropHandler[source]

Bases: QObject

__init__(parent: QObject | None = None)

Constructor for QgsLayoutCustomDropHandler.

Parameters:

parent (Optional[QObject] = None)

handleFileDrop(self, iface: QgsLayoutDesignerInterface | None, file: str | None) bool[source]

Called when the specified file has been dropped onto a QGIS layout. If True is returned, then the handler has accepted this file and it should not be further processed (e.g. by other QgsLayoutCustomDropHandler).

The base class implementation does nothing.

Deprecated since version 3.40: Use the version which specifies a drop location instead.

Parameters:
Return type:

bool

handleFileDrop(self, iface: QgsLayoutDesignerInterface | None, dropPoint: QPointF | QPoint, file: str | None) bool[source]

Called when the specified file has been dropped onto a QGIS layout. If True is returned, then the handler has accepted this file and it should not be further processed (e.g. by other QgsLayoutCustomDropHandler).

The dropPoint point specifies the location (in layout coordinates) at which the drop occurred.

The base class implementation does nothing.

Added in version 3.12.

Parameters:
Return type:

bool

handlePaste(self, iface: QgsLayoutDesignerInterface | None, pastePoint: QPointF | QPoint, data: QMimeData | None)[source]

Called when the specified MIME data has been pasted onto a QGIS layout. If True is returned, then the handler has accepted this data and it should not be further processed (e.g. by other QgsLayoutCustomDropHandler).

The pastePoint point specifies the location (in layout coordinates) at which the paste occurred.

The base class implementation does nothing.

Parameters:
  • iface (Optional[QgsLayoutDesignerInterface]) – pointer to the layout designer interface

  • pastePoint (Union[QPointF, QPoint]) – layout point at which the paste should occur

  • data (Optional[QMimeData]) -> (bool) – MIME data to paste

Returns:

  • True if the handler accepted and processed the paste operation

  • pastedItems: should be filled with any newly created items as a result of the paste

Added in version 3.14.