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 pathgrouplistwindow.cpp
More file actions
53 lines (44 loc) · 1.35 KB
/
grouplistwindow.cpp
File metadata and controls
53 lines (44 loc) · 1.35 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
46
47
48
49
50
51
52
53
#include "grouplistwindow.h"
#include "ui_grouplistwindow.h"
#include "comm.h"
#include <QDebug>
#include "groupinfowindow.h"
GroupListWindow::GroupListWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::GroupListWindow)
{
ui->setupUi(this);
table = ui->tableView;
model = new GroupListTableModel(this);
model->setGroupInfos(g_groups);
table->setModel(model);
// 隐藏行表头
table->verticalHeader()->setHidden(true);
// 第三列自动伸缩
table->horizontalHeader()->setResizeMode(2, QHeaderView::Stretch);
// 当行选择
table->setSelectionBehavior(QAbstractItemView::SelectRows);
table->setSelectionMode(QAbstractItemView::SingleSelection);
// 自适应数据大小
table->resizeColumnsToContents();
table->resizeRowsToContents();
connect(table, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(rowDoubleClicket(QModelIndex)));
}
GroupListWindow::~GroupListWindow()
{
delete ui;
delete model;
}
void GroupListWindow::updateTable()
{
model->setGroupInfos(g_groups);
}
void GroupListWindow::rowDoubleClicket(const QModelIndex &index)
{
int row = index.row();
qDebug() << "double clicked row:" << row;
if (row >= g_groups->size()) return;
TargetGroup *grp = g_groups->at(row);
GroupInfoWindow *infoWin = new GroupInfoWindow(grp, this);
infoWin->show();
}