#include "mainwindow.h"
#include "ui_mainwindow.h"
#include<QDebug>
#include <QApplication>
#define itemEmpty " "
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
saved = true;
//界面
this->setWindowTitle(tr("学生信息管理系统"));
//菜单
QMenu *file = menuBar()->addMenu(tr("&文件"));
newAction = new QAction(tr("新建..."),this);
connect(newAction,SIGNAL(triggered()),this,SLOT(newFile()));
file->addAction(newAction);
openAction = new QAction(tr("打开..."),this);
//openAction->setStatusTip(tr("1234"));
connect(openAction,SIGNAL(triggered()),this,SLOT(openFile()));
file->addAction(openAction);
saveAction = new QAction(tr("保存..."),this);
connect(saveAction,SIGNAL(triggered()),this,SLOT(saveFile()));
file->addAction(saveAction);
QMenu *modify = menuBar()->addMenu(tr("&编辑"));
addAction = new QAction(tr("增加一行"),this);
connect(addAction,SIGNAL(triggered()),this,SLOT(addModify()));
modify->addAction(addAction);
QAction*insertUp = new QAction(tr("上方插入一行"),this);
connect(insertUp,SIGNAL(triggered()),this,SLOT(insertBefore()));
modify->addAction(insertUp);
QAction*insertDown = new QAction(tr("下方插入一行"),this);
connect(insertDown,SIGNAL(triggered()),this,SLOT(insertAfter()));
modify->addAction(insertDown);
moveUpAction = new QAction(tr("上移一行"),this);
connect(moveUpAction,SIGNAL(triggered()),this,SLOT(moveUpModify()));
modify->addAction(moveUpAction);
moveDownAction = new QAction(tr("下移一行"),this);
connect(moveDownAction,SIGNAL(triggered()),this,SLOT(moveDownModify()));
modify->addAction(moveDownAction);
deleteAction = new QAction(tr("删除"),this);
connect(deleteAction,SIGNAL(triggered()),this,SLOT(deleteModify()));
modify->addAction(deleteAction);
//QMenu *exit = menuBar()->addMenu(tr("&退出"));
//connect(exit,SIGNAL(triggered()),this,SLOT(close()));
/*
//connect(button, &QPushButton::clicked, someFunction);
//QMenu *view = menuBar()->addMenu(tr("&查看"));
//sortAction = new QAction(tr("排序"),this);
//connect(sortAction,SIGNAL(triggered()),this,SLOT(sortView()));
//view->addAction(sortAction);
searchAction = new QAction(tr("&搜索"),this);
connect(searchAction,SIGNAL(triggered()),this,SLOT(searchView()));
view->addAction(searchAction);
*/
/*
QMenu *statistic = menuBar()->addMenu(tr("&统计"));
gradeAction = new QAction(tr("年级"));
connect(gradeAction,SIGNAL(triggered()),this,SLOT(gradeStatistic()));
statistic->addAction(gradeAction);
majorAction = new QAction(tr("专业"));
connect(majorAction,SIGNAL(triggered()),this,SLOT(majorStatistic()));
statistic->addAction(majorAction);
gpaAction = new QAction(tr("GPA"));
connect(gpaAction,SIGNAL(triggered()),this,SLOT(gpaStatistic()));
statistic->addAction(gpaAction);
*/
QComboBoxList = new QVector<QComboBox*>();
//右键菜单
//表格
widget = new QWidget();
this->setCentralWidget(widget);
layout = new QHBoxLayout;
table = new QTableWidget();
table->setColumnCount(8);
table->setRowCount(0);
table->horizontalHeader()->setHighlightSections(false);
table->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
connect(table,SIGNAL(cellChanged(int,int)),this,SLOT(tableModify(int,int)));
QStringList header;
header<<tr("姓名")<<tr("性别")<<tr("学号")<<tr("年级")<<tr("专业方向")<<tr("出生日期(年-月-日)")<<(tr("籍贯"))<<(tr("住址"));
//table->horizontalHeader()->setDefaultSectionSize(15);
connect(table->horizontalHeader(),SIGNAL(sectionClicked(int)),this, SLOT(sortView(int)));
table->setHorizontalHeaderLabels(header);
//table->setItem(0,0,new QTableWidgetItem("嘤嘤嘤?"));
//table->setItem(0,1,new QTableWidgetItem("嘤嘤嘤?"));
//table->show();
layout->addWidget(table);
widget->setLayout(layout);
//工具栏搜索:支持姓名、id两种精确搜索
//QToolBar *toolBar = addToolBar(tr("&搜索"));
//toolBar->addAction(searchAction);
//layout->addWidget(toolBar);
//工具栏搜索:支持专业、GPA、年龄三种模糊搜索
QComboBox*tmp = new QComboBox();
tmp->setEditable(false);
table->setItemDelegateForColumn(1,new Delegate(this));
QComboBoxList->push_back(tmp);
tmp = new QComboBox();
tmp->setEditable(false);
table->setItemDelegateForColumn(4,new Delegate(this));
//setItemIsEditable(ui.table, 0);
QComboBoxList->push_back(tmp);
//数据库呈现:这里无需呈现,因为刚打开程序,既没有添加也没有读入文件
//后续考虑加入历史纪录,每次打开软件后,自动开打开上一次的文件。这样需要先读一个墓碑文件,之后再读入用户文件,初始化数据库,再修改行数
stuDB = new studentDatabase();
//table->setRowCount(stuDB->getSize()+3);
for(int i = 0; i < table->columnCount();i++)
c[i] = true;
this->resize(QSize(1200,800));
//搜索功能初始化
searchQstr.clear();
searchRow = -1;
searchColumn = -1;
searchQLineEditToolBar = new QLineEdit;
/*
searchToolBar = new QAction(tr("&搜索"),this);
lastToolBar = new QAction(tr("&上一个"),this);
nextToolBar = new QAction(tr("&下一个"),this);
*/
searchButton = new QPushButton(tr("&搜索"));
lastButton = new QPushButton(tr("&上一个"));;
nextButton = new QPushButton(tr("&下一个"
""));;
//ui->mainToolBar->setVisible(false);
ui->mainToolBar->addWidget(searchQLineEditToolBar);
ui->mainToolBar->addWidget(searchButton);
ui->mainToolBar->addWidget(lastButton);
ui->mainToolBar->addWidget(nextButton);
connect(searchQLineEditToolBar,SIGNAL(textChanged(QString)),this,SLOT(searchQlineEditChanged(QString)));
connect(searchButton,SIGNAL(clicked()),this,SLOT(searchToolBarTriggered()));
connect(lastButton,SIGNAL(clicked()),this,SLOT(lastToolBarTriggered()));
connect(nextButton,SIGNAL(clicked()),this,SLOT(nextToolBarTriggered()));
//ui->mainToolBar->addAction(new QAction(tr("&完成"),this));
//ui->mainToolBar->addWidget(QPushButton(tr("&搜索")))
}
void MainWindow::tableInitialize(){
delete table;
delete layout;
delete QComboBoxList;
saved = false;
layout = new QHBoxLayout;
table = new QTableWidget();
QComboBoxList = new QVector<QComboBox*>();
table->setColumnCount(8);
table->setRowCount(0);
table->horizontalHeader()->setHighlightSections(false);
table->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
connect(table,SIGNAL(cellChanged(int,int)),this,SLOT(tableModify(int,int)));
QStringList header;
header<<tr("姓名")<<tr("性别")<<tr("学号")<<tr("年级")<<tr("专业方向")<<tr("出生日期(年-月-日)")<<(tr("籍贯"))<<(tr("住址"));//<<tr("GPA");
//connect(table->horizontalHeader(),SIGNAL(sectionClicked(int)),this, SLOT(sortView(int)));
connect(table->horizontalHeader(),SIGNAL(sectionDoubleClicked(int)),this, SLOT(sortView(int)));
//table->horizontalHeader()->setDefaultSectionSize(15);
table->setHorizontalHeaderLabels(header);
//table->setItem(0,0,new QTableWidgetItem("嘤嘤嘤?"));
//table->setItem(0,1,new QTableWidgetItem("嘤嘤嘤?"));
//table->show();
layout->addWidget(table);
widget->setLayout(layout);
for(int i = 0; i < table->columnCount();i++)
c[i] = true;
}
void MainWindow::newFile(){
qDebug()<<"newFile";
if(table->rowCount()>0&&!saved){
QMessageBox msgBox;
msgBox.setWindowTitle("请注意!");
msgBox.setText(tr("文件尚未保存!"));
msgBox.setInformativeText(tr("是否保存文
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
1、新建文件 新建文件将会产生一个全新的空表格,在新建文件时,当前表格的内容将会被删除,系统会自动检测当前表格内容是否已经被保存过,如果未保存过的,会对用户进行提示;否则将直接生成新表格 2、打开文件 系统可以打开由系统保存的、符合系统规范的.csv文件。 3、保存文件 系统将当前表格保存为.csv文件。之所以保存为.csv文件,除了考虑到这种文件具有非常规整的模式之外,还考虑到该格式可使用微软excel表格打开,便于实际场景中的使用。 4、增加 在系统菜单栏编辑项中和系统右键菜单中,有三种方式对表格数据进行增加,分别是“增加一行”,“上方插入一行”和“下方插入一行”。 点击“增加一行”,会在表格末尾生成一行空行。 点击“上方插入一行”,会在当前选中表格的上方插入一行空行。 点击“下方插入一行”,会在当前选中表格的下方插入一行空行。
资源推荐
资源详情
资源评论
收起资源包目录
Student-Information-Manage-System-master.zip (50个子文件)
Student-Information-Manage-System-master
datedelegate.cpp 2KB
delegate.h 947B
mainwindow.h 3KB
10.png 66KB
studentdatabase.cpp 1KB
9.png 69KB
3.png 66KB
dialog.cpp 931B
Makefile 26KB
mainwindow.cpp 23KB
SIMS2.pro 1KB
1.png 62KB
main.cpp 204B
debug
studentdatabase.o 199KB
moc_dialog.cpp 3KB
moc_mainwindow.cpp 7KB
dialog.o 620KB
moc_datedelegate.cpp 3KB
moc_delegate.o 616KB
delegate.o 626KB
moc_mainwindow.o 629KB
mainwindow.o 828KB
moc_delegate.cpp 3KB
moc_dialog.o 653KB
SIMS2.exe 5.39MB
main.o 639KB
student.o 49KB
datedelegate.o 628KB
moc_predefs.h 9KB
moc_datedelegate.o 626KB
mainwindow.ui 630B
6.png 66KB
object_script.SIMS2.Debug 245B
SIMS2.pro.user 23KB
Makefile.Release 190KB
5.png 68KB
4.png 70KB
8.png 71KB
object_script.SIMS2.Release 267B
ui_mainwindow.h 2KB
delegate.cpp 3KB
Makefile.Debug 190KB
.qmake.stash 714B
student.h 761B
7.png 67KB
studentdatabase.h 596B
dialog.h 512B
datedelegate.h 974B
2.png 64KB
student.cpp 724B
共 50 条
- 1
资源评论
博士僧小星
- 粉丝: 1911
- 资源: 5876
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 蓝zapro.apk
- chromedriver-linux64.zip
- 基于Python和PyTorch框架完成的一个手写数字识别实验源码(带MINIST手写数字数据集)+详细注释(高分项目)
- 基于Matlab在MNIST数据集上利用CNN完成手写体数字识别任务,并实现单层CNN反向传播算法+源代码+文档说明(高分项目)
- NVIDIA驱动、CUDA和Pytorch及其依赖
- html动态爱心代码一(附源码)
- c40539bc-071a-486c-9d52-9d0c18d62dac 4.html
- 基于物理的非视域成像(NLOS)算法,利用了nerf+python源码+文档说明
- yuluer知更鸟.7z(1).001
- python课程设计-基于tensorflow实现的图文生成程序,数据集flickr30k-images+源代码+文档说明+截图
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功