最新消息:很久没有没有写qt了,qt也不是我的工作方向,看到本篇博文日积月累的点击量很不错,本人决定将该简易系统进行升级改造,提升的内容和方向远超本篇设计的系统,本篇系统其实是一个非常入门的操作,对于基础差的可以快速的理解一些操作,非常简单。升级后的系统内容比当前的这个系统扩展了非常多,也更复杂,所以要想理解,可以先把本篇博文这个先理解,对于基础不错的,则可以移步到我的新的开发的信息系统,本来那个系统我在一年前就已经完成,就想着弄得更完善,但是限于平时时间有限,可以先开放出来,供大家参考学习。后续有时间再继续升级,新的系统功能更强大,设计更合理,如果理解了的话,对于工作上的开发也会是一个不错的参考,新系统不采用任何第三方库,包括日志系统,也是纯手工打造。
新系统源码地址:https://gitee.com/dxl96/StdMsgSystem
信息系统博客新地址:https://blog.youkuaiyun.com/IT_CREATE/article/details/131612076
本系统源码资源:学生信息管理系统.zip · itcreat/qt资源 - Gitee.com
以下是效果图
mainwindow.h
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
#include <QString>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QtWidgets>
#include <QTimer>
#include "insertdialog.h"
#include "updatedialog.h"
namespace Ui {
class MainWindow;
}
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = 0);
// 刷新表格
void tableReflash(QString selectSql = QString());
~MainWindow();
private slots:
//-----------------------------------界面转到槽函数----------------
void on_add_pushButton_clicked();
void on_change_pushButton_clicked();
void on_delete_pushButton_clicked();
void on_refer_pushButton_clicked();
//-----------------------------------自定义槽函数----------------
void changeBackground(); // 更改背景
private:
Ui::MainWindow *ui;
QSqlDatabase db;
// 背景色集合
QList<QString> backgrounds;
// 当前指向景色集合的索引
int backgroundIndex;
// 初始化背景色集合
void initBackgrounds();
// 单元格设置
void cellSetting(int row, int column, QString text);
// 删除学生信息
void deleteStudent();
// 查询学生信息
void selectStudent();
};
#endif // MAINWINDOW_H
mainwindow.cpp
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
setWindowTitle("学生信息管理系统");
// 设置输入框提示信息
ui->select_param_edit->setToolTip("查询支持模糊查询,输入姓名或者学号关键词即可");
// 设置列表第一列宽度100
ui->information_tableWidget->setColumnWidth(0,100);
// 设置列表自动填充满窗口
ui->information_tableWidget->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
// 设置列表列头
ui->information_tableWidget->setColumnCount(7);
ui->information_tableWidget->setHorizontalHeaderItem(0, new QTableWidgetItem("*选择栏"));
ui->information_tableWidget->setHorizontalHeaderItem(1, new QTableWidgetItem("主键(id)"));
ui->information_tableWidget->setHorizontalHead