Class: QgsFileWidget¶
- class qgis.gui.QgsFileWidget¶
Bases:
PyQt5.QtWidgets.QWidget
The
QgsFileWidget
class creates a widget for selecting a file or a folder.QgsFileWidget(parent: QWidget = None)
QgsFileWidget
creates a widget for selecting a file or a folder.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
True
if the tool button is shown.returns the filters used for QDialog.getOpenFileName
Returns
True
if the links shown use the full path.Returns true if
path
is a multifilesReturns 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.
- rtype:
QSize
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
listSets 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 dialogSets the selected filter when the file dialog opens.
Sets the widget's storage mode (i.e.
Sets whether the file path will be shown as a link.
Split the the quoted and space separated
path
and returns a list of strings.Returns the widget's storage mode (i.e.
returns a HTML code with a link to the given file path
Update buttons visibility
Returns
True
if the file path will be shown as a link.Signals
pyqtSignal(*types, name: str = ..., revision: int = ..., arguments: Sequence = ...) -> PYQT_SIGNAL
Attributes
- Absolute = 0¶
- GetDirectory = 1¶
- GetFile = 0¶
- GetMultipleFiles = 2¶
- RelativeDefaultPath = 2¶
- RelativeProject = 1¶
- class RelativeStorage¶
Bases:
int
- baseClass¶
alias of
QgsFileWidget
- SaveFile = 3¶
- class StorageMode¶
Bases:
int
- baseClass¶
alias of
QgsFileWidget
- actionEvent(self, QActionEvent)¶
- changeEvent(self, QEvent)¶
- childEvent(self, QChildEvent)¶
- closeEvent(self, QCloseEvent)¶
- confirmOverwrite(self) bool ¶
Returns whether a confirmation will be shown when overwriting an existing file.
See also
- Return type:
bool
- connectNotify(self, QMetaMethod)¶
- contextMenuEvent(self, QContextMenuEvent)¶
- create(self, window: PyQt5.sip.voidptr = 0, initializeWindow: bool = True, destroyOldWindow: bool = True)¶
- customEvent(self, QEvent)¶
- defaultRoot(self) str ¶
Returns the default root path.
See also
- Return type:
str
- destroy(self, destroyWindow: bool = True, destroySubWindows: bool = True)¶
- dialogTitle(self) str ¶
Returns the open file dialog title.
See also
- Return type:
str
- disconnectNotify(self, QMetaMethod)¶
- dragEnterEvent(self, QDragEnterEvent)¶
- dragLeaveEvent(self, QDragLeaveEvent)¶
- dragMoveEvent(self, QDragMoveEvent)¶
- dropEvent(self, QDropEvent)¶
- enterEvent(self, QEvent)¶
- event(self, QEvent) bool ¶
- fileChanged¶
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.
- Parameters:
name (str = ...) –
revision (int = ...) –
arguments (Sequence = ...) –
- Return type:
PYQT_SIGNAL
- filePath(self) str ¶
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 ¶
Returns
True
if the tool button is shown.See also
- Return type:
bool
- filter(self) str ¶
returns the filters used for QDialog.getOpenFileName
- Return type:
str
- focusInEvent(self, QFocusEvent)¶
- focusNextChild(self) bool ¶
- focusNextPrevChild(self, bool) bool ¶
- focusOutEvent(self, QFocusEvent)¶
- focusPreviousChild(self) bool ¶
- fullUrl(self) bool ¶
Returns
True
if the links shown use the full path.See also
- Return type:
bool
- hideEvent(self, QHideEvent)¶
- initPainter(self, QPainter)¶
- inputMethodEvent(self, QInputMethodEvent)¶
- isMultiFiles(path: str) bool ¶
Returns true if
path
is a multifiles- Parameters:
path (str) –
- Return type:
bool
- isSignalConnected(self, QMetaMethod) bool ¶
- keyPressEvent(self, QKeyEvent)¶
- keyReleaseEvent(self, QKeyEvent)¶
- leaveEvent(self, QEvent)¶
- lineEdit(self) QgsFilterLineEdit ¶
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.
New in version 3.0.
- Return type:
- metric(self, QPaintDevice.PaintDeviceMetric) int ¶
- minimumSizeHint(self) QSize ¶
- Return type:
QSize
- mouseDoubleClickEvent(self, QMouseEvent)¶
- mouseMoveEvent(self, QMouseEvent)¶
- mousePressEvent(self, QMouseEvent)¶
- mouseReleaseEvent(self, QMouseEvent)¶
- moveEvent(self, QMoveEvent)¶
- nativeEvent(self, Union[QByteArray, bytes, bytearray], PyQt5.sip.voidptr) Tuple[bool, int] ¶
- options(self) QFileDialog.Options ¶
Returns the additional options used for QFileDialog.
See also
New in version 3.14.
- Return type:
QFileDialog.Options
- paintEvent(self, QPaintEvent)¶
- receivers(self, PYQT_SIGNAL) int ¶
- relativePath(self, filePath: str, removeRelative: bool) str ¶
Returns a filePath with relative path options applied (or not) !
- Parameters:
filePath (str) –
removeRelative (bool) –
- Return type:
str
- relativeStorage(self) QgsFileWidget.RelativeStorage ¶
Returns if the relative path is with respect to the project path or the default path.
See also
- Return type:
- resizeEvent(self, QResizeEvent)¶
- selectedFilter(self) str ¶
Returns the selected filter from the last opened file dialog.
See also
- Return type:
str
- sender(self) QObject ¶
- senderSignalIndex(self) int ¶
- setConfirmOverwrite(self, confirmOverwrite: bool)¶
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)¶
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 (str) –
- setDialogTitle(self, title: str)¶
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 (str) –
- setFilePath(self, path: str)¶
Sets the current file
path
.See also
- Parameters:
path (str) –
- setFilePaths(self, filePaths: Iterable[str])¶
Update filePath according to
filePaths
list- Parameters:
filePaths (Iterable[str]) –
- setFileWidgetButtonVisible(self, visible: bool)¶
Sets whether the tool button is
visible
.See also
- Parameters:
visible (bool) –
- setFilter(self, filter: str)¶
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 (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)¶
Sets whether links shown use the full path.
See also
- Parameters:
fullUrl (bool) –
- setOptions(self, options: QFileDialog.Options | QFileDialog.Option)¶
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
New in version 3.14.
- Parameters:
options (Union[QFileDialog.Options) –
- setReadOnly(self, readOnly: bool)¶
Sets whether the widget should be read only.
- Parameters:
readOnly (bool) –
- setRelativeStorage(self, relativeStorage: QgsFileWidget.RelativeStorage)¶
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])¶
Called whenever user select
fileNames
from dialog- Parameters:
fileNames (Iterable[str]) –
- setSelectedFilter(self, selectedFilter: str)¶
Sets the selected filter when the file dialog opens.
See also
- Parameters:
selectedFilter (str) –
- setStorageMode(self, storageMode: QgsFileWidget.StorageMode)¶
Sets the widget’s storage mode (i.e. file or directory).
See also
- Parameters:
storageMode (QgsFileWidget.StorageMode) –
- setUseLink(self, useLink: bool)¶
Sets whether the file path will be shown as a link.
See also
- Parameters:
useLink (bool) –
- showEvent(self, QShowEvent)¶
- splitFilePaths(path: str) List[str] ¶
Split the the quoted and space separated
path
and returns a list of strings.See also
- Parameters:
path (str) –
- Return type:
List[str]
- storageMode(self) QgsFileWidget.StorageMode ¶
Returns the widget’s storage mode (i.e. file or directory).
See also
- Return type:
- tabletEvent(self, QTabletEvent)¶
- timerEvent(self, QTimerEvent)¶
- toUrl(self, path: str) str ¶
returns a HTML code with a link to the given file path
- Parameters:
path (str) –
- Return type:
str
- updateLayout(self)¶
Update buttons visibility
- updateMicroFocus(self)¶
- useLink(self) bool ¶
Returns
True
if the file path will be shown as a link.See also
- Return type:
bool
- wheelEvent(self, QWheelEvent)¶