Начиная с Qt5.5, у нас есть TreeView
компонент QML,
main.qml
:
import QtQuick.Controls 1.4
TreeView {
anchors.fill: parent
TableViewColumn {
title: "Name"
role: "fileName"
width: 300
}
model: my_model
}
main.cpp
QFileSystemModel model;
model.setRootPath("/");
QQmlApplicationEngine engine;
engine.rootContext()->setContextProperty("my_model", &model);
engine.load(QUrl(QStringLiteral("qrc:/main.qml")));