QFileDialog Class Reference


The QFileDialog provides a dialog widget for inputting file names. More...

#include <qfiledlg.h>

Inherits QDialog.

List of all member functions.

Public Members

Signals

Static Public Members

Protected Members


Detailed Description

The QFileDialog provides a dialog widget for inputting file names.

Example:

    QString fileName = QFileDialog::getOpenFileName();
    if ( !fileName.isNull() ) {                 // got a file name
        ...
    }

There are two ready-made convenience functions, getOpenFileName() and getSaveFileName(), which may be used like this:

    QString s( QFileDialog::getOpenFileName() );
    if ( s.isNull() )
        return;

    open( s ); // open() being your function to read the file

See also: QPrintDialog.

Examples: movies/main.cpp


Member Function Documentation

QFileDialog::QFileDialog ( QWidget * parent=0, const char * name=0, bool modal=FALSE )

Constructs a file dialog with a parent, name and modal flag.

The dialog becomes modal if modal is TRUE, otherwise modeless.

QFileDialog::QFileDialog ( const char * dirName, const char * filter = 0, QWidget * parent=0, const char * name=0, bool modal=FALSE )

Constructs a file dialog with a parent, name and modal flag.

The dialog becomes modal if modal is TRUE, otherwise modeless.

QFileDialog::~QFileDialog ()

Destroys the file dialog.

const QDir * QFileDialog::dir () const

Returns the active directory in the file dialog.

See also: setDir().

void QFileDialog::dirEntered ( const char * ) [signal]

This signal is emitted when the user has selected a new directory.

const char * QFileDialog::dirPath () const

Returns the active directory path string in the file dialog.

See also: dir() and setDir().

void QFileDialog::fileHighlighted ( const char * ) [signal]

This signal is emitted when the user highlights a file.

void QFileDialog::fileSelected ( const char * ) [signal]

This signal is emitted when the user selects a file.

QString QFileDialog::getOpenFileName ( const char * dirName = 0, const char * filter= 0, QWidget * parent = 0, const char * name = 0 ) [static]

Opens a modal file dialog and returns the name of the file to be opened. Returns a null string if the user cancelled the dialog.

This static function is less capable than the full QFileDialog object, but is convenient and easy to use.

Example:

    // start at the current working directory and with *.cpp as filter
    QString f = QFileDialog::getOpenFileName( 0, "*.cpp", this );
    if ( !f.isEmpty() ) {
        // the user selected a valid existing file
    } else {
        // the user cancelled the dialog
    }

getSaveFileName() is another convenience function, equal to this one except that it allows the user to specify the name of a nonexistent file name.

See also: getSaveFileName().

QString QFileDialog::getSaveFileName ( const char * dirName = 0, const char * filter= 0, QWidget * parent = 0, const char * name = 0 ) [static]

Opens a modal file dialog and returns the name of the file to be saved. Returns a null string if the user cancelled the dialog.

This static function is less capable than the full QFileDialog object, but is convenient and easy to use.

Example:

    // start at the current working directory and with *.cpp as filter
    QString f = QFileDialog::getSaveFileName( 0, "*.cpp", this );
    if ( !f.isEmpty() ) {
        // the user gave a file name
    } else {
        // the user cancelled the dialog
    }

getOpenFileName() is another convenience function, equal to this one except that it allows the user to specify the name of a nonexistent file name.

See also: getOpenFileName().

void QFileDialog::rereadDir ()

Re-reads the active directory in the file dialog.

It is seldom necessary to call this function. It is provided in case the directory contents change and you want to refresh the directory list box.

void QFileDialog::resizeEvent ( QResizeEvent * ) [virtual protected]

Handles resize events for the file dialog.

Reimplemented from QWidget.

QString QFileDialog::selectedFile () const

Returns the selected file name.

If a file name was selected, the returned string will contain the absolute path name. The returned string will be a null string if no file name was selected.

See also: QString::isNull().

void QFileDialog::setDir ( const QDir & dir )

Sets a directory path for the file dialog.

See also: dir().

void QFileDialog::setDir ( const char * pathstr )

Sets a directory path string for the file dialog.

See also: dir().


This file is part of the Qt toolkit, copyright © 1995-97 Troll Tech, all rights reserved.

It was generated from the following files:


Generated at 23:50, 1998/03/16 for Qt version 1.33 by the webmaster at Troll Tech