Class: QgsFileWidget¶
The QgsFileWidget
class creates a widget for selecting a
file or a folder.
Class Hierarchy¶
Base classes¶
Subclasses¶
The |
Methods
Returns whether a confirmation will be shown when overwriting an existing file. |
|
Returns the default root path. |
|
Returns the open file dialog title. |
|
Returns the current file path(s). |
|
Returns |
|
returns the filters used for QDialog.getOpenFileName |
|
Returns |
|
Returns a pointer to the widget's line edit, which can be used to customize the appearance and behavior of the line edit portion of the widget. |
|
Returns the additional options used for QFileDialog. |
|
Returns a filePath with relative path options applied (or not) ! |
|
Returns if the relative path is with respect to the project path or the default path. |
|
Returns the selected filter from the last opened file dialog. |
|
Sets whether a confirmation to overwrite an existing file will appear. |
|
Returns the default root path used as the first shown location when picking a file and used if the RelativeStorage is RelativeDefaultPath. |
|
Sets the title to use for the open file dialog. |
|
Sets the current file path. |
|
Update filePath according to filePaths list |
|
Sets whether the tool button is visible. |
|
setFilter sets the filter used by the model to filters. |
|
Sets whether links shown use the full path. |
|
Set additional options used for QFileDialog. |
|
Sets whether the widget should be read only. |
|
Sets whether the relative path is with respect to the project path or the default path. |
|
Called whenever user select fileNames from dialog |
|
Sets the selected filter when the file dialog opens. |
|
Sets the widget's storage mode (i.e. file or directory). |
|
Sets whether the file path will be shown as a link. |
|
Returns the widget's storage mode (i.e. file or directory). |
|
returns a HTML code with a link to the given file path |
|
Update buttons visibility |
|
Returns |
Static Methods
Returns true if path is a multifiles |
|
Split the the quoted and space separated path and returns a list of strings. |
Signals
Emitted whenever the current file or directory path is changed. |
Attributes
- class qgis.gui.QgsFileWidget[source]¶
Bases:
QWidget
- __init__(parent: QWidget | None = None)
QgsFileWidget creates a widget for selecting a file or a folder.
- Parameters:
parent (Optional[QWidget] = None)
- Absolute = 0¶
- GetDirectory = 1¶
- GetFile = 0¶
- GetMultipleFiles = 2¶
- RelativeDefaultPath = 2¶
- RelativeProject = 1¶
- class RelativeStorage¶
Bases:
int
- SaveFile = 3¶
- class StorageMode¶
Bases:
int
- confirmOverwrite(self) bool [source]¶
Returns whether a confirmation will be shown when overwriting an existing file.
See also
- Return type:
bool
- signal fileChanged(path: str)[source]¶
Emitted whenever the current file or directory
path
is changed.- Parameters:
path (str)
- filePath(self) str [source]¶
Returns the current file path(s).
When multiple files are selected they are quoted and separated by a single space (for example: ‘”/path/foo” “path/bar”’)
See also
See also
- Return type:
str
- fileWidgetButtonVisible(self) bool [source]¶
Returns
True
if the tool button is shown.See also
- Return type:
bool
- fullUrl(self) bool [source]¶
Returns
True
if the links shown use the full path.See also
- Return type:
bool
- static isMultiFiles(path: str | None) bool [source]¶
Returns true if
path
is a multifiles- Parameters:
path (Optional[str])
- Return type:
bool
- lineEdit(self) QgsFilterLineEdit | None [source]¶
Returns a pointer to the widget’s line edit, which can be used to customize the appearance and behavior of the line edit portion of the widget.
- Return type:
Optional[QgsFilterLineEdit]
- options(self) QFileDialog.Options [source]¶
Returns the additional options used for QFileDialog.
See also
Added in version 3.14.
- Return type:
QFileDialog.Options
- relativePath(self, filePath: str | None, removeRelative: bool) str [source]¶
Returns a filePath with relative path options applied (or not) !
- Parameters:
filePath (Optional[str])
removeRelative (bool)
- Return type:
str
- relativeStorage(self) QgsFileWidget.RelativeStorage [source]¶
Returns if the relative path is with respect to the project path or the default path.
See also
- Return type:
- selectedFilter(self) str [source]¶
Returns the selected filter from the last opened file dialog.
See also
- Return type:
str
- setConfirmOverwrite(self, confirmOverwrite: bool)[source]¶
Sets whether a confirmation to overwrite an existing file will appear.
By default, a confirmation will appear.
- Parameters:
confirmOverwrite (bool) – If set to
True
, an overwrite confirmation will be shown
See also
- setDefaultRoot(self, defaultRoot: str | None)[source]¶
Returns the default root path used as the first shown location when picking a file and used if the RelativeStorage is RelativeDefaultPath.
See also
- Parameters:
defaultRoot (Optional[str])
- setDialogTitle(self, title: str | None)[source]¶
Sets the
title
to use for the open file dialog.Note
If not defined, the title is “Select a file” or “Select a directory” or “Select one or more files” depending on the configuration.
See also
- Parameters:
title (Optional[str])
- setFilePath(self, path: str | None)[source]¶
Sets the current file
path
.See also
- Parameters:
path (Optional[str])
- setFilePaths(self, filePaths: Iterable[str | None])[source]¶
Update filePath according to
filePaths
list- Parameters:
filePaths (Iterable[Optional[str]])
- setFileWidgetButtonVisible(self, visible: bool)[source]¶
Sets whether the tool button is
visible
.See also
- Parameters:
visible (bool)
- setFilter(self, filter: str | None)[source]¶
setFilter sets the filter used by the model to filters. The filter is used to specify the kind of files that should be shown.
- Parameters:
filter (Optional[str]) – Only files that match the given filter are shown, it may be an empty string. If you want multiple filters, separate them with ‘;;’,
- setFullUrl(self, fullUrl: bool)[source]¶
Sets whether links shown use the full path.
See also
- Parameters:
fullUrl (bool)
- setOptions(self, options: QFileDialog.Options | QFileDialog.Option)[source]¶
Set additional options used for QFileDialog.
These options affect the look and feel of the QFileDialog shown when a user is interactively browsing for paths.
See also
Added in version 3.14.
- Parameters:
options (Union[QFileDialog.Options, QFileDialog.Option])
- setReadOnly(self, readOnly: bool)[source]¶
Sets whether the widget should be read only.
- Parameters:
readOnly (bool)
- setRelativeStorage(self, relativeStorage: QgsFileWidget.RelativeStorage)[source]¶
Sets whether the relative path is with respect to the project path or the default path.
See also
- Parameters:
relativeStorage (QgsFileWidget.RelativeStorage)
- setSelectedFileNames(self, fileNames: Iterable[str | None])[source]¶
Called whenever user select
fileNames
from dialog- Parameters:
fileNames (Iterable[Optional[str]])
- setSelectedFilter(self, selectedFilter: str | None)[source]¶
Sets the selected filter when the file dialog opens.
See also
- Parameters:
selectedFilter (Optional[str])
- setStorageMode(self, storageMode: QgsFileWidget.StorageMode)[source]¶
Sets the widget’s storage mode (i.e. file or directory).
See also
- Parameters:
storageMode (QgsFileWidget.StorageMode)
- setUseLink(self, useLink: bool)[source]¶
Sets whether the file path will be shown as a link.
See also
- Parameters:
useLink (bool)
- static splitFilePaths(path: str | None) List[str] [source]¶
Split the the quoted and space separated
path
and returns a list of strings.See also
- Parameters:
path (Optional[str])
- Return type:
List[str]
- storageMode(self) QgsFileWidget.StorageMode [source]¶
Returns the widget’s storage mode (i.e. file or directory).
See also
- Return type:
- toUrl(self, path: str | None) str [source]¶
returns a HTML code with a link to the given file path
- Parameters:
path (Optional[str])
- Return type:
str