Class: QgsExternalResourceWidget

Widget to display file path with a push button for an “open file” dialog It can also be used to display a picture or a web page.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsExternalResourceWidget

Base classes

QWidget

QObject

QPaintDevice

Methods

defaultRoot

Configures the base path which should be used if the relativeStorage property is set to QgsFileWidget.RelativeDefaultPath.

documentPath

documentPath returns the path of the current document in the widget

documentViewerContent

returns the type of content used in the document viewer

documentViewerHeight

returns the height of the document viewer

documentViewerWidth

returns the width of the document viewer

fileWidget

Returns file widget to allow its configuration

fileWidgetVisible

returns if the file widget is visible in the widget

messageBar

Returns message bar used to report messages

relativeStorage

Configures if paths are handled absolute or relative and if relative, which should be the base path.

setDefaultRoot

Configures the base path which should be used if the relativeStorage property is set to QgsFileWidget.RelativeDefaultPath.

setDocumentPath

setDocumentViewerContent

setDocumentViewerContent defines the type of content to be shown.

setDocumentViewerHeight

setDocumentViewerWidth set the height of the document viewer.

setDocumentViewerWidth

setDocumentViewerWidth set the width of the document viewer.

setFileWidgetVisible

Sets the visibility of the file widget in the layout

setMessageBar

Set messageBar to report messages

setReadOnly

defines if the widget is readonly

setRelativeStorage

Configures if paths are handled absolute or relative and if relative, which should be the base path.

setStorageAuthConfigId

Sets the authentication configuration ID to be used for the current external storage (if defined)

setStorageType

Set storageType storage type unique identifier as defined in QgsExternalStorageRegistry or an empty string if there is no storage defined, only file selection.

storageAuthConfigId

Returns the authentication configuration ID used for the current external storage (if defined)

storageType

Returns storage type unique identifier as defined in QgsExternalStorageRegistry.

Signals

valueChanged

Emitted as soon as the current document changes

Attributes

Audio

Image

NoContent

Video

Web

class qgis.gui.QgsExternalResourceWidget[source]

Bases: QWidget

__init__(parent: QWidget | None = None)

QgsExternalResourceWidget creates a widget with a file widget and a document viewer Both part of the widget are optional.

See also

QgsFileWidget

Parameters:

parent (Optional[QWidget] = None)

Audio = 3
class DocumentViewerContent

Bases: int

Image = 1
NoContent = 0
Video = 4
Web = 2
defaultRoot(self) str[source]

Configures the base path which should be used if the relativeStorage property is set to QgsFileWidget.RelativeDefaultPath.

Return type:

str

documentPath(self, type: QMetaType.Type = QMetaType.Type.QString) Any[source]

documentPath returns the path of the current document in the widget

Parameters:

type (QMetaType.Type = QMetaType.Type.QString) – determines the type of the returned null variant if the document is not defined yet

Return type:

Any

documentPath(self, type: QVariant.Type) Any[source]

documentPath returns the path of the current document in the widget

Parameters:

type (QVariant.Type) – determines the type of the returned null variant if the document is not defined yet

Deprecated since version 3.38: Use the method with a QMetaType.Type argument instead.

Return type:

Any

documentViewerContent(self) QgsExternalResourceWidget.DocumentViewerContent[source]

returns the type of content used in the document viewer

Return type:

QgsExternalResourceWidget.DocumentViewerContent

documentViewerHeight(self) int[source]

returns the height of the document viewer

Return type:

int

documentViewerWidth(self) int[source]

returns the width of the document viewer

Return type:

int

fileWidget(self) QgsExternalStorageFileWidget | None[source]

Returns file widget to allow its configuration

Return type:

Optional[QgsExternalStorageFileWidget]

fileWidgetVisible(self) bool[source]

returns if the file widget is visible in the widget

Return type:

bool

messageBar(self) QgsMessageBar | None[source]

Returns message bar used to report messages

Added in version 3.22.

Return type:

Optional[QgsMessageBar]

relativeStorage(self) QgsFileWidget.RelativeStorage[source]

Configures if paths are handled absolute or relative and if relative, which should be the base path.

Return type:

QgsFileWidget.RelativeStorage

setDefaultRoot(self, defaultRoot: str | None)[source]

Configures the base path which should be used if the relativeStorage property is set to QgsFileWidget.RelativeDefaultPath.

Parameters:

defaultRoot (Optional[str])

setDocumentPath(self, documentPath: Any)[source]
Parameters:

documentPath (Any)

setDocumentViewerContent(self, content: QgsExternalResourceWidget.DocumentViewerContent)[source]

setDocumentViewerContent defines the type of content to be shown. Widget will be adapted accordingly

Parameters:

content (QgsExternalResourceWidget.DocumentViewerContent)

setDocumentViewerHeight(self, height: int)[source]

setDocumentViewerWidth set the height of the document viewer.

Parameters:

height (int) – the height. Use 0 for automatic best display.

setDocumentViewerWidth(self, width: int)[source]

setDocumentViewerWidth set the width of the document viewer.

Parameters:

width (int) – the width. Use 0 for automatic best display.

setFileWidgetVisible(self, visible: bool)[source]

Sets the visibility of the file widget in the layout

Parameters:

visible (bool)

setMessageBar(self, messageBar: QgsMessageBar | None)[source]

Set messageBar to report messages

Added in version 3.22.

Parameters:

messageBar (Optional[QgsMessageBar])

setReadOnly(self, readOnly: bool)[source]

defines if the widget is readonly

Parameters:

readOnly (bool)

setRelativeStorage(self, relativeStorage: QgsFileWidget.RelativeStorage)[source]

Configures if paths are handled absolute or relative and if relative, which should be the base path.

Parameters:

relativeStorage (QgsFileWidget.RelativeStorage)

setStorageAuthConfigId(self, authCfg: str | None)[source]

Sets the authentication configuration ID to be used for the current external storage (if defined)

Added in version 3.22.

Parameters:

authCfg (Optional[str])

setStorageType(self, storageType: str | None)[source]

Set storageType storage type unique identifier as defined in QgsExternalStorageRegistry or an empty string if there is no storage defined, only file selection.

See also

storageType()

Added in version 3.22.

Parameters:

storageType (Optional[str])

storageAuthConfigId(self) str[source]

Returns the authentication configuration ID used for the current external storage (if defined)

Added in version 3.22.

Return type:

str

storageType(self) str[source]

Returns storage type unique identifier as defined in QgsExternalStorageRegistry. Returns an empty string if there is no storage defined, only file selection.

See also

setStorageType()

Added in version 3.22.

Return type:

str

signal valueChanged(value: str)[source]

Emitted as soon as the current document changes

Parameters:

value (str)