2022-05-10 10:06:48 +00:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QStandardItemModel>
|
|
|
|
#include <QFile>
|
2017-11-10 20:36:27 +00:00
|
|
|
#include <QTextStream>
|
2011-04-27 10:05:43 +00:00
|
|
|
|
|
|
|
#include "freezetablewidget.h"
|
|
|
|
|
2012-11-22 12:40:51 +00:00
|
|
|
int main(int argc, char* argv[])
|
2011-04-27 10:05:43 +00:00
|
|
|
{
|
2012-11-22 12:40:51 +00:00
|
|
|
Q_INIT_RESOURCE(grades);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2012-11-22 12:40:51 +00:00
|
|
|
QApplication app( argc, argv );
|
|
|
|
QStandardItemModel *model=new QStandardItemModel();
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2012-11-22 12:40:51 +00:00
|
|
|
QFile file(":/grades.txt");
|
|
|
|
if (file.open(QFile::ReadOnly)) {
|
2017-11-10 20:36:27 +00:00
|
|
|
QTextStream stream(&file);
|
|
|
|
|
|
|
|
QString line = stream.readLine();
|
2015-10-13 07:06:58 +00:00
|
|
|
QStringList list = line.simplified().split(',');
|
2012-11-22 12:40:51 +00:00
|
|
|
model->setHorizontalHeaderLabels(list);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2012-11-22 12:40:51 +00:00
|
|
|
int row = 0;
|
2019-09-06 21:24:56 +00:00
|
|
|
QStandardItem *newItem = nullptr;
|
2017-11-10 20:36:27 +00:00
|
|
|
while (!stream.atEnd()) {
|
|
|
|
line = stream.readLine();
|
2015-10-13 07:06:58 +00:00
|
|
|
if (!line.startsWith('#') && line.contains(',')) {
|
|
|
|
list = line.simplified().split(',');
|
2012-11-22 12:40:51 +00:00
|
|
|
for (int col = 0; col < list.length(); ++col){
|
|
|
|
newItem = new QStandardItem(list.at(col));
|
|
|
|
model->setItem(row, col, newItem);
|
|
|
|
}
|
|
|
|
++row;
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
2012-11-22 12:40:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
file.close();
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2012-11-22 12:40:51 +00:00
|
|
|
FreezeTableWidget *tableView = new FreezeTableWidget(model);
|
2011-04-27 10:05:43 +00:00
|
|
|
|
2012-11-22 12:40:51 +00:00
|
|
|
tableView->setWindowTitle(QObject::tr("Frozen Column Example"));
|
|
|
|
tableView->resize(560, 680);
|
|
|
|
tableView->show();
|
|
|
|
return app.exec();
|
2011-04-27 10:05:43 +00:00
|
|
|
}
|
|
|
|
|