QFileDialog¶
The
QFileDialogclass provides a dialog that allow users to select files or directories. More…

Synopsis¶
Functions¶
- def - acceptMode()
- def - confirmOverwrite()
- def - defaultSuffix()
- def - directory()
- def - directoryUrl()
- def - fileMode()
- def - filter()
- def - history()
- def - iconProvider()
- def - isNameFilterDetailsVisible()
- def - isReadOnly()
- def - itemDelegate()
- def - labelText(label)
- def - mimeTypeFilters()
- def - nameFilters()
- def - open(receiver, member)
- def - options()
- def - proxyModel()
- def - resolveSymlinks()
- def - restoreState(state)
- def - saveState()
- def - selectFile(filename)
- def - selectMimeTypeFilter(filter)
- def - selectNameFilter(filter)
- def - selectUrl(url)
- def - selectedFiles()
- def - selectedMimeTypeFilter()
- def - selectedNameFilter()
- def - selectedUrls()
- def - setAcceptMode(mode)
- def - setConfirmOverwrite(enabled)
- def - setDefaultSuffix(suffix)
- def - setDirectory(directory)
- def - setDirectory(directory)
- def - setDirectoryUrl(directory)
- def - setFileMode(mode)
- def - setFilter(filters)
- def - setHistory(paths)
- def - setIconProvider(provider)
- def - setItemDelegate(delegate)
- def - setLabelText(label, text)
- def - setMimeTypeFilters(filters)
- def - setNameFilter(filter)
- def - setNameFilterDetailsVisible(enabled)
- def - setNameFilters(filters)
- def - setOption(option[, on=true])
- def - setOptions(options)
- def - setProxyModel(model)
- def - setReadOnly(enabled)
- def - setResolveSymlinks(enabled)
- def - setSidebarUrls(urls)
- def - setSupportedSchemes(schemes)
- def - setViewMode(mode)
- def - sidebarUrls()
- def - supportedSchemes()
- def - testOption(option)
- def - viewMode()
Signals¶
- def - currentChanged(path)
- def - currentUrlChanged(url)
- def - directoryEntered(directory)
- def - directoryUrlEntered(directory)
- def - fileSelected(file)
- def - filesSelected(files)
- def - filterSelected(filter)
- def - urlSelected(url)
- def - urlsSelected(urls)
Static functions¶
- def - getExistingDirectory([parent=None[, caption=”“[, dir=”“[, options=QFileDialog.ShowDirsOnly]]]])
- def - getExistingDirectoryUrl([parent=None[, caption=”“[, dir=QUrl()[, options=QFileDialog.ShowDirsOnly[, supportedSchemes=list()]]]]])
- def - getOpenFileName([parent=None[, caption=”“[, dir=”“[, filter=”“[, selectedFilter=”“[, options=QFileDialog.Options()]]]]]])
- def - getOpenFileNames([parent=None[, caption=”“[, dir=”“[, filter=”“[, selectedFilter=”“[, options=QFileDialog.Options()]]]]]])
- def - getOpenFileUrl([parent=None[, caption=”“[, dir=QUrl()[, filter=”“[, selectedFilter=”“[, options=QFileDialog.Options()[, supportedSchemes=list()]]]]]]])
- def - getOpenFileUrls([parent=None[, caption=”“[, dir=QUrl()[, filter=”“[, selectedFilter=”“[, options=QFileDialog.Options()[, supportedSchemes=list()]]]]]]])
- def - getSaveFileName([parent=None[, caption=”“[, dir=”“[, filter=”“[, selectedFilter=”“[, options=QFileDialog.Options()]]]]]])
- def - getSaveFileUrl([parent=None[, caption=”“[, dir=QUrl()[, filter=”“[, selectedFilter=”“[, options=QFileDialog.Options()[, supportedSchemes=list()]]]]]]])
Detailed Description¶
The
QFileDialogclass enables a user to traverse the file system in order to select one or many files or a directory.The easiest way to create a
QFileDialogis to use the static functions.fileName = QFileDialog.getOpenFileName(self, tr("Open Image"), "/home/jana", tr("Image Files (*.png *.jpg *.bmp)"))In the above example, a modal
QFileDialogis created using a static function. The dialog initially displays the contents of the “/home/jana” directory, and displays files matching the patterns given in the string “Image Files (*.png *.jpg *.bmp)”. The parent of the file dialog is set to this , and the window title is set to “Open Image”.If you want to use multiple filters, separate each one with two semicolons. For example:
"Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)"You can create your own
QFileDialogwithout using the static functions. By callingsetFileMode(), you can specify what the user must select in the dialog:dialog = QFileDialog(self) dialog.setFileMode(QFileDialog.AnyFile)In the above example, the mode of the file dialog is set to
AnyFile, meaning that the user can select any file, or even specify a file that doesn’t exist. This mode is useful for creating a “Save As” file dialog. UseExistingFileif the user must select an existing file, orDirectoryif only a directory may be selected. See theFileModeenum for the complete list of modes.The
fileModeproperty contains the mode of operation for the dialog; this indicates what types of objects the user is expected to select. UsesetNameFilter()to set the dialog’s file filter. For example:dialog.setNameFilter(tr("Images (*.png *.xpm *.jpg)"))In the above example, the filter is set to
"Images (*.png *.xpm *.jpg)", this means that only files with the extensionpng,xpm, orjpgwill be shown in theQFileDialog. You can apply several filters by usingsetNameFilters(). UseselectNameFilter()to select one of the filters you’ve given as the file dialog’s default filter.The file dialog has two view modes:
ListandDetail.Listpresents the contents of the current directory as a list of file and directory names.Detailalso displays a list of file and directory names, but provides additional information alongside each name, such as the file size and modification date. Set the mode withsetViewMode():dialog.setViewMode(QFileDialog.Detail)The last important function you will need to use when creating your own file dialog is
selectedFiles().if dialog.exec_(): fileNames = dialog.selectedFiles()In the above example, a modal file dialog is created and shown. If the user clicked OK, the file they selected is put in
fileName.The dialog’s working directory can be set with
setDirectory(). Each file in the current directory can be selected using theselectFile()function.The Standard Dialogs example shows how to use
QFileDialogas well as other built-in Qt dialogs.By default, a platform-native file dialog will be used if the platform has one. In that case, the widgets which would otherwise be used to construct the dialog will not be instantiated, so related accessors such as
layout()anditemDelegate()will return null. You can set theDontUseNativeDialogoption to ensure that the widget-based implementation will be used instead of the native dialog.See also
QDirQFileInfoQFileQColorDialogQFontDialogStandard Dialogs Example Application Example
- 
class QFileDialog(parent, f)¶
- QFileDialog([parent=None[, caption=”“[, directory=”“[, filter=”“]]]]) - param f
- WindowFlags
- param parent
- param filter
- unicode 
- param directory
- unicode 
- param caption
- unicode 
 - Constructs a file dialog with the given - parentand widget- flags.- Constructs a file dialog with the given - parentand- captionthat initially displays the contents of the specified- directory. The contents of the directory are filtered before being shown in the dialog, using a semicolon-separated list of filters specified by- filter.
- 
PySide2.QtWidgets.QFileDialog.ViewMode¶
- This enum describes the view mode of the file dialog; i.e. what information about each file will be displayed. - Constant - Description - QFileDialog.Detail - Displays an icon, a name, and details for each item in the directory. - QFileDialog.List - Displays only an icon and a name for each item in the directory. - See also 
- 
PySide2.QtWidgets.QFileDialog.FileMode¶
- This enum is used to indicate what the user may select in the file dialog; i.e. what the dialog will return if the user clicks OK. - Constant - Description - QFileDialog.AnyFile - The name of a file, whether it exists or not. - QFileDialog.ExistingFile - The name of a single existing file. - QFileDialog.Directory - The name of a directory. Both files and directories are displayed. However, the native Windows file dialog does not support displaying files in the directory chooser. - QFileDialog.ExistingFiles - The names of zero or more existing files. - This value is obsolete since Qt 4.5: - Constant - Description - QFileDialog.DirectoryOnly - Use - Directoryand- setOption(- ShowDirsOnly, true) instead.- See also 
- 
PySide2.QtWidgets.QFileDialog.AcceptMode¶
- Constant - Description - QFileDialog.AcceptOpen - QFileDialog.AcceptSave 
- 
PySide2.QtWidgets.QFileDialog.DialogLabel¶
- Constant - Description - QFileDialog.LookIn - QFileDialog.FileName - QFileDialog.FileType - QFileDialog.Accept - QFileDialog.Reject 
- 
PySide2.QtWidgets.QFileDialog.Option¶
- Constant - Description - QFileDialog.ShowDirsOnly - Only show directories in the file dialog. By default both files and directories are shown. (Valid only in the - Directoryfile mode.)- QFileDialog.DontResolveSymlinks - Don’t resolve symlinks in the file dialog. By default symlinks are resolved. - QFileDialog.DontConfirmOverwrite - Don’t ask for confirmation if an existing file is selected. By default confirmation is requested. - QFileDialog.DontUseNativeDialog - Don’t use the native file dialog. By default, the native file dialog is used unless you use a subclass of - QFileDialogthat contains the- Q_OBJECTmacro, or the platform does not have a native dialog of the type that you require.- Note - This option must be set before changing dialog properties or showing the dialog. - Constant - Description - QFileDialog.ReadOnly - Indicates that the model is readonly. - QFileDialog.HideNameFilterDetails - Indicates if the file name filter details are hidden or not. - QFileDialog.DontUseSheet - In previous versions of Qt, the static functions would create a sheet by default if the static function was given a parent. This is no longer supported and does nothing in Qt 4.5, The static functions will always be an application modal dialog. If you want to use sheets, use - open()instead.- QFileDialog.DontUseCustomDirectoryIcons - Always use the default directory icon. Some platforms allow the user to set a different icon. Custom icon lookup cause a big performance impact over network or removable drives. Setting this will enable the - DontUseCustomDirectoryIconsoption in the icon provider. This enum value was added in Qt 5.2.
- 
PySide2.QtWidgets.QFileDialog.acceptMode()¶
- Return type
 - See also 
- 
PySide2.QtWidgets.QFileDialog.confirmOverwrite()¶
- Return type
- bool
 - See also 
- 
PySide2.QtWidgets.QFileDialog.currentChanged(path)¶
- Parameters
- path – unicode 
 
- 
PySide2.QtWidgets.QFileDialog.currentUrlChanged(url)¶
- Parameters
- url – - QUrl
 
- 
PySide2.QtWidgets.QFileDialog.defaultSuffix()¶
- Return type
- unicode 
 - See also 
- 
PySide2.QtWidgets.QFileDialog.directory()¶
- Return type
- QDir
 - Returns the directory currently being displayed in the dialog. - See also 
- 
PySide2.QtWidgets.QFileDialog.directoryEntered(directory)¶
- Parameters
- directory – unicode 
 
- 
PySide2.QtWidgets.QFileDialog.directoryUrl()¶
- Return type
- QUrl
 - Returns the url of the directory currently being displayed in the dialog. - See also 
- 
PySide2.QtWidgets.QFileDialog.directoryUrlEntered(directory)¶
- Parameters
- directory – - QUrl
 
- 
PySide2.QtWidgets.QFileDialog.fileMode()¶
- Return type
 - See also 
- 
PySide2.QtWidgets.QFileDialog.fileSelected(file)¶
- Parameters
- file – unicode 
 
- 
PySide2.QtWidgets.QFileDialog.filesSelected(files)¶
- Parameters
- files – list of strings 
 
- 
PySide2.QtWidgets.QFileDialog.filter()¶
- Return type
- Filters
 - Returns the filter that is used when displaying files. - See also 
- 
PySide2.QtWidgets.QFileDialog.filterSelected(filter)¶
- Parameters
- filter – unicode 
 
- 
static PySide2.QtWidgets.QFileDialog.getExistingDirectory([parent=None[, caption=""[, dir=""[, options=QFileDialog.ShowDirsOnly]]]])¶
- Parameters
- parent – - QWidget
- caption – unicode 
- dir – unicode 
- options – - Options
 
- Return type
- unicode 
 - This is a convenience static function that will return an existing directory selected by the user. - dir = QFileDialog.getExistingDirectory(self, tr("Open Directory"), "/home", QFileDialog.ShowDirsOnly | QFileDialog.DontResolveSymlinks) - This function creates a modal file dialog with the given - parentwidget. If- parentis not 0, the dialog will be shown centered over the parent widget.- The dialog’s working directory is set to - dir, and the caption is set to- caption. Either of these may be an empty string in which case the current directory and a default caption will be used respectively.- The - optionsargument holds various options about how to run the dialog, see the- Optionenum for more information on the flags you can pass. To ensure a native file dialog,- ShowDirsOnlymust be set.- On Windows and macOS , this static function will use the native file dialog and not a - QFileDialog. However, the native Windows file dialog does not support displaying files in the directory chooser. You need to pass- DontUseNativeDialogto display files using a- QFileDialog.- On Unix/X11, the normal behavior of the file dialog is to resolve and follow symlinks. For example, if - /usr/tmpis a symlink to- /var/tmp, the file dialog will change to- /var/tmpafter entering- /usr/tmp. If- optionsincludes- DontResolveSymlinks, the file dialog will treat symlinks as regular directories.- On Windows, the dialog will spin a blocking modal event loop that will not dispatch any QTimers, and if - parentis not 0 then it will position the dialog just below the parent’s title bar.- Warning - Do not delete - parentduring the execution of the dialog. If you want to do this, you should create the dialog yourself using one of the- QFileDialogconstructors.
- 
static PySide2.QtWidgets.QFileDialog.getExistingDirectoryUrl([parent=None[, caption=""[, dir=QUrl()[, options=QFileDialog.ShowDirsOnly[, supportedSchemes=list()]]]]])¶
- Parameters
- parent – - QWidget
- caption – unicode 
- dir – - QUrl
- options – - Options
- supportedSchemes – list of strings 
 
- Return type
- QUrl
 - This is a convenience static function that will return an existing directory selected by the user. If the user presses Cancel, it returns an empty url. - The function is used similarly to - getExistingDirectory(). In particular- parent,- caption,- dirand- optionsare used in the exact same way.- The main difference with - getExistingDirectory()comes from the ability offered to the user to select a remote directory. That’s why the return type and the type of- diris- QUrl.- The - supportedSchemesargument allows to restrict the type of URLs the user will be able to select. It is a way for the application to declare the protocols it will support to fetch the file content. An empty list means that no restriction is applied (the default). Supported for local files (“file” scheme) is implicit and always enabled; it is not necessary to include it in the restriction.- When possible, this static function will use the native file dialog and not a - QFileDialog. On platforms which don’t support selecting remote files, Qt will allow to select only local files.
- 
static PySide2.QtWidgets.QFileDialog.getOpenFileName([parent=None[, caption=""[, dir=""[, filter=""[, selectedFilter=""[, options=QFileDialog.Options()]]]]]])¶
- Parameters
- parent – - QWidget
- caption – unicode 
- dir – unicode 
- filter – unicode 
- selectedFilter – unicode 
- options – - Options
 
- Return type
- (fileName, selectedFilter) 
 - This is a convenience static function that returns an existing file selected by the user. If the user presses Cancel, it returns a null string. - fileName = QFileDialog.getOpenFileName(self, tr("Open File"), "/home", tr("Images (*.png *.xpm *.jpg)")) - The function creates a modal file dialog with the given - parentwidget. If- parentis not 0, the dialog will be shown centered over the parent widget.- The file dialog’s working directory will be set to - dir. If- dirincludes a file name, the file will be selected. Only files that match the given- filterare shown. The filter selected is set to- selectedFilter. The parameters- dir,- selectedFilter, and- filtermay be empty strings. If you want multiple filters, separate them with ‘;;’, for example:- "Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)"- The - optionsargument holds various options about how to run the dialog, see the- Optionenum for more information on the flags you can pass.- The dialog’s caption is set to - caption. If- captionis not specified then a default caption will be used.- On Windows, and macOS , this static function will use the native file dialog and not a - QFileDialog.- On Windows the dialog will spin a blocking modal event loop that will not dispatch any QTimers, and if - parentis not 0 then it will position the dialog just below the parent’s title bar.- On Unix/X11, the normal behavior of the file dialog is to resolve and follow symlinks. For example, if - /usr/tmpis a symlink to- /var/tmp, the file dialog will change to- /var/tmpafter entering- /usr/tmp. If- optionsincludes- DontResolveSymlinks, the file dialog will treat symlinks as regular directories.- Warning - Do not delete - parentduring the execution of the dialog. If you want to do this, you should create the dialog yourself using one of the- QFileDialogconstructors.
- 
static PySide2.QtWidgets.QFileDialog.getOpenFileNames([parent=None[, caption=""[, dir=""[, filter=""[, selectedFilter=""[, options=QFileDialog.Options()]]]]]])¶
- Parameters
- parent – - QWidget
- caption – unicode 
- dir – unicode 
- filter – unicode 
- selectedFilter – unicode 
- options – - Options
 
- Return type
- (fileNames, selectedFilter) 
 - This is a convenience static function that will return one or more existing files selected by the user. - files = QFileDialog.getOpenFileNames(self, "Select one or more files to open", "/home", "Images (*.png *.xpm *.jpg)") - This function creates a modal file dialog with the given - parentwidget. If- parentis not 0, the dialog will be shown centered over the parent widget.- The file dialog’s working directory will be set to - dir. If- dirincludes a file name, the file will be selected. The filter is set to- filterso that only those files which match the filter are shown. The filter selected is set to- selectedFilter. The parameters- dir,- selectedFilterand- filtermay be empty strings. If you need multiple filters, separate them with ‘;;’, for instance:- "Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)"- The dialog’s caption is set to - caption. If- captionis not specified then a default caption will be used.- On Windows, and macOS , this static function will use the native file dialog and not a - QFileDialog.- On Windows the dialog will spin a blocking modal event loop that will not dispatch any QTimers, and if - parentis not 0 then it will position the dialog just below the parent’s title bar.- On Unix/X11, the normal behavior of the file dialog is to resolve and follow symlinks. For example, if - /usr/tmpis a symlink to- /var/tmp, the file dialog will change to- /var/tmpafter entering- /usr/tmp. The- optionsargument holds various options about how to run the dialog, see the- Optionenum for more information on the flags you can pass.- Warning - Do not delete - parentduring the execution of the dialog. If you want to do this, you should create the dialog yourself using one of the- QFileDialogconstructors.
- 
static PySide2.QtWidgets.QFileDialog.getOpenFileUrl([parent=None[, caption=""[, dir=QUrl()[, filter=""[, selectedFilter=""[, options=QFileDialog.Options()[, supportedSchemes=list()]]]]]]])¶
- Parameters
- parent – - QWidget
- caption – unicode 
- dir – - QUrl
- filter – unicode 
- selectedFilter – unicode 
- options – - Options
- supportedSchemes – list of strings 
 
- Return type
- (fileName, selectedFilter) 
 - This is a convenience static function that returns an existing file selected by the user. If the user presses Cancel, it returns an empty url. - The function is used similarly to - getOpenFileName(). In particular- parent,- caption,- dir,- filter,- selectedFilterand- optionsare used in the exact same way.- The main difference with - getOpenFileName()comes from the ability offered to the user to select a remote file. That’s why the return type and the type of- diris- QUrl.- The - supportedSchemesargument allows to restrict the type of URLs the user will be able to select. It is a way for the application to declare the protocols it will support to fetch the file content. An empty list means that no restriction is applied (the default). Supported for local files (“file” scheme) is implicit and always enabled; it is not necessary to include it in the restriction.- When possible, this static function will use the native file dialog and not a - QFileDialog. On platforms which don’t support selecting remote files, Qt will allow to select only local files.
- 
static PySide2.QtWidgets.QFileDialog.getOpenFileUrls([parent=None[, caption=""[, dir=QUrl()[, filter=""[, selectedFilter=""[, options=QFileDialog.Options()[, supportedSchemes=list()]]]]]]])¶
- Parameters
- parent – - QWidget
- caption – unicode 
- dir – - QUrl
- filter – unicode 
- selectedFilter – unicode 
- options – - Options
- supportedSchemes – list of strings 
 
- Return type
- (fileName, selectedFilter) 
 - This is a convenience static function that will return one or more existing files selected by the user. If the user presses Cancel, it returns an empty list. - The function is used similarly to - getOpenFileNames(). In particular- parent,- caption,- dir,- filter,- selectedFilterand- optionsare used in the exact same way.- The main difference with - getOpenFileNames()comes from the ability offered to the user to select remote files. That’s why the return type and the type of- dirare respectively- QList<- QUrl> and- QUrl.- The - supportedSchemesargument allows to restrict the type of URLs the user will be able to select. It is a way for the application to declare the protocols it will support to fetch the file content. An empty list means that no restriction is applied (the default). Supported for local files (“file” scheme) is implicit and always enabled; it is not necessary to include it in the restriction.- When possible, this static function will use the native file dialog and not a - QFileDialog. On platforms which don’t support selecting remote files, Qt will allow to select only local files.
- 
static PySide2.QtWidgets.QFileDialog.getSaveFileName([parent=None[, caption=""[, dir=""[, filter=""[, selectedFilter=""[, options=QFileDialog.Options()]]]]]])¶
- Parameters
- parent – - QWidget
- caption – unicode 
- dir – unicode 
- filter – unicode 
- selectedFilter – unicode 
- options – - Options
 
- Return type
- (fileName, selectedFilter) 
 - This is a convenience static function that will return a file name selected by the user. The file does not have to exist. - It creates a modal file dialog with the given - parentwidget. If- parentis not 0, the dialog will be shown centered over the parent widget.- fileName = QFileDialog.getSaveFileName(self, tr("Save F:xile"), "/home/jana/untitled.png", tr("Images (*.png *.xpm *.jpg)")) - The file dialog’s working directory will be set to - dir. If- dirincludes a file name, the file will be selected. Only files that match the- filterare shown. The filter selected is set to- selectedFilter. The parameters- dir,- selectedFilter, and- filtermay be empty strings. Multiple filters are separated with ‘;;’. For instance:- "Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)"- The - optionsargument holds various options about how to run the dialog, see the- Optionenum for more information on the flags you can pass.- The default filter can be chosen by setting - selectedFilterto the desired value.- The dialog’s caption is set to - caption. If- captionis not specified, a default caption will be used.- On Windows, and macOS , this static function will use the native file dialog and not a - QFileDialog.- On Windows the dialog will spin a blocking modal event loop that will not dispatch any QTimers, and if - parentis not 0 then it will position the dialog just below the parent’s title bar. On macOS , with its native file dialog, the filter argument is ignored.- On Unix/X11, the normal behavior of the file dialog is to resolve and follow symlinks. For example, if - /usr/tmpis a symlink to- /var/tmp, the file dialog will change to- /var/tmpafter entering- /usr/tmp. If- optionsincludes- DontResolveSymlinksthe file dialog will treat symlinks as regular directories.- Warning - Do not delete - parentduring the execution of the dialog. If you want to do this, you should create the dialog yourself using one of the- QFileDialogconstructors.
- 
static PySide2.QtWidgets.QFileDialog.getSaveFileUrl([parent=None[, caption=""[, dir=QUrl()[, filter=""[, selectedFilter=""[, options=QFileDialog.Options()[, supportedSchemes=list()]]]]]]])¶
- Parameters
- parent – - QWidget
- caption – unicode 
- dir – - QUrl
- filter – unicode 
- selectedFilter – unicode 
- options – - Options
- supportedSchemes – list of strings 
 
- Return type
- (fileName, selectedFilter) 
 - This is a convenience static function that returns a file selected by the user. The file does not have to exist. If the user presses Cancel, it returns an empty url. - The function is used similarly to - getSaveFileName(). In particular- parent,- caption,- dir,- filter,- selectedFilterand- optionsare used in the exact same way.- The main difference with - getSaveFileName()comes from the ability offered to the user to select a remote file. That’s why the return type and the type of- diris- QUrl.- The - supportedSchemesargument allows to restrict the type of URLs the user will be able to select. It is a way for the application to declare the protocols it will support to save the file content. An empty list means that no restriction is applied (the default). Supported for local files (“file” scheme) is implicit and always enabled; it is not necessary to include it in the restriction.- When possible, this static function will use the native file dialog and not a - QFileDialog. On platforms which don’t support selecting remote files, Qt will allow to select only local files.
- 
PySide2.QtWidgets.QFileDialog.history()¶
- Return type
- list of strings 
 - Returns the browsing history of the filedialog as a list of paths. - See also 
- 
PySide2.QtWidgets.QFileDialog.iconProvider()¶
- Return type
 - Returns the icon provider used by the filedialog. - See also 
- 
PySide2.QtWidgets.QFileDialog.isNameFilterDetailsVisible()¶
- Return type
- bool
 
- 
PySide2.QtWidgets.QFileDialog.isReadOnly()¶
- Return type
- bool
 
- 
PySide2.QtWidgets.QFileDialog.itemDelegate()¶
- Return type
 - Returns the item delegate used to render the items in the views in the filedialog. - See also 
- 
PySide2.QtWidgets.QFileDialog.labelText(label)¶
- Parameters
- label – - DialogLabel
- Return type
- unicode 
 - Returns the text shown in the filedialog in the specified - label.- See also 
- 
PySide2.QtWidgets.QFileDialog.mimeTypeFilters()¶
- Return type
- list of strings 
 - Returns the MIME type filters that are in operation on this file dialog. - See also 
- 
PySide2.QtWidgets.QFileDialog.nameFilters()¶
- Return type
- list of strings 
 - Returns the file type filters that are in operation on this file dialog. - See also 
- 
PySide2.QtWidgets.QFileDialog.open(receiver, member)¶
- Parameters
- receiver – - QObject
- member – str 
 
 - This function connects one of its signals to the slot specified by - receiverand- member. The specific signal depends is- filesSelected()if- fileModeis- ExistingFilesand- fileSelected()if- fileModeis anything else.- The signal will be disconnected from the slot when the dialog is closed. 
- 
PySide2.QtWidgets.QFileDialog.options()¶
- Return type
- Options
 - See also 
- 
PySide2.QtWidgets.QFileDialog.proxyModel()¶
- Return type
- QAbstractProxyModel
 - Returns the proxy model used by the file dialog. By default no proxy is set. - See also 
- 
PySide2.QtWidgets.QFileDialog.resolveSymlinks()¶
- Return type
- bool
 - See also 
- 
PySide2.QtWidgets.QFileDialog.restoreState(state)¶
- Parameters
- state – - QByteArray
- Return type
- bool
 - Restores the dialogs’s layout, history and current directory to the - statespecified.- Typically this is used in conjunction with - QSettingsto restore the size from a past session.- Returns - falseif there are errors
- 
PySide2.QtWidgets.QFileDialog.saveState()¶
- Return type
- QByteArray
 - Saves the state of the dialog’s layout, history and current directory. - Typically this is used in conjunction with - QSettingsto remember the size for a future session. A version number is stored as part of the data.
- 
PySide2.QtWidgets.QFileDialog.selectFile(filename)¶
- Parameters
- filename – unicode 
 - Selects the given - filenamein the file dialog.- See also 
- 
PySide2.QtWidgets.QFileDialog.selectMimeTypeFilter(filter)¶
- Parameters
- filter – unicode 
 - Sets the current MIME type - filter.
- 
PySide2.QtWidgets.QFileDialog.selectNameFilter(filter)¶
- Parameters
- filter – unicode 
 - Sets the current file type - filter. Multiple filters can be passed in- filterby separating them with semicolons or spaces.
- 
PySide2.QtWidgets.QFileDialog.selectUrl(url)¶
- Parameters
- url – - QUrl
 - Selects the given - urlin the file dialog.- Note - The non-native - QFileDialogsupports only local files.- See also 
- 
PySide2.QtWidgets.QFileDialog.selectedFiles()¶
- Return type
- list of strings 
 - Returns a list of strings containing the absolute paths of the selected files in the dialog. If no files are selected, or the mode is not - ExistingFilesor- ExistingFile, contains the current path in the viewport.- See also 
- 
PySide2.QtWidgets.QFileDialog.selectedMimeTypeFilter()¶
- Return type
- unicode 
 - Returns The mimetype of the file that the user selected in the file dialog. 
- 
PySide2.QtWidgets.QFileDialog.selectedNameFilter()¶
- Return type
- unicode 
 - Returns the filter that the user selected in the file dialog. - See also 
- 
PySide2.QtWidgets.QFileDialog.selectedUrls()¶
- Return type
 - Returns a list of urls containing the selected files in the dialog. If no files are selected, or the mode is not - ExistingFilesor- ExistingFile, contains the current path in the viewport.- See also 
- 
PySide2.QtWidgets.QFileDialog.setAcceptMode(mode)¶
- Parameters
- mode – - AcceptMode
 - See also 
- 
PySide2.QtWidgets.QFileDialog.setConfirmOverwrite(enabled)¶
- Parameters
- enabled – - bool
 - See also 
- 
PySide2.QtWidgets.QFileDialog.setDefaultSuffix(suffix)¶
- Parameters
- suffix – unicode 
 - See also 
- 
PySide2.QtWidgets.QFileDialog.setDirectory(directory)¶
- Parameters
- directory – unicode 
 
- 
PySide2.QtWidgets.QFileDialog.setDirectory(directory)
- Parameters
- directory – - QDir
 
- 
PySide2.QtWidgets.QFileDialog.setDirectoryUrl(directory)¶
- Parameters
- directory – - QUrl
 - Sets the file dialog’s current - directoryurl.- Note - The non-native - QFileDialogsupports only local files.- Note - On Windows, it is possible to pass URLs representing one of the virtual folders , such as “Computer” or “Network”. This is done by passing a - QUrlusing the scheme- clsidfollowed by the CLSID value with the curly braces removed. For example the URL- clsid:374DE290-123F-4565-9164-39C4925E467Bdenotes the download location. For a complete list of possible values, see the MSDN documentation on KNOWNFOLDERID. This feature was added in Qt 5.5.- See also 
- 
PySide2.QtWidgets.QFileDialog.setFilter(filters)¶
- Parameters
- filters – - Filters
 - Sets the filter used by the model to - filters. The filter is used to specify the kind of files that should be shown.- See also 
- 
PySide2.QtWidgets.QFileDialog.setHistory(paths)¶
- Parameters
- paths – list of strings 
 - Sets the browsing history of the filedialog to contain the given - paths.- See also 
- 
PySide2.QtWidgets.QFileDialog.setIconProvider(provider)¶
- Parameters
- provider – - QFileIconProvider
 - Sets the icon provider used by the filedialog to the specified - provider.- See also 
- 
PySide2.QtWidgets.QFileDialog.setItemDelegate(delegate)¶
- Parameters
- delegate – - QAbstractItemDelegate
 - Sets the item delegate used to render items in the views in the file dialog to the given - delegate.- Warning - You should not share the same instance of a delegate between views. Doing so can cause incorrect or unintuitive editing behavior since each view connected to a given delegate may receive the - closeEditor()signal, and attempt to access, modify or close an editor that has already been closed.- Note that the model used is - QFileSystemModel. It has custom item data roles, which is described by the- Rolesenum. You can use a- QFileIconProviderif you only want custom icons.
- 
PySide2.QtWidgets.QFileDialog.setLabelText(label, text)¶
- Parameters
- label – - DialogLabel
- text – unicode 
 
 - Sets the - textshown in the filedialog in the specified- label.- See also 
- 
PySide2.QtWidgets.QFileDialog.setMimeTypeFilters(filters)¶
- Parameters
- filters – list of strings 
 - Sets the - filtersused in the file dialog, from a list of MIME types.- Convenience method for - setNameFilters(). Uses- QMimeTypeto create a name filter from the glob patterns and description defined in each MIME type.- Use application/octet-stream for the “All files (*)” filter, since that is the base MIME type for all files. - Calling overrides any previously set name filters, and changes the return value of - nameFilters().- QStringList mimeTypeFilters; mimeTypeFilters << "image/jpeg" // will show "JPEG image (*.jpeg *.jpg *.jpe) << "image/png" // will show "PNG image (*.png)" << "application/octet-stream"; // will show "All files (*)" QFileDialog dialog(this); dialog.setMimeTypeFilters(mimeTypeFilters); dialog.exec(); - See also 
- 
PySide2.QtWidgets.QFileDialog.setNameFilter(filter)¶
- Parameters
- filter – unicode 
 - Sets the filter used in the file dialog to the given - filter.- If - filtercontains a pair of parentheses containing one or more filename-wildcard patterns, separated by spaces, then only the text contained in the parentheses is used as the filter. This means that these calls are all equivalent:- dialog.setNameFilter("All C++ files (*.cpp *.cc *.C *.cxx *.c++)") dialog.setNameFilter("*.cpp *.cc *.C *.cxx *.c++") - See also 
- 
PySide2.QtWidgets.QFileDialog.setNameFilterDetailsVisible(enabled)¶
- Parameters
- enabled – - bool
 - See also 
- 
PySide2.QtWidgets.QFileDialog.setNameFilters(filters)¶
- Parameters
- filters – list of strings 
 - Sets the - filtersused in the file dialog.- Note that the filter *.* is not portable, because the historical assumption that the file extension determines the file type is not consistent on every operating system. It is possible to have a file with no dot in its name (for example, - Makefile). In a native Windows file dialog, *.* will match such files, while in other types of file dialogs it may not. So it is better to use * if you mean to select any file.- filters = QStringList() filters << "Image files (*.png *.xpm *.jpg)" << "Text files (*.txt)" << "Any files (*)" dialog = QFileDialog(this) dialog.setNameFilters(filters) dialog.exec_() - setMimeTypeFilters()has the advantage of providing all possible name filters for each file type. For example, JPEG images have three possible extensions; if your application can open such files, selecting the- image/jpegmime type as a filter will allow you to open all of them.- See also 
- 
PySide2.QtWidgets.QFileDialog.setOption(option[, on=true])¶
- Parameters
- option – - Option
- on – - bool
 
 - Sets the given - optionto be enabled if- onis true; otherwise, clears the given- option.- Options (particularly the DontUseNativeDialogs option) should be set before changing dialog properties or showing the dialog. - Setting options while the dialog is visible is not guaranteed to have an immediate effect on the dialog (depending on the option and on the platform). - Setting options after changing other properties may cause these values to have no effect. - See also 
- 
PySide2.QtWidgets.QFileDialog.setProxyModel(model)¶
- Parameters
- model – - QAbstractProxyModel
 - Sets the model for the views to the given - proxyModel. This is useful if you want to modify the underlying model; for example, to add columns, filter data or add drives.- Any existing proxy model will be removed, but not deleted. The file dialog will take ownership of the - proxyModel.- See also 
- 
PySide2.QtWidgets.QFileDialog.setReadOnly(enabled)¶
- Parameters
- enabled – - bool
 - See also 
- 
PySide2.QtWidgets.QFileDialog.setResolveSymlinks(enabled)¶
- Parameters
- enabled – - bool
 - See also 
- 
PySide2.QtWidgets.QFileDialog.setSidebarUrls(urls)¶
- Parameters
- urls – 
 - Sets the - urlsthat are located in the sidebar.- For instance: - QList<QUrl> urls; urls << QUrl::fromLocalFile("/home/gvatteka/dev/qt-45") << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::MusicLocation)); QFileDialog dialog; dialog.setSidebarUrls(urls); dialog.setFileMode(QFileDialog::AnyFile); if(dialog.exec()) { // ... } - The file dialog will then look like this:   - See also 
- 
PySide2.QtWidgets.QFileDialog.setSupportedSchemes(schemes)¶
- Parameters
- schemes – list of strings 
 - See also 
- Return type
 - Returns a list of urls that are currently in the sidebar - See also 
- 
PySide2.QtWidgets.QFileDialog.supportedSchemes()¶
- Return type
- list of strings 
 - See also 
- 
PySide2.QtWidgets.QFileDialog.testOption(option)¶
- Parameters
- option – - Option
- Return type
- bool
 - Returns - trueif the given- optionis enabled; otherwise, returns false.- See also 
- 
PySide2.QtWidgets.QFileDialog.urlSelected(url)¶
- Parameters
- url – - QUrl
 
- 
PySide2.QtWidgets.QFileDialog.urlsSelected(urls)¶
- Parameters
- urls – 
 
- 
PySide2.QtWidgets.QFileDialog.viewMode()¶
- Return type
 - See also 
© 2018 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.