# MyLibrary **Repository Path**: Weichen961108/my-library ## Basic Information - **Project Name**: MyLibrary - **Description**: 基于Sqlite 和 Qt 技术实现电子图书馆的智慧综合管理 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 4 - **Created**: 2025-01-15 - **Last Updated**: 2025-01-15 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # MyLibrary #### 介绍 基于Sqlite 和 Qt 技术实现电子图书馆的智慧综合管理 > 参考资料: > > https://blog.csdn.net/lishichengyan/article/details/76760859 > > https://blog.csdn.net/a947877846/article/details/78751646 > > https://www.itread01.com/p/1394465.html 图片能正常显示的网址: https://www.yuque.com/docs/share/53c2d429-546a-40cd-8468-898fad8841fd?# 《Qt 图书馆管理系统》 # 一、实验目的 1、 设计并实现一个精简的图书管理系统,具有入库、查询、借书、还书、借书证管理等基本功能。 2、 通过本次设计来加深对数据库的了解和使用,同时提高自身的系统编程能力。 ## 二、实验平台 开发工具 :Qt creator 4.14.2(Qt版本:5.15.2 64bits) 数据库平台:SQLITE 实验平台 :Windows10 # 三、系统架构描述 本系统主要包括以下模块/功能: | 编号 | 模块 | 功能 | | ---- | -------------------- | ------------------------------------------------------------ | | 1 | 使用须知 | 点击后弹出使用须知。 | | 2 | 注册 | 用于用户注册,供用户输入用户名、密码、并确认密码。只有注册后方可借书。 | | 3 | 用户登录 | | | 4 | 管理员登陆 | | | 5 | 图书查询 | 可在输入栏中输入书籍名称,点击"点我搜索"按钮查询这本书的信息 | | 6 | 借书 | 用于用户借书 | | 7 | 还书 | 用于用户还书。 | | 8 | 显示所有书籍 | 进入管理员界面后方可使用,点击显示库存所有书籍。 | | 9 | 新书入库 | 进入管理员界面后方可使用,可输入书籍信息,点击提交按钮完成新书入库 | | 10 | 数据排序 | 进入管理员界面后方可使用,方便管理员掌握数据库情况。 | | 11 | 查看借阅情况 | 进入管理员界面后方可使用,查看用户借阅情况。 | | 12 | 查看用户表 | 进入管理员界面后方可使用,查看注册的用户信息。 | | 13 | 删除用户(收回权限) | 进入管理员界面后方可使用,删除用户。 | 其中(1)、(2)、(5)属于公用功能,也就是说,任何使用这款软件的人都可以查看使用须知、注册以及查询图书信息;(3)、(6)、(7)为用户设计,只有注册过的用户才能借书、还书。余下的模块/功能为管理员设计,是本系统中最复杂的部分。 需要说明的是,我没有设计管理员注册模块,因为在实际的应用情境中,显然不是随便一个人都能通过注册成为某个系统的管理员,所以,管理员权限由我这个"最高的管理员"直接在数据库中添加,从而防止了使用过程中可能出现的安全问题。 ![image](https://gitee.com/shenjiguicang/test/raw/master/images/20210520184408.png) # 四、数据库设计 推荐使用 sqlite expert professional 管理工具,创建数据库和表结构 ![1.png](https://gitee.com/shenjiguicang/test/raw/master/images/20210520184419.png) ## 1) 数据库结构 | 字段名 | 类型 | 介绍 | 备注 | | --------- | ------- | -------- | ---------- | | Book表 | | | | | id | text | ISBN书号 | 主键 | | name | text | 书名 | | | author | text | 作者 | | | pub | text | 出版社 | | | pub_date | text | 出版日期 | yyyy-MM | | avail | bool | 是否可借 | 是1,否0 | | store | integer | 库存 | | | total | integer | 总数 | | | price | REAL | 价格 | | | Loan表 | | | | | user_id | text | 用户 | 外键 | | book_id | text | 书籍 | 外键 | | Loan_date | text | 借阅日期 | yyyy-MM-dd | | Back_date | text | 应还日期 | yyyy-MM-dd | | Manager表 | | | | | id | text | 管理员 | 主键 | | pwd | text | 密码 | | | User表 | | | | | id | text | 用户 | 主键 | | pwd | text | 密码 | | | email | text | 邮箱 | | | loan | integer | 借阅数 | | | max | integer | 可借阅数 | | ## 2)添加测试数据 ``` insert into `manager` values('manager01','123456'); insert into `user` values('1','1'); insert into `book` values ('01','C++程序设计','孟宪福','清华大学出版社','2010-12-12', 1,5, 10, 28.00), ('02','C++ Primer','Stanley B.Lippman','人民邮电出版社','2010-12-12', 1,5, 10, 28.00), ('03','浮士德','歌德','人民文学出版社','2010-12-12', 1,5, 10, 28.00), ('04','简明法语教程','孙辉','外研社','2010-12-12', 1,5, 10, 28.00), ('05','Linear Algebra','Gilbert Strang','高等教育出版社','2010-12-12', 1,5, 10, 28.00); ``` # 五、界面设计 ## 1) 主界面 / 用户页面 ![image.png](https://gitee.com/shenjiguicang/test/raw/master/images/20210520184425.png) ## 2) 主界面 / 管理员页面 ![image.png](https://gitee.com/shenjiguicang/test/raw/master/images/20210520184428.png) ## 3)登录页面 ![image.png](https://gitee.com/shenjiguicang/test/raw/master/images/20210520184431.png) ## 4)注册页面 ![image.png](https://gitee.com/shenjiguicang/test/raw/master/images/20210520184434.png) ## 5)用户须知页面 ![image.png](https://gitee.com/shenjiguicang/test/raw/master/images/20210520184436.png) 页面不多,涉及的类也不多,但是分包管理,还是会更加方便 ## 6)工程文件子文件管理 ![image.png](https://gitee.com/shenjiguicang/test/raw/master/images/20210520184439.png) ## 7)设置应用程序图标 ``` RC_ICONS = library.ico ``` 详见官档 《Setting the Application Icon》 # 六、添加QSS样式文件 ## 1)loadQssFile 函数 ``` inline void loadQssFile(QString fileName) { QFile file(fileName); file.open(QFile::ReadWrite | QIODevice::Text); // 如果文件不存在,会创建该文件 qApp->setStyleSheet(file.readAll()); file.close(); } ``` ## 2)watchQssFile 函数 ``` inline void watchQssFile(QString fileName) { QFileSystemWatcher* watch = new QFileSystemWatcher(qApp); watch->addPath(fileName); QObject::connect(watch, &QFileSystemWatcher::fileChanged, [fileName] { // cout << "watchQssFile"; loadQssFile(fileName); }); } ``` ## 3) 快捷键打开 ``` Welcome w; QShortcut sc(QKeySequence("ctrl+q"), &w); QObject::connect(&sc, &QShortcut::activated, [fileName] { static int flag = 0; if (flag == 0) { QFileInfo info(fileName); QDesktopServices::openUrl(QUrl::fromLocalFile(info.absoluteFilePath())); } }); ``` # 七、程序运行界面 ![1.gif](https://cdn.nlark.com/yuque/0/2021/gif/12792131/1621501746712-151f6576-388b-4661-a20d-de0dcaecc1a1.gif) 参考了一些大佬的资料,若干侵权,请告之。