// Copyright (C) 2021 The Qt Company Ltd. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include #include #include #include #include #include #include #ifdef QT_WIDGETS_LIB #include #include #endif #include "testmodel.h" int main(int c, char **args) { #ifdef QT_WIDGETS_LIB QApplication app(c, args); #else QGuiApplication app(c, args); #endif QFileSystemModel model; model.setRootPath("/"); QQmlApplicationEngine engine("qrc:data/treeview.qml"); engine.rootContext()->setContextProperty("fileSystemModel", &model); QQuickWindow *window = static_cast(engine.rootObjects().at(0)); auto treeView = window->property("treeView").value(); treeView->expand(0); return app.exec(); }