<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- qdeclarativefolderlistmodel.cpp --> <title>Qt 4.8: QML FolderListModel Element</title> <link rel="stylesheet" type="text/css" href="style/style.css" /> <script src="scripts/jquery.js" type="text/javascript"></script> <script src="scripts/functions.js" type="text/javascript"></script> <link rel="stylesheet" type="text/css" href="style/superfish.css" /> <link rel="stylesheet" type="text/css" href="style/narrow.css" /> <!--[if IE]> <meta name="MSSmartTagsPreventParsing" content="true"> <meta http-equiv="imagetoolbar" content="no"> <![endif]--> <!--[if lt IE 7]> <link rel="stylesheet" type="text/css" href="style/style_ie6.css"> <![endif]--> <!--[if IE 7]> <link rel="stylesheet" type="text/css" href="style/style_ie7.css"> <![endif]--> <!--[if IE 8]> <link rel="stylesheet" type="text/css" href="style/style_ie8.css"> <![endif]--> <script src="scripts/superfish.js" type="text/javascript"></script> <script src="scripts/narrow.js" type="text/javascript"></script> </head> <body class="" onload="CheckEmptyAndLoadList();"> <div class="header" id="qtdocheader"> <div class="content"> <div id="nav-logo"> <a href="index.html">Home</a></div> <a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a> <div id="narrowsearch"></div> <div id="nav-topright"> <ul> <li class="nav-topright-home"><a href="http://qt.digia.com/">Qt HOME</a></li> <li class="nav-topright-dev"><a href="http://qt-project.org/">DEV</a></li> <li class="nav-topright-doc nav-topright-doc-active"><a href="http://qt-project.org/doc/"> DOC</a></li> <li class="nav-topright-blog"><a href="http://blog.qt.digia.com/">BLOG</a></li> </ul> </div> <div id="shortCut"> <ul> <li class="shortCut-topleft-inactive"><span><a href="index.html">Qt 4.8</a></span></li> <li class="shortCut-topleft-active"><a href="http://qt-project.org/doc/">ALL VERSIONS </a></li> </ul> </div> <ul class="sf-menu" id="narrowmenu"> <li><a href="#">API Lookup</a> <ul> <li><a href="classes.html">Class index</a></li> <li><a href="functions.html">Function index</a></li> <li><a href="modules.html">Modules</a></li> <li><a href="namespaces.html">Namespaces</a></li> <li><a href="qtglobal.html">Global Declarations</a></li> <li><a href="qdeclarativeelements.html">QML elements</a></li> </ul> </li> <li><a href="#">Qt Topics</a> <ul> <li><a href="qt-basic-concepts.html">Programming with Qt</a></li> <li><a href="qtquick.html">Device UIs & Qt Quick</a></li> <li><a href="qt-gui-concepts.html">UI Design with Qt</a></li> <li><a href="supported-platforms.html">Supported Platforms</a></li> <li><a href="technology-apis.html">Qt and Key Technologies</a></li> <li><a href="best-practices.html">How-To's and Best Practices</a></li> </ul> </li> <li><a href="#">Examples</a> <ul> <li><a href="all-examples.html">Examples</a></li> <li><a href="tutorials.html">Tutorials</a></li> <li><a href="demos.html">Demos</a></li> <li><a href="qdeclarativeexamples.html">QML Examples</a></li> </ul> </li> </ul> </div> </div> <div class="wrapper"> <div class="hd"> <span></span> </div> <div class="bd group"> <div class="sidebar"> <div class="searchlabel"> Search index:</div> <div class="search" id="sidebarsearch"> <form id="qtdocsearch" action="" onsubmit="return false;"> <fieldset> <input type="text" name="searchstring" id="pageType" value="" /> <div id="resultdialog"> <a href="#" id="resultclose">Close</a> <p id="resultlinks" class="all"><a href="#" id="showallresults">All</a> | <a href="#" id="showapiresults">API</a> | <a href="#" id="showarticleresults">Articles</a> | <a href="#" id="showexampleresults">Examples</a></p> <p id="searchcount" class="all"><span id="resultcount"></span><span id="apicount"></span><span id="articlecount"></span><span id="examplecount"></span> results:</p> <ul id="resultlist" class="all"> </ul> </div> </fieldset> </form> </div> <div class="box first bottombar" id="lookup"> <h2 title="API Lookup"><span></span> API Lookup</h2> <div id="list001" class="list"> <ul id="ul001" > <li class="defaultLink"><a href="classes.html">Class index</a></li> <li class="defaultLink"><a href="functions.html">Function index</a></li> <li class="defaultLink"><a href="modules.html">Modules</a></li> <li class="defaultLink"><a href="namespaces.html">Namespaces</a></li> <li class="defaultLink"><a href="qtglobal.html">Global Declarations</a></li> <li class="defaultLink"><a href="qdeclarativeelements.html">QML elements</a></li> </ul> </div> </div> <div class="box bottombar" id="topics"> <h2 title="Qt Topics"><span></span> Qt Topics</h2> <div id="list002" class="list"> <ul id="ul002" > <li class="defaultLink"><a href="qt-basic-concepts.html">Programming with Qt</a></li> <li class="defaultLink"><a href="qtquick.html">Device UIs & Qt Quick</a></li> <li class="defaultLink"><a href="qt-gui-concepts.html">UI Design with Qt</a></li> <li class="defaultLink"><a href="supported-platforms.html">Supported Platforms</a></li> <li class="defaultLink"><a href="technology-apis.html">Qt and Key Technologies</a></li> <li class="defaultLink"><a href="best-practices.html">How-To's and Best Practices</a></li> </ul> </div> </div> <div class="box" id="examples"> <h2 title="Examples"><span></span> Examples</h2> <div id="list003" class="list"> <ul id="ul003"> <li class="defaultLink"><a href="all-examples.html">Examples</a></li> <li class="defaultLink"><a href="tutorials.html">Tutorials</a></li> <li class="defaultLink"><a href="demos.html">Demos</a></li> <li class="defaultLink"><a href="qdeclarativeexamples.html">QML Examples</a></li> </ul> </div> </div> </div> <div class="wrap"> <div class="toolbar"> <div class="breadcrumb toolblock"> <ul> <li class="first"><a href="index.html">Home</a></li> <!-- Breadcrumbs go here --> <li><a href="qdeclarativeelements.html">QML Elements</a></li> <li>QML FolderListModel Element</li> </ul> </div> <div class="toolbuttons toolblock"> <ul> <li id="smallA" class="t_button">A</li> <li id="medA" class="t_button active">A</li> <li id="bigA" class="t_button">A</li> <li id="print" class="t_button"><a href="javascript:this.print();"> <span>Print</span></a></li> </ul> </div> </div> <div class="content mainContent"> <div class="toc"> <h3><a name="toc">Contents</a></h3> <ul> <li class="level1"><a href="#properties">Properties</a></li> <li class="level1"><a href="#methods">Methods</a></li> <li class="level1"><a href="#details">Detailed Description</a></li> <li class="level2"><a href="#filtering">Filtering</a></li> <li class="level2"><a href="#example-usage">Example Usage</a></li> <li class="level2"><a href="#path-separators">Path Separators</a></li> </ul> </div> <h1 class="title">QML FolderListModel Element</h1> <span class="subtitle"></span> <!-- $$$FolderListModel-brief --> <p>The FolderListModel provides a model of the contents of a file system folder. <a href="#details">More...</a></p> <!-- @@@FolderListModel --> <ul> <li><a href="qml-folderlistmodel-members.html">List of all members, including inherited members</a></li> </ul> <a name="properties"></a> <h2>Properties</h2> <ul> <li class="fn"><b><b><a href="qml-folderlistmodel.html#count-prop">count</a></b></b> : int</li> <li class="fn"><b><b><a href="qml-folderlistmodel.html#folder-prop">folder</a></b></b> : string</li> <li class="fn"><b><b><a href="qml-folderlistmodel.html#nameFilters-prop">nameFilters</a></b></b> : list<string></li> <li class="fn"><b><b><a href="qml-folderlistmodel.html#parentFolder-prop">parentFolder</a></b></b> : url</li> <li class="fn"><b><b><a href="qml-folderlistmodel.html#showDirs-prop">showDirs</a></b></b> : bool</li> <li class="fn"><b><b><a href="qml-folderlistmodel.html#showDotAndDotDot-prop">showDotAndDotDot</a></b></b> : bool</li> <li class="fn"><b><b><a href="qml-folderlistmodel.html#showOnlyReadable-prop">showOnlyReadable</a></b></b> : bool</li> <li class="fn"><b><b><a href="qml-folderlistmodel.html#sortField-prop">sortField</a></b></b> : enumeration</li> <li class="fn"><b><b><a href="qml-folderlistmodel.html#sortReversed-prop">sortReversed</a></b></b> : bool</li> </ul> <a name="methods"></a> <h2>Methods</h2> <ul> <li class="fn"><b><b><a href="qml-folderlistmodel.html#isFolder-method">isFolder</a></b></b></li> </ul> <!-- $$$FolderListModel-description --> <a name="details"></a> <h2>Detailed Description</h2> <p>FolderListModel provides access to information about the contents of a folder in the local file system, exposing a list of files to views and other data components.</p> <p><b>Note:</b> This type is made available by importing the <tt>Qt.labs.folderlistmodel</tt> module. <i>Elements in the Qt.labs module are not guaranteed to remain compatible in future versions.</i></p> <p><b>import Qt.labs.folderlistmodel 1.0</b></p> <p>The <a href="qml-folderlistmodel.html#folder-prop">folder</a> property specifies the folder to access. Information about the files and directories in the folder is supplied via the model's interface. Components access names and paths via the following roles:</p> <ul> <li>fileName</li> <li>filePath</li> </ul> <p>Additionally a file entry can be differentiated from a folder entry via the <a href="qml-folderlistmodel.html#isFolder-method">isFolder()</a> method.</p> <a name="filtering"></a> <h2>Filtering</h2> <p>Various properties can be set to filter the number of files and directories exposed by the model.</p> <p>The <a href="qml-folderlistmodel.html#nameFilters-prop">nameFilters</a> property can be set to contain a list of wildcard filters that are applied to names of files and directories, causing only those that match the filters to be exposed.</p> <p>Directories can be included or excluded using the <a href="qml-folderlistmodel.html#showDirs-prop">showDirs</a> property, and navigation directories can also be excluded by setting the <a href="qml-folderlistmodel.html#showDotAndDotDot-prop">showDotAndDotDot</a> property to false.</p> <p>It is sometimes useful to limit the files and directories exposed to those that the user can access. The <a href="qml-folderlistmodel.html#showOnlyReadable-prop">showOnlyReadable</a> property can be set to enable this feature.</p> <a name="example-usage"></a> <h2>Example Usage</h2> <p>The following example shows a FolderListModel being used to provide a list of QML files in a <a href="qml-listview.html">ListView</a>:</p> <pre class="qml"> import QtQuick 1.0 import Qt.labs.folderlistmodel 1.0 <span class="type"><a href="qml-listview.html">ListView</a></span> { <span class="name">width</span>: <span class="number">200</span>; <span class="name">height</span>: <span class="number">400</span> <span class="type">FolderListModel</span> { <span class="name">id</span>: <span class="name">folderModel</span> <span class="name">nameFilters</span>: [<span class="string">"*.qml"</span>] } <span class="type"><a href="qml-component.html">Component</a></span> { <span class="name">id</span>: <span class="name">fileDelegate</span> <span class="type"><a href="qml-text.html">Text</a></span> { <span class="name">text</span>: <span class="name">fileName</span> } } <span class="name">model</span>: <span class="name">folderModel</span> <span class="name">delegate</span>: <span class="name">fileDelegate</span> }</pre> <a name="path-separators"></a> <h2>Path Separators</h2> <p>Qt uses "/" as a universal directory separator in the same way that "/" is used as a path separator in URLs. If you always use "/" as a directory separator, Qt will translate your paths to conform to the underlying operating system.</p> <p><b>See also </b><a href="qdeclarativemodels.html">QML Data Models</a>.</p> <!-- @@@FolderListModel --> <h2>Property Documentation</h2> <!-- $$$count --> <div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlPropNode"><p><a name="count-prop"></a><span class="qmlreadonly">read-only</span><span class="name">count</span> : <span class="type"><a href="qml-int.html">int</a></span></p></td></tr></table></div><div class="qmldoc"><p>Returns the number of items in the current folder that match the filter criteria.</p> </div></div><!-- @@@count --> <br/> <!-- $$$folder --> <div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlPropNode"><p><a name="folder-prop"></a><span class="name">folder</span> : <span class="type"><a href="qml-string.html">string</a></span></p></td></tr></table></div><div class="qmldoc"><p>The <i>folder</i> property holds a URL for the folder that the model is currently providing.</p> <p>The value is a URL expressed as a string, and must be a <tt>file</tt>: or <tt>qrc</tt>: URL, or a relative URL.</p> <p>By default, the value is an invalid URL.</p> </div></div><!-- @@@folder --> <br/> <!-- $$$nameFilters --> <div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlPropNode"><p><a name="nameFilters-prop"></a><span class="name">nameFilters</span> : <span class="type"><a href="qml-list.html">list</a></span><<span class="type"><a href="qml-string.html">string</a></span>></p></td></tr></table></div><div class="qmldoc"><p>The <i>nameFilters</i> property contains a list of file name filters. The filters may include the ? and * wildcards.</p> <p>The example below filters on PNG and JPEG files:</p> <pre class="qml"> <span class="type"><a href="qml-folderlistmodel.html">FolderListModel</a></span> { <span class="name">nameFilters</span>: [ <span class="string">"*.png"</span>, <span class="string">"*.jpg"</span> ] }</pre> <p><b>Note:</b> Directories are not excluded by filters.</p> </div></div><!-- @@@nameFilters --> <br/> <!-- $$$parentFolder --> <div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlPropNode"><p><a name="parentFolder-prop"></a><span class="qmlreadonly">read-only</span><span class="name">parentFolder</span> : <span class="type"><a href="qml-url.html">url</a></span></p></td></tr></table></div><div class="qmldoc"><p>Returns the URL of the parent of of the current <a href="qml-folderlistmodel.html#folder-prop">folder</a>.</p> </div></div><!-- @@@parentFolder --> <br/> <!-- $$$showDirs --> <div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlPropNode"><p><a name="showDirs-prop"></a><span class="name">showDirs</span> : <span class="type"><a href="qml-bool.html">bool</a></span></p></td></tr></table></div><div class="qmldoc"><p>If true, directories are included in the model; otherwise only files are included.</p> <p>By default, this property is true.</p> <p>Note that the <a href="qml-folderlistmodel.html#nameFilters-prop">nameFilters</a> are not applied to directories.</p> <p><b>See also </b><a href="qml-folderlistmodel.html#showDotAndDotDot-prop">showDotAndDotDot</a>.</p> </div></div><!-- @@@showDirs --> <br/> <!-- $$$showDotAndDotDot --> <div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlPropNode"><p><a name="showDotAndDotDot-prop"></a><span class="name">showDotAndDotDot</span> : <span class="type"><a href="qml-bool.html">bool</a></span></p></td></tr></table></div><div class="qmldoc"><p>If true, the "." and ".." directories are included in the model; otherwise they are excluded.</p> <p>By default, this property is false.</p> <p><b>See also </b><a href="qml-folderlistmodel.html#showDirs-prop">showDirs</a>.</p> </div></div><!-- @@@showDotAndDotDot --> <br/> <!-- $$$showOnlyReadable --> <div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlPropNode"><p><a name="showOnlyReadable-prop"></a><span class="name">showOnlyReadable</span> : <span class="type"><a href="qml-bool.html">bool</a></span></p></td></tr></table></div><div class="qmldoc"><p>If true, only readable files and directories are shown; otherwise all files and directories are shown.</p> <p>By default, this property is false.</p> <p><b>See also </b><a href="qml-folderlistmodel.html#showDirs-prop">showDirs</a>.</p> </div></div><!-- @@@showOnlyReadable --> <br/> <!-- $$$sortField --> <div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlPropNode"><p><a name="sortField-prop"></a><span class="name">sortField</span> : <span class="type"><a href="qml-enumeration.html">enumeration</a></span></p></td></tr></table></div><div class="qmldoc"><p>The <i>sortField</i> property contains field to use for sorting. sortField may be one of:</p> <ul> <li>Unsorted - no sorting is applied. The order is system default.</li> <li>Name - sort by filename</li> <li>Time - sort by time modified</li> <li>Size - sort by file size</li> <li>Type - sort by file type (extension)</li> </ul> <p><b>See also </b><a href="qml-folderlistmodel.html#sortReversed-prop">sortReversed</a>.</p> </div></div><!-- @@@sortField --> <br/> <!-- $$$sortReversed --> <div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlPropNode"><p><a name="sortReversed-prop"></a><span class="name">sortReversed</span> : <span class="type"><a href="qml-bool.html">bool</a></span></p></td></tr></table></div><div class="qmldoc"><p>If set to true, reverses the sort order. The default is false.</p> <p><b>See also </b><a href="qml-folderlistmodel.html#sortField-prop">sortField</a>.</p> </div></div><!-- @@@sortReversed --> <br/> <h2>Method Documentation</h2> <!-- $$$isFolder --> <div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlFuncNode"><p><a name="isFolder-method"></a><span class="type"><a href="qml-bool.html">bool</a></span> FolderListModel::<span class="name">isFolder</span> ( <span class="type"><a href="qml-int.html">int</a></span> <i>index</i> )</p></td></tr></table></div><div class="qmldoc"><p>Returns true if the entry <i>index</i> is a folder; otherwise returns false.</p> </div></div><!-- @@@isFolder --> <br/> </div> </div> </div> <div class="ft"> <span></span> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2013 Digia Plc and/or its subsidiaries. Documentation contributions included herein are the copyrights of their respective owners.</p> <br /> <p> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.</p> <p> Documentation sources may be obtained from <a href="http://www.qt-project.org"> www.qt-project.org</a>.</p> <br /> <p> Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide. All other trademarks are property of their respective owners. <a title="Privacy Policy" href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p> </div> <script src="scripts/functions.js" type="text/javascript"></script> </body> </html>