Subgroup: Provider

Class: QgsProviderRegistry

class qgis.core.QgsProviderRegistry

Bases: sip.wrapper

A registry / canonical manager of data providers.

This is a Singleton class that manages data provider access.

Providers can be either loaded via libraries or native providers that are included in the core QGIS installation and accessed through function pointers.

Loaded providers may be restricted using QGIS_PROVIDER_FILE environment variable. QGIS_PROVIDER_FILE is regexp pattern applied to provider file name (not provider key). For example, if the variable is set to gdal|ogr|postgres it will load only providers gdal, ogr and postgres.

Methods

createProvider Creates a new instance of a provider.
createProviderLibrary Returns a new QLibrary for the specified providerKey.
createSelectionWidget Returns a new widget for selecting layers from a provider.
databaseDrivers Return a string containing the available database drivers
directoryDrivers Return a string containing the available directory drivers
fileRasterFilters Return raster file filter string
fileVectorFilters Return vector file filter string
function Get pointer to provider function
instance Means of accessing canonical single instance
library Return path for the library of the provider.
libraryDirectory Returns the library directory where plugins are found.
pluginList Return list of provider plugins found
protocolDrivers Return a string containing the available protocol drivers
providerCapabilities Return the provider capabilities
providerList Return list of available providers by their keys
providerMetadata Return metadata of the provider or NULL if not found
registerGuis
setLibraryDirectory Set library directory where to search for plugins

Signals

Attributes

Embedded
Manager
None
Embedded = 1
Manager = 2
None = 0
class WidgetMode

Bases: int

createProvider(self, providerKey: str, dataSource: str) → QgsDataProvider

Creates a new instance of a provider.

Parameters:
  • providerKey – identificator of the provider
  • dataSource – string containing data source for the provider
Returns:

new instance of provider or NULL on error

createProviderLibrary(self, providerKey: str) → QLibrary

Returns a new QLibrary for the specified providerKey. Ownership of the returned object is transferred to the caller and the caller is responsible for deleting it.

If the provider uses direct provider function pointers instead of a library None will be returned.

createSelectionWidget(self, providerKey: str, parent: QWidget = None, fl: Union[Qt.WindowFlags, Qt.WindowType] = Qt.WindowFlags(), widgetMode: QgsProviderRegistry.WidgetMode = QgsProviderRegistry.WidgetMode.None) → QWidget

Returns a new widget for selecting layers from a provider. Either the parent widget must be set or the caller becomes responsible for deleting the returned widget.

databaseDrivers(self) → str

Return a string containing the available database drivers

directoryDrivers(self) → str

Return a string containing the available directory drivers

fileRasterFilters(self) → str

Return raster file filter string

Returns a string suitable for a QFileDialog of raster file formats supported by all data providers.

This walks through all data providers appending calls to their buildSupportedRasterFileFilter to a string, which is then returned.

Note

This replaces QgsRasterLayer.buildSupportedRasterFileFilter()

fileVectorFilters(self) → str

Return vector file filter string

Returns a string suitable for a QFileDialog of vector file formats supported by all data providers.

This walks through all data providers appending calls to their fileVectorFilters to a string, which is then returned.

note

It’d be nice to eventually be raster/vector neutral.

function(self, providerKey: str, functionName: str) → sip.voidptr

Get pointer to provider function

Parameters:
  • providerKey – identificator of the provider
  • functionName – name of function
Returns:

pointer to function or NULL on error. If the provider uses direct provider

function pointers instead of a library None will be returned.

instance(pluginPath: str = '') → QgsProviderRegistry

Means of accessing canonical single instance

library(self, providerKey: str) → str

Return path for the library of the provider.

If the provider uses direct provider function pointers instead of a library an empty string will be returned.

libraryDirectory(self) → QDir

Returns the library directory where plugins are found.

pluginList(self, asHtml: bool = False) → str

Return list of provider plugins found

protocolDrivers(self) → str

Return a string containing the available protocol drivers

providerCapabilities(self, providerKey: str) → int

Return the provider capabilities

Parameters:providerKey – identificator of the provider

New in version 2.6.

providerList(self) → List[str]

Return list of available providers by their keys

providerMetadata(self, providerKey: str) → QgsProviderMetadata

Return metadata of the provider or NULL if not found

registerGuis(self, widget: QWidget)
setLibraryDirectory(self, path: QDir)

Set library directory where to search for plugins