aboutsummaryrefslogtreecommitdiffstats
path: root/tests/manual/treeview/sidebyside/main.cpp
blob: 25b598b703fb1ab32ace37ebc72e424c2ec685c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// 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 <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>
#include <QtGui/qfilesystemmodel.h>
#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<QQuickWindow *>(engine.rootObjects().at(0));
    auto treeView = window->property("treeView").value<QQuickTreeView *>();
    treeView->expand(0);

    return app.exec();
}