Skip to content
AtlasOSFramework API
Browse the docs

AtlasTreeModel

A read-only tree model built from nested JavaScript objects, for AtlasTreeView.

Since 1.4.0

AtlasTreeModel builds a tree model from nested JS objects, because QML can't build a tree model itself. Use it for a small tree that is static or rebuilt as a whole; an app with a large or live tree writes its own QAbstractItemModel. Feed it to AtlasTreeView or any Qt Quick TreeView.

The model has one column. Its roles are display (the text), symbol (a Symbols value, 0 if none) and icon (an icon name or image url, empty if none). Each item is { text, symbol, icon, children }.

Example

AtlasTreeModel {
    id: tree
    items: [
        { text: "Documents", symbol: Symbols.Folder, children: [
            { text: "Report.odt" }, { text: "Notes.md" } ] },
        { text: "Music" }
    ]
}
AtlasTreeView { model: tree; symbolRole: "symbol" }

Properties

Name Type Default Description
items list<var> [] The tree: a list of { text, symbol, icon, children } objects. Setting it again replaces the whole tree (a view collapses). The depth is limited to 64 levels.