Volker Hilsheimer feadcc6869 Move storageview example into tests/manual
The code is mostly an implementation of a model based on QStorageInfo,
shown in an otherwise uninteresting tree view.

Change-Id: Id6ce70d71ddc9bcd6e82a9ee12f5e1af159eac7a
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
(cherry picked from commit a89f575be3a410a06165dc19961b1a260a67464d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
2023-06-12 19:22:58 +00:00

33 lines
908 B
C++

// 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();
}