188
\class QDirModel qdirmodel.h
190
\brief The QDirModel class provides a data model for the local filesystem.
194
This class provides access to the local filesystem, providing functions
195
for renaming and removing files and directories, and for creating new
196
directories. In the simplest case, it can be used with a suitable display
197
widget as part of a browser or filer.
199
QDirModel keeps a cache with file information. The cache needs to be
200
updated with refresh().
202
A directory model that displays the contents of a default directory
203
is usually constructed with a parent object:
205
\snippet doc/src/snippets/shareddirmodel/main.cpp 2
207
A tree view can be used to display the contents of the model
209
\snippet doc/src/snippets/shareddirmodel/main.cpp 4
211
and the contents of a particular directory can be displayed by
212
setting the tree view's root index:
214
\snippet doc/src/snippets/shareddirmodel/main.cpp 7
216
The view's root index can be used to control how much of a
217
hierarchical model is displayed. QDirModel provides a convenience
218
function that returns a suitable model index for a path to a
219
directory within the model.
221
QDirModel can be accessed using the standard interface provided by
222
QAbstractItemModel, but it also provides some convenience functions
223
that are specific to a directory model. The fileInfo() and isDir()
224
functions provide information about the underlying files and directories
225
related to items in the model.
227
Directories can be created and removed using mkdir(), rmdir(), and the
228
model will be automatically updated to take the changes into account.
230
\sa nameFilters(), setFilter(), filter(), QListView, QTreeView,
231
{Dir View Example}, {Model Classes}
188
\class QDirModel qdirmodel.h
190
\brief The QDirModel class provides a data model for the local filesystem.
194
This class provides access to the local filesystem, providing functions
195
for renaming and removing files and directories, and for creating new
196
directories. In the simplest case, it can be used with a suitable display
197
widget as part of a browser or filer.
199
QDirModel keeps a cache with file information. The cache needs to be
200
updated with refresh().
202
A directory model that displays the contents of a default directory
203
is usually constructed with a parent object:
205
\snippet doc/src/snippets/shareddirmodel/main.cpp 2
207
A tree view can be used to display the contents of the model
209
\snippet doc/src/snippets/shareddirmodel/main.cpp 4
211
and the contents of a particular directory can be displayed by
212
setting the tree view's root index:
214
\snippet doc/src/snippets/shareddirmodel/main.cpp 7
216
The view's root index can be used to control how much of a
217
hierarchical model is displayed. QDirModel provides a convenience
218
function that returns a suitable model index for a path to a
219
directory within the model.
221
QDirModel can be accessed using the standard interface provided by
222
QAbstractItemModel, but it also provides some convenience functions
223
that are specific to a directory model. The fileInfo() and isDir()
224
functions provide information about the underlying files and directories
225
related to items in the model.
227
Directories can be created and removed using mkdir(), rmdir(), and the
228
model will be automatically updated to take the changes into account.
230
\note QDirModel requires an instance of a GUI application.
232
\sa nameFilters(), setFilter(), filter(), QListView, QTreeView,
233
{Dir View Example}, {Model Classes}