QFileDialog

Provides a dialog that allows users to select files or directories. More...

Methods

Detailed Description

Use the QFileDialog::getExistingDirectory() method to create a modal dialog that displays an existing directory selected by the user. Use the QFileDialog::getOpenFileName() method to create a dialog that displays matching files in the directory selected by the user. When a command line interface is used, a dialog is not displayed. Instead, the user can type the directory or the file name in the console. For automatic installations, --file-query with identifier=value pairs can be given separated with a comma. For example, --file-query filedialog.id=C:/Temp,filedialog.id2=C:/Temp2.

Method Documentation

string getExistingDirectory(string caption, string dir, string identifier)

Returns an existing directory selected by the user.

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 identifier is used in command line interface to allow to identify specific file dialogs for automatic answer.


string getOpenFileName(string caption, string dir, string filter, string identifier)

Returns an existing file selected by the user. If the user selects Cancel, returns a null string.

The file dialog's caption is set to caption. If caption is not specified, a default caption is used.

The file dialog's working directory is set to dir. If dir includes a file name, the file will be selected. Only files that match the specified filter are shown. Either of these may be an empty string.

The identifier is used in command line interface to allow to identify specific file dialogs for automatic answer.

To specify multiple filters, separate them with two semicolons (;;). For example:

"Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)"

On Windows, and macOS, this static function will use the native file dialog and not a QFileDialog.


© 2021 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. The Qt Company, Qt and their 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.