|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.internal.QSignalEmitterInternal
com.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.core.QObject
com.trolltech.qt.gui.QWidget
com.trolltech.qt.gui.QDialog
com.trolltech.qt.gui.QFileDialog
public class QFileDialog
The QFileDialog class provides a dialog that allow users to select files or directories. The QFileDialog class 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 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.
String fileName = QFileDialog.getOpenFileName(this, tr("Open Image"), "/home/jana", new QFileDialog.Filter(tr("Image Files (*.png *.jpg *.bmp)")));In the above example, a modal QFileDialog is 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:
String filter = "Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)";You can create your own QFileDialog without using the static functions. By calling
setFileMode()
, you can specify what the user must select in the dialog: QFileDialog dialog = new QFileDialog(this); dialog.setFileMode(QFileDialog.FileMode.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. Use ExistingFile
if the user must select an existing file, or Directory
if only a directory may be selected. See the QFileDialog::FileMode
enum for the complete list of modes. The fileMode
property contains the mode of operation for the dialog; this indicates what types of objects the user is expected to select. Use setNameFilter()
to set the dialog's file filter. For example:
dialog.setFilter(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 extension png, xpm, or jpg will be shown in the QFileDialog. You can apply several filters by using
setNameFilters()
. Use selectNameFilter()
to select one of the filters you've given as the file dialog's default filter. The file dialog has two view modes: List
and Detail
. List
presents the contents of the current directory as a list of file and directory names. Detail
also 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 with setViewMode()
:
dialog.setViewMode(QFileDialog.ViewMode.Detail);The last important function you will need to use when creating your own file dialog is
selectedFiles()
. java.util.List fileNames; if (dialog.exec() != 0) 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 the selectFile()
function.
The Standard Dialogs example shows how to use QFileDialog as well as other built-in Qt dialogs.
QDir
, QFileInfo
, QFile
, QPrintDialog
, QColorDialog
, QFontDialog
, Standard Dialogs Example, and Application Example.
Nested Class Summary | |
---|---|
static class |
QFileDialog.AcceptMode
|
static class |
QFileDialog.DialogLabel
|
static class |
QFileDialog.FileMode
This enum is used to indicate what the user may select in the file dialog; i.e. |
static class |
QFileDialog.Filter
|
static class |
QFileDialog.Option
|
static class |
QFileDialog.Options
|
static class |
QFileDialog.ViewMode
This enum describes the view mode of the file dialog; i.e. |
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QDialog |
---|
QDialog.DialogCode |
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QWidget |
---|
QWidget.RenderFlag, QWidget.RenderFlags |
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter |
---|
QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9 |
Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal |
Field Summary | |
---|---|
QSignalEmitter.Signal1 |
currentChanged
This signal takes 1 generic argument(s). |
QSignalEmitter.Signal1 |
directoryEntered
This signal takes 1 generic argument(s). |
QSignalEmitter.Signal1 |
filesSelected
This signal takes 1 generic argument(s). |
QSignalEmitter.Signal1 |
filterSelected
This signal takes 1 generic argument(s). |
Fields inherited from class com.trolltech.qt.gui.QDialog |
---|
accepted, finished, rejected |
Fields inherited from class com.trolltech.qt.gui.QWidget |
---|
customContextMenuRequested |
Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
currentSender |
Constructor Summary | |
---|---|
QFileDialog()
Constructs a file dialog with the given parent and caption that initially displays the contents of the specified directory. |
|
QFileDialog(QWidget parent)
Constructs a file dialog with the given parent and caption that initially displays the contents of the specified directory. |
|
QFileDialog(QWidget parent,
Qt.WindowFlags f)
Constructs a file dialog with the given parent and widget flags. |
|
QFileDialog(QWidget parent,
Qt.WindowType[] f)
|
|
QFileDialog(QWidget parent,
java.lang.String caption)
Constructs a file dialog with the given parent and caption that initially displays the contents of the specified directory. |
|
QFileDialog(QWidget parent,
java.lang.String caption,
java.lang.String directory)
Constructs a file dialog with the given parent and caption that initially displays the contents of the specified directory. |
|
QFileDialog(QWidget parent,
java.lang.String caption,
java.lang.String directory,
java.lang.String filter)
Constructs a file dialog with the given parent and caption that initially displays the contents of the specified directory. |
Method Summary | |
---|---|
QFileDialog.AcceptMode |
acceptMode()
This property holds the accept mode of the dialog. |
boolean |
confirmOverwrite()
This property holds whether the filedialog should ask before accepting a selected file, when the accept mode is AcceptSave . |
java.lang.String |
defaultSuffix()
This property holds suffix added to the filename if no other suffix was specified. |
QDir |
directory()
Returns the directory currently being displayed in the dialog. |
QFileDialog.FileMode |
fileMode()
This property holds the file mode of the dialog. |
QDir.Filters |
filter()
Returns the filter that is used when displaying files. |
java.util.List |
filters()
Use nameFilters() instead. |
static java.lang.String |
getExistingDirectory()
This is a convenience static function that will return an existing directory selected by the user. |
static java.lang.String |
getExistingDirectory(QWidget parent)
This is a convenience static function that will return an existing directory selected by the user. |
static java.lang.String |
getExistingDirectory(QWidget parent,
java.lang.String caption)
This is a convenience static function that will return an existing directory selected by the user. |
static java.lang.String |
getExistingDirectory(QWidget parent,
java.lang.String caption,
java.lang.String dir)
This is a convenience static function that will return an existing directory selected by the user. |
static java.lang.String |
getExistingDirectory(QWidget parent,
java.lang.String caption,
java.lang.String dir,
QFileDialog.Option[] options)
|
static java.lang.String |
getExistingDirectory(QWidget parent,
java.lang.String caption,
java.lang.String dir,
QFileDialog.Options options)
This is a convenience static function that will return an existing directory selected by the user. |
static java.lang.String |
getOpenFileName()
This is an overloaded function provided for convenience. |
static java.lang.String |
getOpenFileName(QWidget parent)
This is an overloaded function provided for convenience. |
static java.lang.String |
getOpenFileName(QWidget parent,
java.lang.String caption)
This is an overloaded function provided for convenience. |
static java.lang.String |
getOpenFileName(QWidget parent,
java.lang.String caption,
java.lang.String dir)
This is an overloaded function provided for convenience. |
static java.lang.String |
getOpenFileName(QWidget parent,
java.lang.String caption,
java.lang.String dir,
QFileDialog.Filter filter)
This is a convenience static function that returns an existing file selected by the user. |
static java.lang.String |
getOpenFileName(QWidget parent,
java.lang.String caption,
java.lang.String dir,
QFileDialog.Filter filter,
QFileDialog.Option[] options)
This is a convenience static function that returns an existing file selected by the user. |
static java.lang.String |
getOpenFileName(QWidget parent,
java.lang.String caption,
java.lang.String dir,
QFileDialog.Filter filter,
QFileDialog.Options options)
This is a convenience static function that returns an existing file selected by the user. |
static java.util.List |
getOpenFileNames()
This is an overloaded function provided for convenience. |
static java.util.List |
getOpenFileNames(QWidget parent)
This is an overloaded function provided for convenience. |
static java.util.List |
getOpenFileNames(QWidget parent,
java.lang.String caption)
This is an overloaded function provided for convenience. |
static java.util.List |
getOpenFileNames(QWidget parent,
java.lang.String caption,
java.lang.String dir)
This is an overloaded function provided for convenience. |
static java.util.List |
getOpenFileNames(QWidget parent,
java.lang.String caption,
java.lang.String dir,
QFileDialog.Filter filter)
This is a convenience static function that will return one or more existing files selected by the user. |
static java.util.List |
getOpenFileNames(QWidget parent,
java.lang.String caption,
java.lang.String dir,
QFileDialog.Filter filter,
QFileDialog.Option[] options)
This is a convenience static function that will return one or more existing files selected by the user. |
static java.util.List |
getOpenFileNames(QWidget parent,
java.lang.String caption,
java.lang.String dir,
QFileDialog.Filter filter,
QFileDialog.Options options)
This is a convenience static function that will return one or more existing files selected by the user. |
static java.lang.String |
getSaveFileName()
This is an overloaded function provided for convenience. |
static java.lang.String |
getSaveFileName(QWidget parent)
This is an overloaded function provided for convenience. |
static java.lang.String |
getSaveFileName(QWidget parent,
java.lang.String caption)
This is an overloaded function provided for convenience. |
static java.lang.String |
getSaveFileName(QWidget parent,
java.lang.String caption,
java.lang.String dir)
This is an overloaded function provided for convenience. |
static java.lang.String |
getSaveFileName(QWidget parent,
java.lang.String caption,
java.lang.String dir,
QFileDialog.Filter filter)
This is a convenience static function that will return a file name selected by the user. |
static java.lang.String |
getSaveFileName(QWidget parent,
java.lang.String caption,
java.lang.String dir,
QFileDialog.Filter filter,
QFileDialog.Option[] options)
This is a convenience static function that will return a file name selected by the user. |
static java.lang.String |
getSaveFileName(QWidget parent,
java.lang.String caption,
java.lang.String dir,
QFileDialog.Filter filter,
QFileDialog.Options options)
This is a convenience static function that will return a file name selected by the user. |
java.util.List |
history()
Returns the browsing history of the filedialog as a list of paths. |
QFileIconProvider |
iconProvider()
Returns the icon provider used by the filedialog. |
boolean |
isNameFilterDetailsVisible()
This property holds This property holds whether the filter details is shown or not. |
boolean |
isReadOnly()
This property holds Whether the filedialog is readonly. |
QAbstractItemDelegate |
itemDelegate()
Returns the item delegate used to render the items in the views in the filedialog. |
java.lang.String |
labelText(QFileDialog.DialogLabel label)
Returns the text shown in the filedialog in the specified label. |
java.util.List |
nameFilters()
Returns the file type filters that are in operation on this file dialog. |
QAbstractProxyModel |
proxyModel()
Returns the proxy model used by the file dialog. |
boolean |
resolveSymlinks()
This property holds whether the filedialog should resolve shortcuts. |
boolean |
restoreState(QByteArray state)
Restores the dialogs's layout, history and current directory to the state specified. |
QByteArray |
saveState()
Saves the state of the dialog's layout, history and current directory. |
java.util.List |
selectedFiles()
Returns a list of strings containing the absolute paths of the selected files in the dialog. |
java.lang.String |
selectedFilter()
Use selectedNameFilter() instead. |
java.lang.String |
selectedNameFilter()
Returns the filter that the user selected in the file dialog. |
void |
selectFile(java.lang.String filename)
Selects the given filename in the file dialog. |
void |
selectFilter(java.lang.String filter)
Use selectNameFilter() instead. |
void |
selectNameFilter(java.lang.String filter)
Sets the current file type filter. |
void |
setAcceptMode(QFileDialog.AcceptMode mode)
This property holds the accept mode of the dialog. |
void |
setConfirmOverwrite(boolean enabled)
This property holds whether the filedialog should ask before accepting a selected file, when the accept mode is AcceptSave . |
void |
setDefaultSuffix(java.lang.String suffix)
This property holds suffix added to the filename if no other suffix was specified. |
void |
setDirectory(QDir directory)
Set the current directory of this QFileDialog to directory. |
void |
setDirectory(java.lang.String directory)
Sets the file dialog's current directory. |
void |
setFileMode(QFileDialog.FileMode mode)
This property holds the file mode of the dialog. |
void |
setFilter(QDir.Filter[] filters)
|
void |
setFilter(QDir.Filters filters)
Sets the filter used by the model to filters. |
void |
setFilter(java.lang.String filter)
Use setNameFilter() instead. |
void |
setFilters(java.util.List filters)
Use setNameFilters() instead. |
void |
setHistory(java.util.List paths)
Sets the browsing history of the filedialog to contain the given paths. |
void |
setIconProvider(QFileIconProvider provider)
Sets the icon provider used by the filedialog to the specified provider. |
void |
setItemDelegate(QAbstractItemDelegate delegate)
Sets the item delegate used to render items in the views in the file dialog to the given delegate. |
void |
setLabelText(QFileDialog.DialogLabel label,
java.lang.String text)
Sets the text shown in the filedialog in the specified label. |
void |
setNameFilter(java.lang.String filter)
Sets the filter used in the file dialog to the given filter. |
void |
setNameFilterDetailsVisible(boolean enabled)
This property holds This property holds whether the filter details is shown or not. |
void |
setNameFilters(java.util.List filters)
Sets the filters used in the file dialog. |
void |
setProxyModel(QAbstractProxyModel model)
Sets the model for the views to the given proxyModel. |
void |
setReadOnly(boolean enabled)
This property holds Whether the filedialog is readonly. |
void |
setResolveSymlinks(boolean enabled)
This property holds whether the filedialog should resolve shortcuts. |
void |
setSidebarUrls(java.util.List urls)
Sets the urls that are located in the sidebar |
void |
setViewMode(QFileDialog.ViewMode mode)
This property holds the way files and directories are displayed in the dialog. |
java.util.List |
sidebarUrls()
Returns a list of urls that are currently in the sidebar |
QFileDialog.ViewMode |
viewMode()
This property holds the way files and directories are displayed in the dialog. |
Methods inherited from class com.trolltech.qt.gui.QDialog |
---|
accept, done, exec, isSizeGripEnabled, reject, result, setModal, setResult, setSizeGripEnabled |
Methods inherited from class com.trolltech.qt.core.QObject |
---|
childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, indexOfProperty, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, properties, property, removeEventFilter, setObjectName, setParent, setProperty, startTimer, timerEvent, toString, userProperty |
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr |
Methods inherited from class com.trolltech.qt.QSignalEmitter |
---|
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread |
Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
__qt_signalInitialization |
Methods inherited from class java.lang.Object |
---|
clone, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface com.trolltech.qt.QtJambiInterface |
---|
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership |
Field Detail |
---|
public final QSignalEmitter.Signal1 currentChanged
This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.String(named: path)>:
When the current file changes, this signal is emitted with the new file name as the path parameter.
filesSelected()
.
public final QSignalEmitter.Signal1 directoryEntered
This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.String(named: directory)>:
This signal is emitted when the user enters a directory.
public final QSignalEmitter.Signal1 filesSelected
This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <java.util.List When the selection changes and the dialog is accepted, this signal is emitted with the (possibly empty) list of selected files.
currentChanged()
, and QDialog::Accepted
.
public final QSignalEmitter.Signal1 filterSelected
This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.String(named: filter)>:
This signal is emitted when the user selects a filter.
Constructor Detail |
---|
public QFileDialog(QWidget parent, Qt.WindowType[] f)
public QFileDialog(QWidget parent, Qt.WindowFlags f)
public QFileDialog(QWidget parent, java.lang.String caption, java.lang.String directory)
public QFileDialog(QWidget parent, java.lang.String caption)
public QFileDialog(QWidget parent)
public QFileDialog()
public QFileDialog(QWidget parent, java.lang.String caption, java.lang.String directory, java.lang.String filter)
Method Detail |
---|
public final QFileDialog.AcceptMode acceptMode()
By default, this property is set to AcceptOpen
.
AcceptMode
.
public final boolean confirmOverwrite()
AcceptSave
. If this property is set to true and the accept mode is AcceptSave
, the filedialog will ask whether the user wants to overwrite the file before accepting the file. By default, this property is true.
public final java.lang.String defaultSuffix()
public final QDir directory()
setDirectory()
.
public final QFileDialog.FileMode fileMode()
By default, this property is set to AnyFile
.
FileMode
.
public final QDir.Filters filter()
setFilter()
.
public final java.util.List filters()
nameFilters()
instead.
public final java.util.List history()
setHistory()
.
public final QFileIconProvider iconProvider()
setIconProvider()
.
public final boolean isNameFilterDetailsVisible()
setNameFilters()
.
public final boolean isReadOnly()
The default value is false.
public final QAbstractItemDelegate itemDelegate()
setItemDelegate()
.
public final java.lang.String labelText(QFileDialog.DialogLabel label)
setLabelText()
.
public final java.util.List nameFilters()
setNameFilters()
.
public final QAbstractProxyModel proxyModel()
setProxyModel()
.
public final boolean resolveSymlinks()
By default, this property is false.
public final boolean restoreState(QByteArray state)
Typically this is used in conjunction with QSettings
to restore the size from a past session.
Returns false if there are errors
public final QByteArray saveState()
Typically this is used in conjunction with QSettings
to remember the size for a future session. A version number is stored as part of the data.
public final void selectFile(java.lang.String filename)
selectedFiles()
.
public final void selectFilter(java.lang.String filter)
selectNameFilter()
instead.
public final void selectNameFilter(java.lang.String filter)
setNameFilter()
, setNameFilters()
, and selectedNameFilter()
.
public final java.util.List selectedFiles()
ExistingFiles
, selectedFiles()
contains the current path in the viewport. selectedNameFilter()
, and selectFile()
.
public final java.lang.String selectedFilter()
selectedNameFilter()
instead.
public final java.lang.String selectedNameFilter()
selectedFiles()
.
public final void setAcceptMode(QFileDialog.AcceptMode mode)
By default, this property is set to AcceptOpen
.
AcceptMode
.
public final void setConfirmOverwrite(boolean enabled)
AcceptSave
. If this property is set to true and the accept mode is AcceptSave
, the filedialog will ask whether the user wants to overwrite the file before accepting the file. By default, this property is true.
public final void setDefaultSuffix(java.lang.String suffix)
public final void setDirectory(QDir directory)
public final void setDirectory(java.lang.String directory)
directory()
.
public final void setFileMode(QFileDialog.FileMode mode)
By default, this property is set to AnyFile
.
FileMode
.
public final void setFilter(QDir.Filter[] filters)
public final void setFilter(QDir.Filters filters)
filter()
.
public final void setFilter(java.lang.String filter)
setNameFilter()
instead.
public final void setFilters(java.util.List filters)
setNameFilters()
instead.
public final void setHistory(java.util.List paths)
history()
.
public final void setIconProvider(QFileIconProvider provider)
iconProvider()
.
public final void setItemDelegate(QAbstractItemDelegate 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.
itemDelegate()
.
public final void setLabelText(QFileDialog.DialogLabel label, java.lang.String text)
labelText()
.
public final void setNameFilter(java.lang.String filter)
If filter contains a pair of parentheses containing one or more of anything*something, 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.setFilter("All C++ files (*.cpp *.cc *.C *.cxx *.c++)"); dialog.setFilter("*.cpp;*.cc;*.C;*.cxx;*.c++");
setNameFilters()
.
public final void setNameFilterDetailsVisible(boolean enabled)
setNameFilters()
.
public final void setNameFilters(java.util.List filters)
java.util.ArrayList<String> filters = new java.util.ArrayList<String>(); filters.add("Image files (*.png *.xpm *.jpg)"); filters.add("Text files (*.txt)"); filters.add("Any files (*)"); QFileDialog dlg = new QFileDialog(this); dlg.setFilters(filters); dlg.exec();
nameFilters()
.
public final void setProxyModel(QAbstractProxyModel model)
Any existing proxy model will be removed, but not deleted. The file dialog will take ownership of the proxyModel.
proxyModel()
.
public final void setReadOnly(boolean enabled)
The default value is false.
public final void setResolveSymlinks(boolean enabled)
By default, this property is false.
public final void setSidebarUrls(java.util.List urls)
sidebarUrls()
.
public final void setViewMode(QFileDialog.ViewMode mode)
ViewMode
.
public final java.util.List sidebarUrls()
setSidebarUrls()
.
public final QFileDialog.ViewMode viewMode()
ViewMode
.
public static java.lang.String getExistingDirectory(QWidget parent, java.lang.String caption, java.lang.String dir, QFileDialog.Option[] options)
public static java.lang.String getExistingDirectory(QWidget parent, java.lang.String caption, java.lang.String dir)
String dir = QFileDialog.getExistingDirectory(this, tr("Open Directory"), "/home", QFileDialog.Option.createQFlags( QFileDialog.Option.ShowDirsOnly, QFileDialog.Option.DontResolveSymlinks));This function creates a modal file dialog with the given parent widget. If the parent is 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 options argument holds various options about how to run the dialog, see the QFileDialog::Option
enum for more information on the flags you can pass.
Under Windows and Mac OS X, this static function will use the native file dialog and not a QFileDialog. On Mac OS X, the dir argument is ignored, the native dialog always displays the last visited directory. On Windows CE, if the device has no native file dialog, a QFileDialog will be used.
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 options includes DontResolveSymlinks
, the file dialog will treat symlinks as regular directories.
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 title bar.
getOpenFileName()
, getOpenFileNames()
, and getSaveFileName()
.
public static java.lang.String getExistingDirectory(QWidget parent, java.lang.String caption)
String dir = QFileDialog.getExistingDirectory(this, tr("Open Directory"), "/home", QFileDialog.Option.createQFlags( QFileDialog.Option.ShowDirsOnly, QFileDialog.Option.DontResolveSymlinks));This function creates a modal file dialog with the given parent widget. If the parent is 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 options argument holds various options about how to run the dialog, see the QFileDialog::Option
enum for more information on the flags you can pass.
Under Windows and Mac OS X, this static function will use the native file dialog and not a QFileDialog. On Mac OS X, the dir argument is ignored, the native dialog always displays the last visited directory. On Windows CE, if the device has no native file dialog, a QFileDialog will be used.
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 options includes DontResolveSymlinks
, the file dialog will treat symlinks as regular directories.
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 title bar.
getOpenFileName()
, getOpenFileNames()
, and getSaveFileName()
.
public static java.lang.String getExistingDirectory(QWidget parent)
String dir = QFileDialog.getExistingDirectory(this, tr("Open Directory"), "/home", QFileDialog.Option.createQFlags( QFileDialog.Option.ShowDirsOnly, QFileDialog.Option.DontResolveSymlinks));This function creates a modal file dialog with the given parent widget. If the parent is 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 options argument holds various options about how to run the dialog, see the QFileDialog::Option
enum for more information on the flags you can pass.
Under Windows and Mac OS X, this static function will use the native file dialog and not a QFileDialog. On Mac OS X, the dir argument is ignored, the native dialog always displays the last visited directory. On Windows CE, if the device has no native file dialog, a QFileDialog will be used.
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 options includes DontResolveSymlinks
, the file dialog will treat symlinks as regular directories.
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 title bar.
getOpenFileName()
, getOpenFileNames()
, and getSaveFileName()
.
public static java.lang.String getExistingDirectory()
String dir = QFileDialog.getExistingDirectory(this, tr("Open Directory"), "/home", QFileDialog.Option.createQFlags( QFileDialog.Option.ShowDirsOnly, QFileDialog.Option.DontResolveSymlinks));This function creates a modal file dialog with the given parent widget. If the parent is 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 options argument holds various options about how to run the dialog, see the QFileDialog::Option
enum for more information on the flags you can pass.
Under Windows and Mac OS X, this static function will use the native file dialog and not a QFileDialog. On Mac OS X, the dir argument is ignored, the native dialog always displays the last visited directory. On Windows CE, if the device has no native file dialog, a QFileDialog will be used.
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 options includes DontResolveSymlinks
, the file dialog will treat symlinks as regular directories.
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 title bar.
getOpenFileName()
, getOpenFileNames()
, and getSaveFileName()
.
public static java.lang.String getExistingDirectory(QWidget parent, java.lang.String caption, java.lang.String dir, QFileDialog.Options options)
String dir = QFileDialog.getExistingDirectory(this, tr("Open Directory"), "/home", QFileDialog.Option.createQFlags( QFileDialog.Option.ShowDirsOnly, QFileDialog.Option.DontResolveSymlinks));This function creates a modal file dialog with the given parent widget. If the parent is 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 options argument holds various options about how to run the dialog, see the QFileDialog::Option
enum for more information on the flags you can pass.
Under Windows and Mac OS X, this static function will use the native file dialog and not a QFileDialog. On Mac OS X, the dir argument is ignored, the native dialog always displays the last visited directory. On Windows CE, if the device has no native file dialog, a QFileDialog will be used.
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 options includes DontResolveSymlinks
, the file dialog will treat symlinks as regular directories.
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 title bar.
getOpenFileName()
, getOpenFileNames()
, and getSaveFileName()
.
public static java.lang.String getOpenFileName(QWidget parent, java.lang.String caption, java.lang.String dir, QFileDialog.Filter filter, QFileDialog.Options options)
String fName = QFileDialog.getOpenFileName(this, tr("Open File"), "/home", new QFileDialog.Filter(tr("Images (*.png *.xpm *.jpg)")));The function creates a modal file dialog with the given parent widget. If the parent is not 0, the dialog will be shown centered over the parent widget.
The file dialog's working directory will be set to dir. If dir includes a file name, the file will be selected. Only files that match the given filter are shown. The filter selected is set to selectedFilter. The parameters dir, selectedFilter, and filter may be empty strings. The options argument holds various options about how to run the dialog, see the QFileDialog::Option
enum for more information on the flags you can pass.
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.
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 title bar.
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 options includes DontResolveSymlinks
, the file dialog will treat symlinks as regular directories.
getOpenFileNames()
, getSaveFileName()
, and getExistingDirectory()
.
public static java.lang.String getOpenFileName(QWidget parent, java.lang.String caption, java.lang.String dir, QFileDialog.Filter filter, QFileDialog.Option[] options)
String fName = QFileDialog.getOpenFileName(this, tr("Open File"), "/home", new QFileDialog.Filter(tr("Images (*.png *.xpm *.jpg)")));The function creates a modal file dialog with the given parent widget. If the parent is not 0, the dialog will be shown centered over the parent widget.
The file dialog's working directory will be set to dir. If dir includes a file name, the file will be selected. Only files that match the given filter are shown. The filter selected is set to selectedFilter. The parameters dir, selectedFilter, and filter may be empty strings. The options argument holds various options about how to run the dialog, see the QFileDialog::Option
enum for more information on the flags you can pass.
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.
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 title bar.
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 options includes DontResolveSymlinks
, the file dialog will treat symlinks as regular directories.
getOpenFileNames()
, getSaveFileName()
, and getExistingDirectory()
.
public static java.lang.String getOpenFileName(QWidget parent, java.lang.String caption, java.lang.String dir, QFileDialog.Filter filter)
String fName = QFileDialog.getOpenFileName(this, tr("Open File"), "/home", new QFileDialog.Filter(tr("Images (*.png *.xpm *.jpg)")));The function creates a modal file dialog with the given parent widget. If the parent is not 0, the dialog will be shown centered over the parent widget.
The file dialog's working directory will be set to dir. If dir includes a file name, the file will be selected. Only files that match the given filter are shown. The filter selected is set to selectedFilter. The parameters dir, selectedFilter, and filter may be empty strings. The options argument holds various options about how to run the dialog, see the QFileDialog::Option
enum for more information on the flags you can pass.
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.
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 title bar.
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 options includes DontResolveSymlinks
, the file dialog will treat symlinks as regular directories.
getOpenFileNames()
, getSaveFileName()
, and getExistingDirectory()
.
public static java.lang.String getOpenFileName(QWidget parent, java.lang.String caption, java.lang.String dir)
public static java.lang.String getOpenFileName(QWidget parent, java.lang.String caption)
public static java.lang.String getOpenFileName(QWidget parent)
public static java.lang.String getOpenFileName()
public static java.util.List getOpenFileNames(QWidget parent, java.lang.String caption, java.lang.String dir, QFileDialog.Filter filter, QFileDialog.Options options)
java.util.List<String> files = QFileDialog.getOpenFileNames( this, "Select one or more files to open", "/home", new QFileDialog.Filter("Images (*.png *.xpm *.jpg)"));This function creates a modal file dialog with the given parent widget. If the parent is not 0, the dialog will be shown centered over the parent widget.
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 empty strings.
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. On Mac OS X, the dir argument is ignored, the native dialog always displays the last visited directory.
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 title bar.
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. The options argument holds various options about how to run the dialog, see the QFileDialog::Option
enum for more information on the flags you can pass.
Note that if you want to iterate over the list of files, you should iterate over a copy. For example:
java.util.List<String> list = files; java.util.ListIterator it = list.listIterator(); while(it.hasNext()) { myProcessing(it.next()); }
getOpenFileName()
, getSaveFileName()
, and getExistingDirectory()
.
public static java.util.List getOpenFileNames(QWidget parent, java.lang.String caption, java.lang.String dir, QFileDialog.Filter filter, QFileDialog.Option[] options)
java.util.List<String> files = QFileDialog.getOpenFileNames( this, "Select one or more files to open", "/home", new QFileDialog.Filter("Images (*.png *.xpm *.jpg)"));This function creates a modal file dialog with the given parent widget. If the parent is not 0, the dialog will be shown centered over the parent widget.
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 empty strings.
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. On Mac OS X, the dir argument is ignored, the native dialog always displays the last visited directory.
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 title bar.
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. The options argument holds various options about how to run the dialog, see the QFileDialog::Option
enum for more information on the flags you can pass.
Note that if you want to iterate over the list of files, you should iterate over a copy. For example:
java.util.List<String> list = files; java.util.ListIterator it = list.listIterator(); while(it.hasNext()) { myProcessing(it.next()); }
getOpenFileName()
, getSaveFileName()
, and getExistingDirectory()
.
public static java.util.List getOpenFileNames(QWidget parent, java.lang.String caption, java.lang.String dir, QFileDialog.Filter filter)
java.util.List<String> files = QFileDialog.getOpenFileNames( this, "Select one or more files to open", "/home", new QFileDialog.Filter("Images (*.png *.xpm *.jpg)"));This function creates a modal file dialog with the given parent widget. If the parent is not 0, the dialog will be shown centered over the parent widget.
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 empty strings.
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. On Mac OS X, the dir argument is ignored, the native dialog always displays the last visited directory.
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 title bar.
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. The options argument holds various options about how to run the dialog, see the QFileDialog::Option
enum for more information on the flags you can pass.
Note that if you want to iterate over the list of files, you should iterate over a copy. For example:
java.util.List<String> list = files; java.util.ListIterator it = list.listIterator(); while(it.hasNext()) { myProcessing(it.next()); }
getOpenFileName()
, getSaveFileName()
, and getExistingDirectory()
.
public static java.util.List getOpenFileNames(QWidget parent, java.lang.String caption, java.lang.String dir)
public static java.util.List getOpenFileNames(QWidget parent, java.lang.String caption)
public static java.util.List getOpenFileNames(QWidget parent)
public static java.util.List getOpenFileNames()
public static java.lang.String getSaveFileName(QWidget parent, java.lang.String caption, java.lang.String dir, QFileDialog.Filter filter, QFileDialog.Options options)
It creates a modal file dialog with the given parent widget. If the parent is not 0, the dialog will be shown centered over the parent widget.
String saveName = QFileDialog.getSaveFileName(this, tr("Save File"), "/home/jana/untitled.png", new QFileDialog.Filter(tr("Images (*.png *.xpm *.jpg)")));The file dialog's working directory will be set to dir. If dir includes a file name, the file will be selected. Only files that match the filter are shown. The filter selected is set to selectedFilter. The parameters dir, selectedFilter, and filter may be empty strings. The options argument holds various options about how to run the dialog, see the
QFileDialog::Option
enum for more information on the flags you can pass. The default filter can be chosen by setting selectedFilter to the desired value.
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.
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 title bar. On Mac OS X, the filter argument is ignored.
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 options includes DontResolveSymlinks
, the file dialog will treat symlinks as regular directories.
getOpenFileName()
, getOpenFileNames()
, and getExistingDirectory()
.
public static java.lang.String getSaveFileName(QWidget parent, java.lang.String caption, java.lang.String dir, QFileDialog.Filter filter, QFileDialog.Option[] options)
It creates a modal file dialog with the given parent widget. If the parent is not 0, the dialog will be shown centered over the parent widget.
String saveName = QFileDialog.getSaveFileName(this, tr("Save File"), "/home/jana/untitled.png", new QFileDialog.Filter(tr("Images (*.png *.xpm *.jpg)")));The file dialog's working directory will be set to dir. If dir includes a file name, the file will be selected. Only files that match the filter are shown. The filter selected is set to selectedFilter. The parameters dir, selectedFilter, and filter may be empty strings. The options argument holds various options about how to run the dialog, see the
QFileDialog::Option
enum for more information on the flags you can pass. The default filter can be chosen by setting selectedFilter to the desired value.
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.
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 title bar. On Mac OS X, the filter argument is ignored.
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 options includes DontResolveSymlinks
, the file dialog will treat symlinks as regular directories.
getOpenFileName()
, getOpenFileNames()
, and getExistingDirectory()
.
public static java.lang.String getSaveFileName(QWidget parent, java.lang.String caption, java.lang.String dir, QFileDialog.Filter filter)
It creates a modal file dialog with the given parent widget. If the parent is not 0, the dialog will be shown centered over the parent widget.
String saveName = QFileDialog.getSaveFileName(this, tr("Save File"), "/home/jana/untitled.png", new QFileDialog.Filter(tr("Images (*.png *.xpm *.jpg)")));The file dialog's working directory will be set to dir. If dir includes a file name, the file will be selected. Only files that match the filter are shown. The filter selected is set to selectedFilter. The parameters dir, selectedFilter, and filter may be empty strings. The options argument holds various options about how to run the dialog, see the
QFileDialog::Option
enum for more information on the flags you can pass. The default filter can be chosen by setting selectedFilter to the desired value.
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.
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 title bar. On Mac OS X, the filter argument is ignored.
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 options includes DontResolveSymlinks
, the file dialog will treat symlinks as regular directories.
getOpenFileName()
, getOpenFileNames()
, and getExistingDirectory()
.
public static java.lang.String getSaveFileName(QWidget parent, java.lang.String caption, java.lang.String dir)
public static java.lang.String getSaveFileName(QWidget parent, java.lang.String caption)
public static java.lang.String getSaveFileName(QWidget parent)
public static java.lang.String getSaveFileName()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |