<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html> <html lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- qtquickcontrols-examples.qdoc --> <title>Qt Quick Controls - Table View Example | Qt Quick Controls 5.11</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 ><a href="../qtdoc/index.html">Qt 5.11</a></td><td ><a href="qtquickcontrols-index.html">Qt Quick Controls</a></td><td ><a href="qtquickcontrols-examples.html">Qt Quick Controls Examples</a></td><td >Qt Quick Controls - Table View Example</td></tr></table><table class="buildversion"><tr> <td id="buildversion" width="100%" align="right">Qt 5.11.2 Reference Documentation</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="#running-the-example">Running the Example</a></li> </ul> </div> <div class="sidebar-content" id="sidebar-content"></div></div> <h1 class="title">Qt Quick Controls - Table View Example</h1> <span class="subtitle"></span> <!-- $$$tableview-brief --> <p>An example for the <a href="qml-qtquick-controls-tableview.html">TableView</a> control.</p> <!-- @@@tableview --> <!-- $$$tableview-description --> <div class="descr"> <a name="details"></a> <p class="centerAlign"><img src="images/qtquickcontrols-example-tableview.png" alt="" /></p><p>This example project demonstrates the usage of <a href="qml-qtquick-controls-tableview.html">TableView</a> from <a href="qtquickcontrols-index.html">Qt Quick Controls</a> - a control to display one or more columns of information from a data list model. The example includes a model that supports sorting and filtering.</p> <p>The C++ class, SortFilterProxyModel, is registered as a QML type under the namespace, "<code>org.qtproject.example 1.0</code>".</p> <p>The following snippets show how the type is registered under a namespace and later imported by <i>main.qml</i>.</p> <p>QML type registration:</p> <pre class="cpp"> <span class="preprocessor">#include <QtQml/qqml.h></span> <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span> qmlRegisterType<span class="operator"><</span>SortFilterProxyModel<span class="operator">></span>(<span class="string">"org.qtproject.example"</span><span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="string">"SortFilterProxyModel"</span>); <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span> </pre> <p>QML namespace import:</p> <pre class="cpp"> import org<span class="operator">.</span>qtproject<span class="operator">.</span>example <span class="number">1.0</span> </pre> <p>For more information about registering C++ classes as QML types, see <a href="../qtqml/qtqml-cppintegration-overview.html#defining-qml-types-from-c">Defining QML Types from C++</a>.</p> <a name="running-the-example"></a> <h2 id="running-the-example">Running the Example</h2> <p>To run the example from <a href="http://doc.qt.io/qtcreator/index.html">Qt Creator</a>, open the <b>Welcome</b> mode and select the example from <b>Examples</b>. For more information, visit <a href="http://doc.qt.io/qtcreator/creator-build-example-application.html">Building and Running an Example</a>.</p> <p>Files:</p> <ul> <li><a href="qtquickcontrols-tableview-main-qml.html">tableview/main.qml</a></li> <li><a href="qtquickcontrols-tableview-src-main-cpp.html">tableview/src/main.cpp</a></li> <li><a href="qtquickcontrols-tableview-src-sortfilterproxymodel-cpp.html">tableview/src/sortfilterproxymodel.cpp</a></li> <li><a href="qtquickcontrols-tableview-src-sortfilterproxymodel-h.html">tableview/src/sortfilterproxymodel.h</a></li> <li><a href="qtquickcontrols-tableview-tableview-pro.html">tableview/tableview.pro</a></li> <li><a href="qtquickcontrols-tableview-tableview-qrc.html">tableview/tableview.qrc</a></li> </ul> </div> <!-- @@@tableview --> </div> </div> </div> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2018 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>