-
Notifications
You must be signed in to change notification settings - Fork 0
/
datadialog.cpp
62 lines (52 loc) · 1.63 KB
/
datadialog.cpp
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#pragma execution_character_set("utf-8")
#include "datadialog.h"
#include "ui_datadialog.h"
DataDialog::DataDialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::DataDialog)
{
this->setWindowTitle("数据点");
ui->setupUi(this);
aItemModel = new QStandardItemModel();
ui->tableView->setModel(aItemModel);
}
DataDialog::~DataDialog()
{
delete ui;
delete aItemModel;
}
void DataDialog::AddColumn(QString name,QVector<QPointF> data)
{
qDebug()<<"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"<<data.size();
QList<QStandardItem*> aItemList;
QList<QStandardItem*> aItemList_2;
QStandardItem *aItem;
aItem = new QStandardItem();
aItem->setData(name,Qt::DisplayRole);
aItemList.append(aItem);
name ="差值";
aItem = new QStandardItem();
aItem->setData(name,Qt::DisplayRole);
aItemList_2.append(aItem);
QString str;
for(auto itor = data.begin();itor<data.end();itor++)
{
aItem = new QStandardItem();
str ="(";
str.append(QString::number(itor->rx(),'f',3));
str.append(",");
str.append(QString::number(itor->ry(),'f',3));
str.append(")");
aItem->setData(str,Qt::DisplayRole);
aItemList.append(aItem);
aItem = new QStandardItem();
if(itor!=data.begin())
{
str = QString::number((*itor-*(itor-1)).y(),'f',3);
aItem->setData(str,Qt::DisplayRole);
}
aItemList_2.append(aItem);
}
aItemModel->insertColumn(aItemModel->columnCount(),aItemList);
aItemModel->insertColumn(aItemModel->columnCount(),aItemList_2);
}