<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- qqmldelegatecomponent.cpp --> <title>DelegateChooser QML Type | Qt QML 5.12.6</title> <link rel="stylesheet" type="text/css" href="style/offline-simple.css" /> <script type="text/javascript"> document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css"); // loading style sheet breaks anchors that were jumped to before // so force jumping to anchor again setTimeout(function() { var anchor = location.hash; // need to jump to different anchor first (e.g. none) location.hash = "#"; setTimeout(function() { location.hash = anchor; }, 0); }, 0); </script> </head> <body> <div class="header" id="qtdocheader"> <div class="main"> <div class="main-rounded"> <div class="navigationbar"> <table><tr> <td >Qt 5.12</td><td ><a href="qtqml-index.html">Qt QML</a></td><td ><a href="qtqml-qmlmodule.html">QML Types</a></td><td >DelegateChooser QML Type</td></tr></table><table class="buildversion"><tr> <td id="buildversion" width="100%" align="right"><a href="qtqml-index.html">Qt 5.12.6 Reference Documentation</a></td> </tr></table> </div> </div> <div class="content"> <div class="line"> <div class="content mainContent"> <div class="sidebar"> <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="#details">Detailed Description</a></li> </ul> </div> <div class="sidebar-content" id="sidebar-content"></div></div> <h1 class="title">DelegateChooser QML Type</h1> <span class="subtitle"></span> <!-- $$$DelegateChooser-brief --> <p>Allows a view to use different delegates for different types of items in the model. <a href="#details">More...</a></p> <!-- @@@DelegateChooser --> <div class="table"><table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> Import Statement:</td><td class="memItemRight bottomAlign"> import Qt.labs.qmlmodels 1.0</td></tr></table></div><ul> <li><a href="qml-qt-labs-qmlmodels-delegatechooser-members.html">List of all members, including inherited members</a></li> </ul> <a name="properties"></a> <h2 id="properties">Properties</h2> <ul> <li class="fn"><b><b><a href="qml-qt-labs-qmlmodels-delegatechooser.html#choices-prop">choices</a></b></b> : list<DelegateChoice></li> <li class="fn"><b><b><a href="qml-qt-labs-qmlmodels-delegatechooser.html#role-prop">role</a></b></b> : string</li> </ul> <!-- $$$DelegateChooser-description --> <a name="details"></a> <h2 id="details">Detailed Description</h2> <p>The <a href="qml-qt-labs-qmlmodels-delegatechooser.html">DelegateChooser</a> is a special <a href="qml-qtqml-component.html">Component</a> type intended for those scenarios where a Component is required by a view and used as a delegate. <a href="qml-qt-labs-qmlmodels-delegatechooser.html">DelegateChooser</a> encapsulates a set of <a href="qml-qt-labs-qmlmodels-delegatechoice.html">DelegateChoice</a>s. These choices are used to determine the delegate that will be instantiated for each item in the model. The selection of the choice is performed based on the value that a model item has for <a href="qml-qt-labs-qmlmodels-delegatechooser.html#role-prop">role</a>, and also based on index.</p> <p><a href="qml-qt-labs-qmlmodels-delegatechooser.html">DelegateChooser</a> is commonly used when a view needs to display a set of delegates that are significantly different from each other. For example, a typical phone settings view might include toggle switches, sliders, radio buttons, and other visualizations based on the type of each setting. In this case, <a href="qml-qt-labs-qmlmodels-delegatechooser.html">DelegateChooser</a> could provide an easy way to associate a different type of delegate with each setting:</p> <pre class="qml"> </pre> <p><b>Note: </b>This type is intended to transparently work only with TableView and any <a href="qml-qtqml-models-delegatemodel.html">DelegateModel</a>-based view. Views (including user-defined views) that aren't internally based on a <a href="qml-qtqml-models-delegatemodel.html">DelegateModel</a> need to explicitly support this type of component to make it function as described.</p><p><b>See also </b><a href="qml-qt-labs-qmlmodels-delegatechoice.html">DelegateChoice</a>.</p> <!-- @@@DelegateChooser --> <h2>Property Documentation</h2> <!-- $$$choices --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="choices-prop"> <td class="tblQmlPropNode"><p> <a name="choices-prop"></a><span class="qmldefault">[default] </span><span class="name">choices</span> : <span class="type"><a href="qml-list.html">list</a></span><<span class="type"><a href="qml-qt-labs-qmlmodels-delegatechoice.html">DelegateChoice</a></span>></p></td></tr> </table></div> </div><div class="qmldoc"><p>The list of DelegateChoices for the chooser.</p> <p>The list is treated as an ordered list, where the first <a href="qml-qt-labs-qmlmodels-delegatechoice.html">DelegateChoice</a> to match will be used be a view.</p> <p>It should not generally be necessary to refer to the <code>choices</code> property, as it is the default property for <a href="qml-qt-labs-qmlmodels-delegatechooser.html">DelegateChooser</a> and thus all child items are automatically assigned to this property.</p> </div></div><!-- @@@choices --> <br/> <!-- $$$role --> <div class="qmlitem"><div class="qmlproto"> <div class="table"><table class="qmlname"> <tr valign="top" class="odd" id="role-prop"> <td class="tblQmlPropNode"><p> <a name="role-prop"></a><span class="name">role</span> : <span class="type"><a href="qml-string.html">string</a></span></p></td></tr> </table></div> </div><div class="qmldoc"><p>This property holds the role used to determine the delegate for a given model item.</p> <p><b>See also </b><a href="qml-qt-labs-qmlmodels-delegatechoice.html">DelegateChoice</a>.</p> </div></div><!-- @@@role --> <br/> </div> </div> </div> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2019 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners.<br/> 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.<br/> Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners. </p> </div> </body> </html>