Class: QgsLocatorModel

An abstract list model for displaying the results of locator searches.

Note that this class should generally be used with a QgsLocatorProxyModel in order to ensure correct sorting of results by priority and match level.

Class Hierarchy

Inheritance diagram of qgis.core.QgsLocatorModel

Base classes

QAbstractTableModel

QAbstractItemModel

QObject

Subclasses

QgsLocatorAutomaticModel

A QgsLocatorModel which is associated directly with a QgsLocator, and is automatically populated with results from locator searches.

Enums

CustomRole

Custom model roles.

Role

alias of CustomRole

Methods

addResult

Adds a new result to the model.

clear

Resets the model and clears all existing results.

deferredClear

Resets the model and clears all existing results after a short delay, or whenever the next result is added to the model (whichever occurs first).

Attributes

NoGroup

UnorderedGroup

class qgis.core.QgsLocatorModel[source]

Bases: QAbstractTableModel

__init__(parent: QObject | None = None)

Constructor for QgsLocatorModel.

Parameters:

parent (Optional[QObject] = None)

class CustomRole(*values)

Bases: IntEnum

Custom model roles.

Note

Prior to QGIS 3.36 this was available as QgsLocatorModel.Role

Added in version 3.36.

  • ResultData: QgsLocatorResult data

    Available as QgsLocatorModel.ResultDataRole in older QGIS releases.

  • ResultType: Result type

    Available as QgsLocatorModel.ResultTypeRole in older QGIS releases.

  • ResultFilterPriority: Result priority, used by QgsLocatorProxyModel for sorting roles.

    Available as QgsLocatorModel.ResultFilterPriorityRole in older QGIS releases.

  • ResultScore: Result match score, used by QgsLocatorProxyModel for sorting roles.

    Available as QgsLocatorModel.ResultScoreRole in older QGIS releases.

  • ResultFilterName: Associated filter name which created the result

    Available as QgsLocatorModel.ResultFilterNameRole in older QGIS releases.

  • ResultFilterGroupSorting: Custom value for sorting

    Deprecated since version 3.40.: No longer used.

    Available as QgsLocatorModel.ResultFilterGroupSortingRole in older QGIS releases.

  • ResultFilterGroupTitle: Group title

  • ResultFilterGroupScore: Group score

  • ResultActions: The actions to be shown for the given result in a context menu

    Available as QgsLocatorModel.ResultActionsRole in older QGIS releases.

NoGroup = -1
Role

alias of CustomRole

UnorderedGroup = 0
addResult(self, result: QgsLocatorResult)[source]

Adds a new result to the model.

Parameters:

result (QgsLocatorResult)

clear(self)[source]

Resets the model and clears all existing results.

See also

deferredClear()

deferredClear(self)[source]

Resets the model and clears all existing results after a short delay, or whenever the next result is added to the model (whichever occurs first). Using deferredClear() instead of clear() can avoid the visually distracting frequent clears which may occur if the model is being updated quickly multiple times as a result of users typing in a search query.

See also

deferredClear()