This repository was archived by the owner on Apr 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtargetinfowindow.cpp
More file actions
45 lines (40 loc) · 1.51 KB
/
targetinfowindow.cpp
File metadata and controls
45 lines (40 loc) · 1.51 KB
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
#include "targetinfowindow.h"
#include "ui_targetinfowindow.h"
#include <QDebug>
TargetInfoWindow::TargetInfoWindow(SingleTarget *t, QWidget *parent) :
QMainWindow(parent), target(t),
ui(new Ui::TargetInfoWindow)
{
ui->setupUi(this);
table = ui->tableView;
model = new TargetInfoTableModel(t);
table->setModel(model);
// 隐藏行表头
table->verticalHeader()->setHidden(true);
for (int i = 0; i < model->columnCount(QModelIndex()); ++i) {
table->horizontalHeader()->setResizeMode(i, QHeaderView::Stretch);
}
// 当行选择
table->setSelectionBehavior(QAbstractItemView::SelectRows);
table->setSelectionMode(QAbstractItemView::SingleSelection);
table->setAutoScroll(true);
connect(model, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(updateTable(QModelIndex,QModelIndex)));
this->setWindowTitle(QString("目标T%1 详细信息").arg(target->getID()));
ui->targetIDLabel->setText(QString("T%1").arg(target->getID()));
ui->stateNumLabel->setText(QString("%1").arg(target->getStateCount()));
}
TargetInfoWindow::~TargetInfoWindow()
{
delete ui;
delete model;
}
void TargetInfoWindow::updateTable(QModelIndex start, QModelIndex end)
{
if (isTracking) {
ui->targetIDLabel->setText(QString("T%1").arg(target->getID()));
ui->stateNumLabel->setText(QString("%1").arg(target->getStateCount()));
} else {
ui->targetIDLabel->setText(QString("No Such Target..."));
ui->stateNumLabel->setText(QString("NAN"));
}
}