Class: QgsDataSourceSelectDialog

The QgsDataSourceSelectDialog class embeds the browser view to select an existing data source.

By default any layer type can be chosen, the valid layer type can be restricted by setting a layer type filter with setLayerTypeFilter(layerType) or by activating the filter directly from the constructor.

To retrieve the selected data source, uri() can be called and it will return a (possibly invalid) QgsMimeDataUtils.Uri.

Added in version 3.6.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsDataSourceSelectDialog

Base classes

QDialog

QWidget

QObject

QPaintDevice

Methods

expandPath

Expands out a file path in the view.

setCaseSensitive

Sets filter case sensitivity

setDescription

Sets a description label

setFilter

Apply filter to the model

setFilterSyntax

Sets filter syntax

setLayerTypeFilter

Sets layer type filter to layerType and activates the filtering

showFilterWidget

Show/hide filter widget

uri

Returns the (possibly invalid) uri of the selected data source

class qgis.gui.QgsDataSourceSelectDialog[source]

Bases: QDialog

__init__(browserModel: QgsBrowserGuiModel | None = None, setFilterByLayerType: bool = False, layerType: Qgis.LayerType = Qgis.LayerType.Vector, parent: QWidget | None = None)

Constructs a QgsDataSourceSelectDialog, optionally filtering by layer type

Parameters:
  • browserModel (Optional[QgsBrowserGuiModel] = None) – an existing browser model (typically from app), if None an instance will be created

  • setFilterByLayerType (bool = False) – activates filtering by layer type

  • layerType (Qgis.LayerType = Qgis.LayerType.Vector) – sets the layer type filter, this is in effect only if filtering by layer type is also active

  • parent (Optional[QWidget] = None) – the object

expandPath(self, path: str | None, selectPath: bool = False)[source]

Expands out a file path in the view.

The path must correspond to a valid directory existing on the file system.

Since QGIS 3.38 the selectPath argument can be used to automatically select the path too.

Added in version 3.28.

Parameters:
  • path (Optional[str])

  • selectPath (bool = False)

setCaseSensitive(self, caseSensitive: bool)[source]

Sets filter case sensitivity

Parameters:

caseSensitive (bool)

setDescription(self, description: str | None)[source]

Sets a description label

Parameters:

description (Optional[str]) – a description string

Note

the description will be displayed at the bottom of the dialog

Added in version 3.8.

setFilter(self)[source]

Apply filter to the model

setFilterSyntax(self, a0: QAction | None)[source]

Sets filter syntax

Parameters:

a0 (Optional[QAction])

setLayerTypeFilter(self, layerType: Qgis.LayerType)[source]

Sets layer type filter to layerType and activates the filtering

Parameters:

layerType (Qgis.LayerType)

showFilterWidget(self, visible: bool)[source]

Show/hide filter widget

Parameters:

visible (bool)

uri(self) QgsMimeDataUtils.Uri[source]

Returns the (possibly invalid) uri of the selected data source

Return type:

QgsMimeDataUtils.Uri