QFileDialog(3qt)

NAME
QFileDialog - Dialogs that allow users to select files or directories

SYNOPSIS
#include <ntqfiledialog.h>

Inherits QDialog.

  Public Members
QFileDialog ( const TQString & dirName, const TQString & filter = TQString::null, TQWidget * parent = 0, const char * name = 0, bool modal = FALSE )
QFileDialog ( TQWidget * parent = 0, const char * name = 0, bool modal = FALSE )
~QFileDialog ()
TQString selectedFile () const
TQString selectedFilter () const
virtual void setSelectedFilter ( const TQString & mask )
virtual void setSelectedFilter ( int n )
void setSelection ( const TQString & filename )
void selectAll ( bool b )
QStringList selectedFiles () const
TQString dirPath () const
void setDir ( const QDir & dir )
const QDir * dir () const
void setShowHiddenFiles ( bool s )
bool showHiddenFiles () const
void rereadDir ()
void resortDir ()
enum Mode { AnyFile, ExistingFile, Directory, ExistingFiles, DirectoryOnly }
void setMode ( Mode )
Mode mode () const
enum ViewMode { Detail, List }
enum PreviewMode { NoPreview, Contents, Info }
void setViewMode ( ViewMode m )
ViewMode viewMode () const
void setPreviewMode ( PreviewMode m )
PreviewMode previewMode () const
bool isInfoPreviewEnabled () const
bool isContentsPreviewEnabled () const
void setInfoPreviewEnabled ( bool )
void setContentsPreviewEnabled ( bool )
void setInfoPreview ( TQWidget * w, QFilePreview * preview )
void setContentsPreview ( TQWidget * w, QFilePreview * preview )
QUrl url () const
void addFilter ( const TQString & filter )

  Public Slots
void setDir ( const TQString & pathstr )
void setUrl ( const QUrlOperator & url )
void setFilter ( const TQString & newFilter )
void setFilters ( const TQString & filters )
void setFilters ( const char ** types )
void setFilters ( const QStringList & )

  Signals
void fileHighlighted ( const TQString & )
void fileSelected ( const TQString & )
void filesSelected ( const QStringList & )
void dirEntered ( const TQString & )
void filterSelected ( const TQString & )

  Static Public Members
TQString getOpenFileName ( const TQString & startWith = TQString::null, const TQString & filter = TQString::null, TQWidget * parent = 0, const char * name = 0, const TQString & caption = TQString::null, TQString * selectedFilter = 0, bool resolveSymlinks = TRUE )
TQString getSaveFileName ( const TQString & startWith = TQString::null, const TQString & filter = TQString::null, TQWidget * parent = 0, const char * name = 0, const TQString & caption = TQString::null, TQString * selectedFilter = 0, bool resolveSymlinks = TRUE )
TQString getExistingDirectory ( const TQString & dir = TQString::null, TQWidget * parent = 0, const char * name = 0, const TQString & caption = TQString::null, bool dirOnly = TRUE, bool resolveSymlinks = TRUE )
QStringList getOpenFileNames ( const TQString & filter = TQString::null, const TQString & dir = TQString::null, TQWidget * parent = 0, const char * name = 0, const TQString & caption = TQString::null, TQString * selectedFilter = 0, bool resolveSymlinks = TRUE )
void setIconProvider ( QFileIconProvider * provider )
QFileIconProvider * iconProvider ()

  Properties
bool contentsPreview - whether the file dialog can provide a contents preview of the currently selected file
TQString dirPath - the file dialog's working directory (read only)
bool infoPreview - whether the file dialog can provide preview information about the currently selected file
Mode mode - the file dialog's mode
PreviewMode previewMode - the preview mode for the file dialog
TQString selectedFile - the name of the selected file (read only)
QStringList selectedFiles - the list of selected files (read only)
TQString selectedFilter - the filter which the user has selected in the file dialog (read only)
bool showHiddenFiles - whether hidden files are shown in the file dialog
ViewMode viewMode - the file dialog's view mode

  Protected Members
void addWidgets ( QLabel * l, TQWidget * w, QPushButton * b )
void addToolButton ( QButton * b, bool separator = FALSE )
void addLeftWidget ( TQWidget * w )
void addRightWidget ( TQWidget * w )

DESCRIPTION
The QFileDialog class provides dialogs that allow users to select files or directories.

The QFileDialog class enables a user to traverse their file system in order to select one or many files or a directory.

The easiest way to create a QFileDialog is to use the static functions. On Windows, these static functions will call the native Windows file dialog and on Mac OS X, these static function will call the native Mac OS X file dialog.

    TQString s = QFileDialog::getOpenFileName(
                    "/home",
                    "Images (*.png *.xpm *.jpg)",
                    this,
                    "open file dialog",
                    "Choose a file" );

In the above example, a modal QFileDialog is created using a static function. The startup directory is set to "/home". The file filter is set to "Images (*.png *.xpm *.jpg)". The parent of the file dialog is set to this and it is given the identification name - "open file dialog". The caption at the top of file dialog is set to "Choose a file". If you want to use multiple filters, separate each one with two semi-colons, e.g.

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

You can create your own QFileDialog without using the static functions. By calling setMode(), you can set what can be returned by the QFileDialog.

    QFileDialog* fd = new QFileDialog( this, "file dialog", TRUE );
    fd->setMode( 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 "File Save As" file dialog. Use ExistingFile if the user must select an existing file or Directory if only a directory may be selected. (See the QFileDialog::Mode enum for the complete list of modes.)

You can retrieve the dialog's mode with mode(). Use setFilter() to set the dialog's file filter, e.g.

    fd->setFilter( "Images (*.png *.xpm *.jpg)" );

In the above example, the filter is set to "Images (*.png *.xpm *.jpg)", this means that only files with the extension png, xpm or jpg will be shown in the QFileDialog. You can apply several filters by using setFilters() and add additional filters with addFilter(). Use setSelectedFilter() to select one of the filters you've given as the file dialog's default filter. Whenever the user changes the filter the filterSelected() signal is emitted.

The file dialog has two view modes, QFileDialog::List which simply lists file and directory names and QFileDialog::Detail which displays additional information alongside each name, e.g. file size, modification date, etc. Set the mode with setViewMode().

    fd->setViewMode( QFileDialog::Detail );

The last important function you will need to use when creating your own file dialog is selectedFile().

    TQString fileName;
    if ( fd->exec() == QDialog::Accepted )
        fileName = fd->selectedFile();

In the above example, a modal file dialog is created and shown. If the user clicked OK, then the file they selected is put in fileName.

If you are using the ExistingFiles mode then you will need to use selectedFiles() which will return the selected files in a QStringList.

The dialog's working directory can be set with setDir(). The display of hidden files is controlled with setShowHiddenFiles(). The dialog can be forced to re-read the directory with rereadDir() and re-sort the directory with resortDir(). All the files in the current directory can be selected with selectAll().

Creating and using preview widgets
There are two kinds of preview widgets that can be used with QFileDialogs: content preview widgets and information preview widgets. They are created and used in the same way except that the function names differ, e.g. setContentsPreview() and setInfoPreview().

A preview widget is a widget that is placed inside a QFileDialog so that the user can see either the contents of the file, or information about the file.

    class Preview : public QLabel, public QFilePreview
    {
    public:
        Preview( TQWidget *parent=0 ) : QLabel( parent ) {}
        void previewUrl( const QUrl &u )
        {
            TQString path = u.path();
            QPixmap pix( path );
            if ( pix.isNull() )
                setText( "This is not a pixmap" );
            else
                setPixmap( pix );
        }
    };

In the above snippet, we create a preview widget which inherits from QLabel and QFilePreview. File preview widgets must inherit from QFilePreview.

Inside the class we reimplement QFilePreview::previewUrl(), this is where we determine what happens when a file is selected. In the above example we only show a preview of the file if it is a valid pixmap. Here's how to make a file dialog use a preview widget:

    Preview* p = new Preview;
    QFileDialog* fd = new QFileDialog( this );
    fd->setContentsPreviewEnabled( TRUE );
    fd->setContentsPreview( p, p );
    fd->setPreviewMode( QFileDialog::Contents );
    fd->show();

The first line creates an instance of our preview widget. We then create our file dialog and call setContentsPreviewEnabled( TRUE ), this tell the file dialog to preview the contents of the currently selected file. We then call setContentsPreview() -- note that we pass the same preview widget twice. Finally, before showing the file dialog, we call setPreviewMode() setting the mode to Contents which will show the contents preview of the file that the user has selected.

If you create another preview widget that is used for displaying information about a file, create it in the same way as the contents preview widget and call setInfoPreviewEnabled(), and setInfoPreview(). Then the user will be able to switch between the two preview modes.

For more information about creating a QFilePreview widget see QFilePreview.

[Image Omitted]

[Image Omitted]

See also Dialog Classes.

  Member Type Documentation

QFileDialog::Mode
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.

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.

QFileDialog::DirectoryOnly - The name of a directory. The file dialog will only display directories.

QFileDialog::ExistingFiles - The names of zero or more existing files.

See setMode().

QFileDialog::PreviewMode
This enum describes the preview mode of the file dialog.

QFileDialog::NoPreview - No preview is shown at all.

QFileDialog::Contents - Show a preview of the contents of the current file using the contents preview widget.

QFileDialog::Info - Show information about the current file using the info preview widget.

See setPreviewMode(), setContentsPreview() and setInfoPreview().

QFileDialog::ViewMode
This enum describes the view mode of the file dialog, i.e. what information about each file will be displayed.

QFileDialog::List - Display file and directory names with icons.

QFileDialog::Detail - Display file and directory names with icons plus additional information, such as file size and modification date.

See setViewMode().

MEMBER FUNCTION DOCUMENTATION

QFileDialog::QFileDialog ( const TQString & dirName, const TQString & filter = TQString::null, TQWidget * parent = 0, const char * name = 0, bool modal = FALSE )
Constructs a file dialog called name with the parent, parent. If modal is TRUE then the file dialog is modal; otherwise it is modeless.

If dirName is specified then it will be used as the dialog's working directory, i.e. it will be the directory that is shown when the dialog appears. If filter is specified it will be used as the dialog's file filter.

QFileDialog::QFileDialog ( TQWidget * parent = 0, const char * name = 0, bool modal = FALSE )
Constructs a file dialog called name, with the parent, parent. If modal is TRUE then the file dialog is modal; otherwise it is modeless.

QFileDialog::~QFileDialog ()
Destroys the file dialog.

void QFileDialog::addFilter ( const TQString & filter )
Adds the filter filter to the list of filters and makes it the current filter.

    QFileDialog* fd = new QFileDialog( this );
    fd->addFilter( "Images (*.png *.jpg *.xpm)" );
    fd->show();

In the above example, a file dialog is created, and the file filter "Images (*.png *.jpg *.xpm)" is added and is set as the current filter. The original filter, "All Files (*)", is still available.

See also setFilter() and setFilters().

void QFileDialog::addLeftWidget ( TQWidget * w ) [protected]
Adds the widget w to the left-hand side of the file dialog.

See also addRightWidget(), addWidgets(), and addToolButton().

void QFileDialog::addRightWidget ( TQWidget * w ) [protected]
Adds the widget w to the right-hand side of the file dialog.

See also addLeftWidget(), addWidgets(), and addToolButton().

void QFileDialog::addToolButton ( QButton * b, bool separator = FALSE ) [protected]
Adds the tool button b to the row of tool buttons at the top of the file dialog. The button is appended to the right of this row. If separator is TRUE, a small space is inserted between the last button of the row and the new button b.

See also addWidgets(), addLeftWidget(), and addRightWidget().

void QFileDialog::addWidgets ( QLabel * l, TQWidget * w, QPushButton * b ) [protected]
Adds the specified widgets to the bottom of the file dialog. The label l is placed underneath the "file name" and the "file types" labels. The widget w is placed underneath the file types combobox. The button b is placed underneath the Cancel pushbutton.

    MyFileDialog::MyFileDialog( TQWidget* parent, const char* name ) :
        QFileDialog( parent, name )
    {
        QLabel* label = new QLabel( "Added widgets", this );
        QLineEdit* lineedit = new QLineEdit( this );
        QPushButton* pushbutton = new QPushButton( this );
        addWidgets( label, lineedit, pushbutton );
    }

If you don't want to have one of the widgets added, pass 0 in that widget's position.

Every time you call this function, a new row of widgets will be added to the bottom of the file dialog.

See also addToolButton(), addLeftWidget(), and addRightWidget().

const QDir * QFileDialog::dir () const
Returns the current directory shown in the file dialog.

The ownership of the QDir pointer is transferred to the caller, so it must be deleted by the caller when no longer required.

See also setDir().

void QFileDialog::dirEntered ( const TQString & ) [signal]
This signal is emitted when the user enters a directory.

See also dir().

TQString QFileDialog::dirPath () const
Returns the file dialog's working directory. See the "dirPath" property for details.

void QFileDialog::fileHighlighted ( const TQString & ) [signal]
This signal is emitted when the user highlights a file, i.e. makes it the current file.

See also fileSelected() and filesSelected().

void QFileDialog::fileSelected ( const TQString & ) [signal]
This signal is emitted when the user selects a file.

See also filesSelected(), fileHighlighted(), and selectedFile.

void QFileDialog::filesSelected ( const QStringList & ) [signal]
This signal is emitted when the user selects one or more files in ExistingFiles mode.

See also fileSelected(), fileHighlighted(), and selectedFiles.

void QFileDialog::filterSelected ( const TQString & ) [signal]
This signal is emitted when the user selects a filter.

See also selectedFilter.

TQString QFileDialog::getExistingDirectory ( const TQString & dir = TQString::null, TQWidget * parent = 0, const char * name = 0, const TQString & caption = TQString::null, bool dirOnly = TRUE, bool resolveSymlinks = TRUE ) [static]
This is a convenience static function that will return an existing directory selected by the user.

    TQString s = QFileDialog::getExistingDirectory(
                    "/home",
                    this,
                    "get existing directory",
                    "Choose a directory",
                    TRUE );

This function creates a modal file dialog called name, with parent, parent. If parent is not 0, the dialog will be shown centered over the parent.

The dialog's working directory is set to dir, and the caption is set to caption. Either of these may be TQString::null in which case the current directory and a default caption will be used respectively.

Note on Windows that if dir is TQString::null then the dialog's working directory will be set to the user's My Documents directory.

If dirOnly is TRUE, then only directories will be shown in the file dialog; otherwise both directories and files will be shown.

Under Unix/X11, the normal behavior of the file dialog is to resolve and follow symlinks. For example, if /usr/tmp is a symlink to /var/tmp, the file dialog will change to /var/tmp after entering /usr/tmp. If resolveSymlinks is FALSE, the file dialog will treat symlinks as regular directories.

Under Windows and Mac OS X, this static function will use the native file dialog and not a QFileDialog, unless the style of the application is set to something other than the native style. (Note that on Windows the dialog will spin a blocking modal event loop that will not dispatch any QTimers and if parent is not 0 then it will position the dialog just under the parent's titlebar).

See also getOpenFileName(), getOpenFileNames(), and getSaveFileName().

TQString QFileDialog::getOpenFileName ( const TQString & startWith = TQString::null, const TQString & filter = TQString::null, TQWidget * parent = 0, const char * name = 0, const TQString & caption = TQString::null, TQString * selectedFilter = 0, bool resolveSymlinks = TRUE ) [static]
This is a convenience static function that returns an existing file selected by the user. If the user pressed Cancel, it returns a null string.

    TQString s = QFileDialog::getOpenFileName(
                    "/home",
                    "Images (*.png *.xpm *.jpg)",
                    this,
                    "open file dialog",
                    "Choose a file to open" );

The function creates a modal file dialog called name, with parent, parent. If a parent is not 0, the dialog will be shown centered over the parent.

The file dialog's working directory will be set to startWith. If startWith includes a file name, the file will be selected. The filter is set to filter so that only those files which match the filter are shown. The filter selected is set to selectedFilter. The parameters startWith, selectedFilter and filter may be TQString::null.

The dialog's caption is set to caption. If caption is not specified then a default caption will be used.

Under Windows and Mac OS X, this static function will use the native file dialog and not a QFileDialog, unless the style of the application is set to something other than the native style (Note that on Windows the dialog will spin a blocking modal event loop that will not dispatch any QTimers and if parent is not 0 then it will position the dialog just under the parent's titlebar).

Under Unix/X11, the normal behavior of the file dialog is to resolve and follow symlinks. For example, if /usr/tmp is a symlink to /var/tmp, the file dialog will change to /var/tmp after entering /usr/tmp. If resolveSymlinks is FALSE, the file dialog will treat symlinks as regular directories.

See also getOpenFileNames(), getSaveFileName(), and getExistingDirectory().

Examples:

QStringList QFileDialog::getOpenFileNames ( const TQString & filter = TQString::null, const TQString & dir = TQString::null, TQWidget * parent = 0, const char * name = 0, const TQString & caption = TQString::null, TQString * selectedFilter = 0, bool resolveSymlinks = TRUE ) [static]
This is a convenience static function that will return one or more existing files selected by the user.

    QStringList files = QFileDialog::getOpenFileNames(
                            "Images (*.png *.xpm *.jpg)",
                            "/home",
                            this,
                            "open files dialog",
                            "Select one or more files to open" );

This function creates a modal file dialog called name, with parent parent. If parent is not 0, the dialog will be shown centered over the parent.

The file dialog's working directory will be set to dir. If dir includes a file name, the file will be selected. The filter is set to filter so that only those files which match the filter are shown. The filter selected is set to selectedFilter. The parameters dir, selectedFilter and filter may be TQString::null.

The dialog's caption is set to caption. If caption is not specified then a default caption will be used.

Under Windows and Mac OS X, this static function will use the native file dialog and not a QFileDialog, unless the style of the application is set to something other than the native style. (Note that on Windows the dialog will spin a blocking modal event loop that will not dispatch any QTimers and if parent is not 0 then it will position the dialog just under the parent's titlebar).

Under Unix/X11, the normal behavior of the file dialog is to resolve and follow symlinks. For example, if /usr/tmp is a symlink to /var/tmp, the file dialog will change to /var/tmp after entering /usr/tmp. If resolveSymlinks is FALSE, the file dialog will treat symlinks as regular directories.

Note that if you want to iterate over the list of files, you should iterate over a copy, e.g.

    QStringList list = files;
    QStringList::Iterator it = list.begin();
    while( it != list.end() ) {
        myProcessing( *it );
        ++it;
    }

See also getOpenFileName(), getSaveFileName(), and getExistingDirectory().

TQString QFileDialog::getSaveFileName ( const TQString & startWith = TQString::null, const TQString & filter = TQString::null, TQWidget * parent = 0, const char * name = 0, const TQString & caption = TQString::null, TQString * selectedFilter = 0, bool resolveSymlinks = TRUE ) [static]
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 called name, with parent, parent. If a parent is not 0, the dialog will be shown centered over the parent.

    TQString s = QFileDialog::getSaveFileName(
                    "/home",
                    "Images (*.png *.xpm *.jpg)",
                    this,
                    "save file dialog",
                    "Choose a filename to save under" );

The file dialog's working directory will be set to startWith. If startWith includes a file name, the file will be selected. The filter is set to filter so that only those files which match the filter are shown. The filter selected is set to selectedFilter. The parameters startWith, selectedFilter and filter may be TQString::null.

The dialog's caption is set to caption. If caption is not specified then a default caption will be used.

Under Windows and Mac OS X, this static function will use the native file dialog and not a QFileDialog, unless the style of the application is set to something other than the native style. (Note that on Windows the dialog will spin a blocking modal event loop that will not dispatch any QTimers and if parent is not 0 then it will position the dialog just under the parent's titlebar.

Under Unix/X11, the normal behavior of the file dialog is to resolve and follow symlinks. For example, if /usr/tmp is a symlink to /var/tmp, the file dialog will change to /var/tmp after entering /usr/tmp. If resolveSymlinks is FALSE, the file dialog will treat symlinks as regular directories.

See also getOpenFileName(), getOpenFileNames(), and getExistingDirectory().

Examples:

QFileIconProvider * QFileDialog::iconProvider () [static]
Returns a pointer to the icon provider currently set on the file dialog. By default there is no icon provider, and this function returns 0.

See also setIconProvider() and QFileIconProvider.

bool QFileDialog::isContentsPreviewEnabled () const
Returns TRUE if the file dialog can provide a contents preview of the currently selected file; otherwise returns FALSE. See the "contentsPreview" property for details.

bool QFileDialog::isInfoPreviewEnabled () const
Returns TRUE if the file dialog can provide preview information about the currently selected file; otherwise returns FALSE. See the "infoPreview" property for details.

Mode QFileDialog::mode () const
Returns the file dialog's mode. See the "mode" property for details.

PreviewMode QFileDialog::previewMode () const
Returns the preview mode for the file dialog. See the "previewMode" property for details.

void QFileDialog::rereadDir ()
Rereads the current directory shown in the file dialog.

The only time you will need to call this function is if the contents of the directory change and you wish to refresh the file dialog to reflect the change.

See also resortDir().

void QFileDialog::resortDir ()
Re-sorts the displayed directory.

See also rereadDir().

void QFileDialog::selectAll ( bool b )
If b is TRUE then all the files in the current directory are selected; otherwise, they are deselected.

TQString QFileDialog::selectedFile () const
Returns the name of the selected file. See the "selectedFile" property for details.

QStringList QFileDialog::selectedFiles () const
Returns the list of selected files. See the "selectedFiles" property for details.

TQString QFileDialog::selectedFilter () const
Returns the filter which the user has selected in the file dialog. See the "selectedFilter" property for details.

void QFileDialog::setContentsPreview ( TQWidget * w, QFilePreview * preview )
Sets the widget to be used for displaying the contents of the file to the widget w and a preview of those contents to the QFilePreview preview.

Normally you would create a preview widget that derives from both TQWidget and QFilePreview, so you should pass the same widget twice. If you don't, you must remember to delete the preview object in order to avoid memory leaks.

    class Preview : public QLabel, public QFilePreview
    {
    public:
        Preview( TQWidget *parent=0 ) : QLabel( parent ) {}
        void previewUrl( const QUrl &u )
        {
            TQString path = u.path();
            QPixmap pix( path );
            if ( pix.isNull() )
                setText( "This is not a pixmap" );
            else
                setPixmap( pix );
        }
    };
  //...
  int main( int argc, char** argv )
  {
    Preview* p = new Preview;
    QFileDialog* fd = new QFileDialog( this );
    fd->setContentsPreviewEnabled( TRUE );
    fd->setContentsPreview( p, p );
    fd->setPreviewMode( QFileDialog::Contents );
    fd->show();
  }

See also contentsPreview, setInfoPreview(), and previewMode.

Example: qdir/qdir.cpp.

void QFileDialog::setContentsPreviewEnabled ( bool )
Sets whether the file dialog can provide a contents preview of the currently selected file. See the "contentsPreview" property for details.

void QFileDialog::setDir ( const QDir & dir )
Sets the file dialog's working directory to dir.

See also dir().

void QFileDialog::setDir ( const TQString & pathstr ) [slot]
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Sets the file dialog's working directory to pathstr.

See also dir().

void QFileDialog::setFilter ( const TQString & newFilter ) [slot]
Sets the filter used in the file dialog to newFilter.

If newFilter contains a pair of parentheses containing one or more of anything*something separated by spaces or by semi-colons then only the text contained in the parentheses is used as the filter. This means that these calls are all equivalent:

     fd->setFilter( "All C++ files (*.cpp *.cc *.C *.cxx *.c++)" );
     fd->setFilter( "*.cpp *.cc *.C *.cxx *.c++" );
     fd->setFilter( "All C++ files (*.cpp;*.cc;*.C;*.cxx;*.c++)" );
     fd->setFilter( "*.cpp;*.cc;*.C;*.cxx;*.c++" );

See also setFilters().

void QFileDialog::setFilters ( const TQString & filters ) [slot]
Sets the filters used in the file dialog to filters. Each group of filters must be separated by ;; (two semi-colons).

    TQString types("Image files (*.png *.xpm *.jpg);;"
                  "Text files (*.txt);;"
                  "Any files (*)");
    QFileDialog fd = new QFileDialog( this );
    fd->setFilters( types );
    fd->show();

void QFileDialog::setFilters ( const char ** types ) [slot]
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

types must be a null-terminated list of strings.

void QFileDialog::setFilters ( const QStringList & ) [slot]
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

void QFileDialog::setIconProvider ( QFileIconProvider * provider ) [static]
Sets the QFileIconProvider used by the file dialog to provider.

The default is that there is no QFileIconProvider and QFileDialog just draws a folder icon next to each directory and nothing next to files.

See also QFileIconProvider and iconProvider().

Example: showimg/main.cpp.

void QFileDialog::setInfoPreview ( TQWidget * w, QFilePreview * preview )
Sets the widget to be used for displaying information about the file to the widget w and a preview of that information to the QFilePreview preview.

Normally you would create a preview widget that derives from both TQWidget and QFilePreview, so you should pass the same widget twice. If you don't, you must remember to delete the preview object in order to avoid memory leaks.

    class Preview : public QLabel, public QFilePreview
    {
    public:
        Preview( TQWidget *parent=0 ) : QLabel( parent ) {}
        void previewUrl( const QUrl &u )
        {
            TQString path = u.path();
            QPixmap pix( path );
            if ( pix.isNull() )
                setText( "This is not a pixmap" );
            else
                setText( "This is a pixmap" );
        }
    };
  //...
  int main( int argc, char** argv )
  {
    Preview* p = new Preview;
    QFileDialog* fd = new QFileDialog( this );
    fd->setInfoPreviewEnabled( TRUE );
    fd->setInfoPreview( p, p );
    fd->setPreviewMode( QFileDialog::Info );
    fd->show();
  }

See also setContentsPreview(), infoPreview, and previewMode.

void QFileDialog::setInfoPreviewEnabled ( bool )
Sets whether the file dialog can provide preview information about the currently selected file. See the "infoPreview" property for details.

void QFileDialog::setMode ( Mode )
Sets the file dialog's mode. See the "mode" property for details.

void QFileDialog::setPreviewMode ( PreviewMode m )
Sets the preview mode for the file dialog to m. See the "previewMode" property for details.

void QFileDialog::setSelectedFilter ( const TQString & mask ) [virtual]
Sets the current filter selected in the file dialog to the first one that contains the text mask.

void QFileDialog::setSelectedFilter ( int n ) [virtual]
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

Sets the current filter selected in the file dialog to the n-th filter in the filter list.

See also filterSelected(), selectedFilter, selectedFiles, and selectedFile.

void QFileDialog::setSelection ( const TQString & filename )
Sets the default selection to filename. If filename is absolute, setDir() is also called to set the file dialog's working directory to the filename's directory.

Example: qdir/qdir.cpp.

void QFileDialog::setShowHiddenFiles ( bool s )
Sets whether hidden files are shown in the file dialog to s. See the "showHiddenFiles" property for details.

void QFileDialog::setUrl ( const QUrlOperator & url ) [slot]
Sets the file dialog's working directory to the directory specified at url.

See also url().

void QFileDialog::setViewMode ( ViewMode m )
Sets the file dialog's view mode to m. See the "viewMode" property for details.

bool QFileDialog::showHiddenFiles () const
Returns TRUE if hidden files are shown in the file dialog; otherwise returns FALSE. See the "showHiddenFiles" property for details.

QUrl QFileDialog::url () const
Returns the URL of the current working directory in the file dialog.

See also setUrl().

Example: network/networkprotocol/view.cpp.

ViewMode QFileDialog::viewMode () const
Returns the file dialog's view mode. See the "viewMode" property for details.

  Property Documentation

bool contentsPreview
This property holds whether the file dialog can provide a contents preview of the currently selected file.

The default is FALSE.

See also setContentsPreview() and infoPreview.

Set this property's value with setContentsPreviewEnabled() and get this property's value with isContentsPreviewEnabled().

TQString dirPath
This property holds the file dialog's working directory.

Get this property's value with dirPath().

See also dir() and setDir().

bool infoPreview
This property holds whether the file dialog can provide preview information about the currently selected file.

The default is FALSE.

Set this property's value with setInfoPreviewEnabled() and get this property's value with isInfoPreviewEnabled().

Mode mode
This property holds the file dialog's mode.

The default mode is ExistingFile.

Set this property's value with setMode() and get this property's value with mode().

PreviewMode previewMode
This property holds the preview mode for the file dialog.

If you set the mode to be a mode other than NoPreview, you must use setInfoPreview() or setContentsPreview() to set the dialog's preview widget to your preview widget and enable the preview widget(s) with setInfoPreviewEnabled() or setContentsPreviewEnabled().

See also infoPreview, contentsPreview, and viewMode.

Set this property's value with setPreviewMode() and get this property's value with previewMode().

TQString selectedFile
This property holds the name of the selected file.

If a file was selected selectedFile contains the file's name including its absolute path; otherwise selectedFile is empty.

See also TQString::isEmpty(), selectedFiles, and selectedFilter.

Get this property's value with selectedFile().

QStringList selectedFiles
This property holds the list of selected files.

If one or more files are selected, selectedFiles contains their names including their absolute paths. If no files are selected or the mode isn't ExistingFiles selectedFiles is an empty list.

It is more convenient to use selectedFile() if the mode is ExistingFile, Directory or DirectoryOnly.

Note that if you want to iterate over the list, you should iterate over a copy, e.g.

    QStringList list = myFileDialog.selectedFiles();
    QStringList::Iterator it = list.begin();
    while( it != list.end() ) {
        myProcessing( *it );
        ++it;
    }

See also selectedFile, selectedFilter, and QValueList::empty().

Get this property's value with selectedFiles().

TQString selectedFilter
This property holds the filter which the user has selected in the file dialog.

Get this property's value with selectedFilter().

See also filterSelected(), selectedFiles, and selectedFile.

bool showHiddenFiles
This property holds whether hidden files are shown in the file dialog.

The default is FALSE, i.e. don't show hidden files.

Set this property's value with setShowHiddenFiles() and get this property's value with showHiddenFiles().

ViewMode viewMode
This property holds the file dialog's view mode.

If you set the view mode to be Detail (the default), then you will see the file's details, such as the size of the file and the date the file was last modified in addition to the file's name.

If you set the view mode to be List, then you will just see a list of the files and folders.

See QFileDialog::ViewMode

Set this property's value with setViewMode() and get this property's value with viewMode().

SEE ALSO
http://doc.trolltech.com/ntqfiledialog.html http://www.trolltech.com/faq/tech.html

COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the license file included in the distribution for a complete license statement.

AUTHOR
Generated automatically from the source code.

BUGS
If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you.

The definitive TQt documentation is provided in HTML format; it is located at $TQTDIR/doc/html and can be read using TQt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech.

If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (tqfiledialog.3qt) and the Qt version (3.3.8).