Class: QgsDataSourceSelectWidget

class qgis.gui.QgsDataSourceSelectWidget(browserModel: QgsBrowserGuiModel = None, setFilterByLayerType: bool = False, layerType: QgsMapLayerType = QgsMapLayerType.VectorLayer, parent: QWidget = None)

Bases: QgsPanelWidget

Constructs a QgsDataSourceSelectWidget, optionally filtering by layer type

Parameters
  • browserModel (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 (QgsMapLayerType = QgsMapLayerType.VectorLayer) – sets the layer type filter, this is in effect only if filtering by layer type is also active

  • parent (QWidget = None) – the object

The QgsDataSourceSelectWidget 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.

Methods

actionEvent

changeEvent

childEvent

closeEvent

connectNotify

contextMenuEvent

create

customEvent

destroy

disconnectNotify

dragEnterEvent

dragLeaveEvent

dragMoveEvent

dropEvent

enterEvent

event

focusInEvent

focusNextChild

focusNextPrevChild

focusOutEvent

focusPreviousChild

hideEvent

initPainter

inputMethodEvent

isSignalConnected

keyPressEvent

keyReleaseEvent

leaveEvent

metric

mouseDoubleClickEvent

mouseMoveEvent

mousePressEvent

mouseReleaseEvent

moveEvent

nativeEvent

paintEvent

receivers

resizeEvent

sender

senderSignalIndex

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

sharedPainter

showEvent

Scroll to last selected index and expand it’s children

showFilterWidget

Show/hide filter widget

tabletEvent

timerEvent

updateMicroFocus

uri

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

wheelEvent

Signals

itemTriggered

Emitted when an item is triggered, e.g.

selectionChanged

Emitted when the current selection changes in the widget.

validationChanged

This signal is emitted whenever the validation status of the widget changes.

actionEvent()
changeEvent()
childEvent()
closeEvent()
connectNotify()
contextMenuEvent()
create()
customEvent()
destroy()
disconnectNotify()
dragEnterEvent()
dragLeaveEvent()
dragMoveEvent()
dropEvent()
enterEvent()
event()
focusInEvent()
focusNextChild()
focusNextPrevChild()
focusOutEvent()
focusPreviousChild()
hideEvent()
initPainter()
inputMethodEvent()
isSignalConnected()
itemTriggered

Emitted when an item is triggered, e.g. via a double-click. [signal]

Parameters

uri (QgsMimeDataUtils.Uri) –

keyPressEvent()
keyReleaseEvent()
leaveEvent()
metric()
mouseDoubleClickEvent()
mouseMoveEvent()
mousePressEvent()
mouseReleaseEvent()
moveEvent()
nativeEvent()
paintEvent()
receivers()
resizeEvent()
selectionChanged

Emitted when the current selection changes in the widget. [signal]

sender()
senderSignalIndex()
setCaseSensitive(self, caseSensitive: bool)

Sets filter case sensitivity

Parameters

caseSensitive (bool) –

setDescription(self, description: str)

Sets a description label

Parameters

description (str) – a description string

Note

the description will be displayed at the bottom of the dialog

New in version 3.8.

setFilter(self)

Apply filter to the model

setFilterSyntax(self, QAction)

Sets filter syntax

setLayerTypeFilter(self, layerType: QgsMapLayerType)

Sets layer type filter to layerType and activates the filtering

Parameters

layerType (QgsMapLayerType) –

sharedPainter()
showEvent(self, e: QShowEvent)

Scroll to last selected index and expand it’s children

Parameters

e (QShowEvent) –

showFilterWidget(self, visible: bool)

Show/hide filter widget

Parameters

visible (bool) –

tabletEvent()
timerEvent()
updateMicroFocus()
uri(self) → QgsMimeDataUtils.Uri

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

Return type

QgsMimeDataUtils.Uri

validationChanged

This signal is emitted whenever the validation status of the widget changes.

Parameters

isValid (bool) – True if the current status of the widget is valid [signal]

wheelEvent()