Äîêóìåíò âçÿò èç êýøà ïîèñêîâîé ìàøèíû. Àäðåñ îðèãèíàëüíîãî äîêóìåíòà : http://rtm-cs.sinp.msu.ru/manual/qt/qfiledialog.html
Äàòà èçìåíåíèÿ: Sun Jul 12 02:58:59 1998
Äàòà èíäåêñèðîâàíèÿ: Mon Oct 1 20:32:52 2012
Êîäèðîâêà:
Qt Toolkit - QFileDialog Class Qt logo

QFileDialog Class Reference


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

#include <qfiledialog.h>

Inherits QDialog.

List of all member functions.

Public Members

Public Slots

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.

void QFileDialog::addWidgets ( QLabel * l, QWidget * w, QPushButton * b ) [protected]

Adds 1-3 widgets to the bottom of the file dialog. l is the (optional) label, which is put beneath the "file name" and "file type" labels, w is a (optional) widget, which is put beneath the file type combo box, and b is the (you guessed it - optional) button, which is put beneath the cancel button.

If you don't want to add something in one of the columns, pass 0.

It is not currently possible to add more than one row.

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().

bool QFileDialog::eventFilter ( QObject * o, QEvent * e ) [virtual]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QObject.

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::getExistingDirectory ( const char * dir = 0, QWidget * parent = 0, const char * name = 0 ) [static]

Ask the user for the name of an existing directory, starting at dir. Returns the name of the directory the user selected.

If dir is null, getExistingDirectory() starts wherever the previous file dialog left off.

QString QFileDialog::getOpenFileName ( const char * startWith = 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.

If startWith is the name of a directory, the dialog starts off in that directory. If startWith is the name of an existing file, the dialogs starts in that directory, and with startWith selected.

Only files matching filter are selectable. If filter is 0, all files are selectable.

If widget and/or name is provided, the dialog will be centered over widget and named name.

getOpenFileName() 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 * startWith = 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.

If startWith is the name of a directory, the dialog starts off in that directory. If startWith is the name of an existing file, the dialogs starts in that directory, and with startWith selected.

Only files matching filter are selectable. If filter is 0, all files are selectable.

If widget and/or name is provided, the dialog will be centered over widget and named name.

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 does not allow the user to specify the name of a nonexistent file name.

See also: getOpenFileName().

QFileIconProvider * QFileDialog::iconProvider () [static]

Returns the icon provider currently in use. By default there is no icon provider and this function returns 0.

See also: setIconProvider() and QFileIconProvider.

void QFileDialog::keyPressEvent ( QKeyEvent * ke ) [virtual protected]

Reimplemented for internal reasons; the API is not affected.

Reimplemented from QWidget.

QFileDialog::Mode QFileDialog::mode() const

Returns the file mode of this dialog.

See also: setMode().

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 contains the absolute path name. The returned string is 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 ) [slot]

Sets a directory path string for the file dialog.

See also: dir().

void QFileDialog::setFilter ( const char * newFilter ) [slot]

Sets the filter spec in use to newFilter.

If newFilter matches the regular expression ([a-zA-Z0-9\.\*\?]*)$ (ie. it ends with a normal wildcard expression enclosed in parentheses), only the parenthesized is used. This means that these two calls are equivalent:

     fd->setFilter( "All perl files (*.pl)" );
     fd->setFilter( "*.pl" )

void QFileDialog::setFilters ( const char ** types ) [slot]

Sets this file dialog to offer types in the File Type combo box. types must be a null-terminated list of strings; each string must be in the format described in the documentation for setFilter().

See also: setFilter().

void QFileDialog::setFilters ( const QStrList & ) [slot]

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

void QFileDialog::setIconProvider ( QFileIconProvider * provider ) [static]

Sets all file dialogs to use provider to select icons to draw for each file. By default there is no icon provider, and QFileDialog simply draws a "folder" icon next to each directory and nothing next to the files.

See also: QFileIconProvider and iconProvider().

void QFileDialog::setMode ( Mode newMode )

Sets this file dialog to newMode, which can be one of Directory (directories are accepted), ExistingFile (existing files are accepted) or AnyFile (any valid file name is accepted).

See also: mode().

void QFileDialog::setSelection ( const char * filename )

Sets the default selection to filename. If filename is absolute, setDir() is also called.


Search the documentation, FAQ, qt-interest archive and more (uses www.troll.no):


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

It was generated from the following files:


Copyright © 1998 Troll TechTrademarks
Qt version 1.40