Class: QgsDataSourceSelectWidget

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.14.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsDataSourceSelectWidget

Base classes

QgsPanelWidget

Base class for any widget that can be shown as an inline panel.

QWidget

QObject

QPaintDevice

class qgis.gui.QgsDataSourceSelectWidget[source]

Bases: QgsPanelWidget

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

Constructs a QgsDataSourceSelectWidget, 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)

signal itemTriggered[source]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

signal selectionChanged[source]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.

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)

virtual showEvent(self, e: QShowEvent | None)[source]

Scroll to last selected index and expand it’s children

Parameters:

e (Optional[QShowEvent])

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

signal validationChanged[source]

pyqtSignal(*types, name: str = …, revision: int = …, arguments: Sequence = …) -> PYQT_SIGNAL

types is normally a sequence of individual types. Each type is either a type object or a string that is the name of a C++ type. Alternatively each type could itself be a sequence of types each describing a different overloaded signal. name is the optional C++ name of the signal. If it is not specified then the name of the class attribute that is bound to the signal is used. revision is the optional revision of the signal that is exported to QML. If it is not specified then 0 is used. arguments is the optional sequence of the names of the signal’s arguments.