summaryrefslogtreecommitdiffstats
path: root/examples/widgets/itemviews/storageview/main.cpp
blob: 3bd5392736a22fb3bb9b0b2ba64380091887390d (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
// Copyright (C) 2016 The Qt Company Ltd.
// Copyright (C) 2016 Ivan Komissarov
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

#include <QApplication>
#include <QShortcut>
#include <QTreeView>

#include "storagemodel.h"

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QTreeView view;
    view.resize(640, 480);
    view.setWindowTitle("Storage View");
    view.setSelectionBehavior(QAbstractItemView::SelectRows);

    StorageModel *model = new StorageModel(&view);
    model->refresh();
    QShortcut *refreshShortcut = new QShortcut(QKeySequence::Refresh, &view);
    QObject::connect(refreshShortcut, &QShortcut::activated, model, &StorageModel::refresh);
    view.setModel(model);

    int columnCount = view.model()->columnCount();
    for (int c = 0; c < columnCount; ++c)
        view.resizeColumnToContents(c);
    view.show();

    return a.exec();
}