2022-05-13 13:12:05 +00:00
|
|
|
// Copyright (C) 2021 The Qt Company Ltd.
|
2024-02-22 14:51:16 +00:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
|
2021-11-19 15:58:36 +00:00
|
|
|
|
|
|
|
#include <QtQuick/qquickview.h>
|
|
|
|
#include <QtQuick/qquickwindow.h>
|
|
|
|
#include <QtQml/qqmlapplicationengine.h>
|
|
|
|
#include <QtQml/qqmlcontext.h>
|
|
|
|
|
|
|
|
#include <QtQuick/private/qquicktreeview_p.h>
|
|
|
|
#include <QtQuick/private/qquicktreeview_p_p.h>
|
|
|
|
|
|
|
|
#include <QtGui/qguiapplication.h>
|
|
|
|
|
|
|
|
#ifdef QT_WIDGETS_LIB
|
|
|
|
#include <QtWidgets/qapplication.h>
|
2021-11-19 16:00:10 +00:00
|
|
|
#include <QtGui/qfilesystemmodel.h>
|
2021-11-19 15:58:36 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "testmodel.h"
|
|
|
|
|
|
|
|
int main(int c, char **args) {
|
|
|
|
#ifdef QT_WIDGETS_LIB
|
|
|
|
QApplication app(c, args);
|
|
|
|
#else
|
|
|
|
QGuiApplication app(c, args);
|
|
|
|
#endif
|
|
|
|
|
2021-11-19 16:00:10 +00:00
|
|
|
QFileSystemModel model;
|
2024-02-01 19:30:50 +00:00
|
|
|
model.setIconProvider(nullptr); // save time: we don't need icons
|
2021-11-19 16:00:10 +00:00
|
|
|
model.setRootPath("/");
|
|
|
|
|
2021-11-19 15:58:36 +00:00
|
|
|
QQmlApplicationEngine engine("qrc:data/treeview.qml");
|
2021-11-19 16:00:10 +00:00
|
|
|
engine.rootContext()->setContextProperty("fileSystemModel", &model);
|
|
|
|
|
2021-11-19 15:58:36 +00:00
|
|
|
QQuickWindow *window = static_cast<QQuickWindow *>(engine.rootObjects().at(0));
|
|
|
|
auto treeView = window->property("treeView").value<QQuickTreeView *>();
|
|
|
|
treeView->expand(0);
|
|
|
|
|
|
|
|
return app.exec();
|
|
|
|
}
|