![]() |
Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
|
#include "qquicktreeview_p_p.h"
#include <QtCore/qobject.h>
#include <QtQml/qqmlcontext.h>
#include <QtQuick/private/qquicktaphandler_p.h>
#include <QtQmlModels/private/qqmltreemodeltotablemodel_p_p.h>
#include "moc_qquicktreeview_p.cpp"
Go to the source code of this file.
Variables | |
static const int | kTreeColumn = 0 |
\qmlproperty QModelIndex QtQuick::TreeView::rootIndex |
|
static |
\qmlproperty QModelIndex QtQuick::TreeView::rootIndex
\qmltype TreeView \inqmlmodule QtQuick \ingroup qtquick-views \since 6.3 \inherits TableView \brief Provides a tree view to display data from a QAbstractItemModel. A TreeView has a \l model that defines the data to be displayed, and a \l delegate that defines how the data should be displayed. TreeView inherits \l TableView. This means that, despite the model has a parent-child tree structure, TreeView is internally using a proxy model that converts that structure into a flat table model that can be rendered by TableView. Each node in the tree ends up occupying one row in the table, where the first column renders the tree itself. By indenting each delegate item in that column according to its parent-child depth in the model, it will end up looking like a tree, even if it's technically still just a flat list of items. \section2 Declare a TreeView TreeView is a data bound control, so it cannot show anything without a data model. You cannot declare tree nodes in QML. When you declare a TreeView, you need to specify: \list \li \b{A data model}. TreeView can work with data models that derive from \l QAbstractItemModel. \li \b{A delegate}. A delegate is a template that specifies how the tree nodes are displayed in the UI. \endlist \qml TreeView {
The model needs to be a QAbstractItemModel model: myTreeModel You can set a custom delegate or use a built-in TreeViewDelegate delegate: TreeViewDelegate {} } \endqml
Definition at line 295 of file qquicktreeview.cpp.