Class: QgsProviderConnectionModel

A model containing registered connection names for a specific data provider.

Warning

The provider must support the connection API methods in its QgsProviderMetadata implementation in order for the model to work correctly.

Added in version 3.14.

Class Hierarchy

Inheritance diagram of qgis.core.QgsProviderConnectionModel

Base classes

QAbstractItemModel

QObject

Enums

CustomRole

Custom model roles.

Role

alias of CustomRole

Methods

allowEmptyConnection

Returns True if the model allows the empty connection ("not set") choice.

setAllowEmptyConnection

Sets whether an optional empty connection ("not set") option is present in the model.

class qgis.core.QgsProviderConnectionModel[source]

Bases: QAbstractItemModel

__init__(provider: str | None, parent: QObject | None = None)

Constructor for QgsProviderConnectionModel, for the specified provider.

Warning

The provider must support the connection API methods in its QgsProviderMetadata implementation in order for the model to work correctly.

Parameters:
  • provider (Optional[str])

  • parent (Optional[QObject] = None)

class CustomRole(*values)

Bases: IntEnum

Custom model roles.

Note

Prior to QGIS 3.36 this was available as QgsProviderConnectionModel.Role

Added in version 3.36.

  • ConnectionName: Connection name

    Available as QgsProviderConnectionModel.RoleConnectionName in older QGIS releases.

  • Uri: Connection URI string

    Available as QgsProviderConnectionModel.RoleUri in older QGIS releases.

  • Configuration: Connection configuration variant map

    Available as QgsProviderConnectionModel.RoleConfiguration in older QGIS releases.

  • Empty: Entry is an empty entry

    Available as QgsProviderConnectionModel.RoleEmpty in older QGIS releases.

Role

alias of CustomRole

allowEmptyConnection(self) bool[source]

Returns True if the model allows the empty connection (“not set”) choice.

Return type:

bool

setAllowEmptyConnection(self, allowEmpty: bool)[source]

Sets whether an optional empty connection (“not set”) option is present in the model.

Parameters:

allowEmpty (bool)