Class: QgsProviderSublayerTask

A QgsTask which retrieves sublayer details for a URI.

This task executes a call to QgsProviderRegistry.querySublayers() in a background thread. Depending on the URI queried it can be expensive to calculate the sublayers (e.g. in the case where a full table scan is required to resolve mixed geometry type layers), so it is beneficial to perform these queries in the background wherever possible.

While QgsProviderRegistry.querySublayers() offers various flags to control how in-depth the querying will be, these flags are not exposed through QgsProviderSublayerTask. Rather QgsProviderSublayerTask will always execute the most thorough query possible, regardless of how expensive this may be.

Added in version 3.22.

Class Hierarchy

Inheritance diagram of qgis.core.QgsProviderSublayerTask

Base classes

QgsTask

Abstract base class for long running background tasks.

QObject

Methods

results

Returns the sublayer details as calculated by the task.

class qgis.core.QgsProviderSublayerTask[source]

Bases: QgsTask

__init__(uri: str | None, includeSystemTables: bool = False)

Constructor for QgsProviderSublayerTask, which retrieves sublayer details for the specified uri.

Parameters:
  • uri (Optional[str])

  • includeSystemTables (bool = False)

__init__(uri: str | None, providerKey: str | None, includeSystemTables: bool = False)

Constructor for QgsProviderSublayerTask, which retrieves sublayer details for the specified uri, restricted to a particular provider.

Added in version 3.30.

Parameters:
  • uri (Optional[str])

  • providerKey (Optional[str])

  • includeSystemTables (bool = False)

results(self) List[QgsProviderSublayerDetails]

Returns the sublayer details as calculated by the task.

Return type:

List[QgsProviderSublayerDetails]