# HumanBodyComposition **Repository Path**: codeceo_net/human-body-composition ## Basic Information - **Project Name**: HumanBodyComposition - **Description**: 基于 C++、Qt 与 QML 的心电管理系统设计与实现 - **Primary Language**: C++ - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2026-06-10 - **Last Updated**: 2026-08-28 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 开发环境 - 操作系统:Windows 10/11 x64 - Qt 版本: - 项目最低要求:Qt 6.5+ - 当前本机开发环境:Qt 6.9.1 `msvc2022_64` - C++ 标准:C++17 - 构建系统:CMake - CMake 最低版本:3.21 - 当前本机 CMake 版本:3.30.5 - 编译器/IDE:Visual Studio 2022 / MSVC x64 - 当前工程生成器: - `CMakeUserPresets.json`:Ninja - `build/cmake` 缓存:Visual Studio 17 2022 x64 ## Qt 模块依赖 项目使用 Qt 6,主要依赖模块: - Qt6::Core - Qt6::CorePrivate - Qt6::Gui - Qt6::Qml - Qt6::Quick - Qt6::QuickControls2 - Qt6::QuickDialogs2 - Qt6::QuickWidgets - Qt6::Widgets - Qt6::Sql - Qt6::SerialPort - Qt6::Concurrent - Qt6::Pdf - Qt6::PdfQuick - Qt6::PrintSupport ## 技术栈 - UI:Qt Quick / QML - 后端逻辑:C++ / QObject / 信号槽 - 数据库:SQLite,基于 Qt SQL 封装 DAO - 设备通信:Qt SerialPort - 心电数据处理:C++ 服务层 - PDF 报告:Qt Pdf / QPdfWriter / QPainter / Qt PrintSupport - Excel 导出:基于 Qt 内部 Zip 写入方式生成 `.xlsx` ## 构建方式 ### 使用 Qt Creator 直接打开 `CMakeLists.txt`,选择 Qt 6.9.1 msvc2022_64 Kit 后构建。 ### 使用命令行 - cmake -S . -B build/cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_PREFIX_PATH="C:/Qt/6.9.1/msvc2022_64" - cmake --build build/cmake --config Debug -- /m:1 ### 数据库文件名: human_body_composition.db ### 附件地址 - HumanBodyComposition\docs - 12lead_ecg_origin_data.txt 该数据是设备原始数据 没有真实设备,可以使用此数据 模拟串口发送数据,需要自定义模拟串口线程 - human_body_composition.db 为我测试的数据库,可以直接替换默认生成的数据库 # 目录结构 HumanBodyComposition/ ├─ app/ # 应用入口、全局初始化 │ ├─ main.cpp │ ├─ application.h │ └─ application.cpp │ ├─ ui/ # 界面层,只负责显示和用户交互 │ ├─ windows/ # 主窗口、独立窗口 │ │ ├─ MainWindow.h │ │ ├─ MainWindow.cpp │ │ └─ MainWindow.ui │ │ │ ├─ pages/ # 页面级界面 │ │ ├─ HomePage.h │ │ ├─ MeasurePage.h │ │ ├─ ReportPage.h │ │ └─ SettingsPage.h │ │ │ ├─ dialogs/ # 弹窗 │ │ ├─ LoginDialog.h │ │ ├─ PatientEditDialog.h │ │ └─ ConfirmDialog.h │ │ │ ├─ widgets/ # 可复用控件 │ │ ├─ ChartWidget.h │ │ ├─ NumericInputWidget.h │ │ └─ StatusBarWidget.h │ │ │ └─ delegates/ # Qt Model/View 委托 │ └─ TableButtonDelegate.h │ ├─ services/ # 业务服务层,组织业务流程 │ ├─ PatientService.h │ ├─ PatientService.cpp │ ├─ MeasurementService.h │ ├─ MeasurementService.cpp │ ├─ ReportService.h │ ├─ ReportService.cpp │ ├─ AuthService.h │ └─ AuthService.cpp │ ├─ database/ # 数据库访问层 │ ├─ DatabaseManager.h # 数据库连接、初始化、事务 │ ├─ DatabaseManager.cpp │ ├─ migrations/ # 建表、升级 SQL │ │ ├─ 001_init.sql │ │ └─ 002_add_measurement.sql │ ├─ dao/ # DAO,只做数据库 CRUD / 负责数据库的增删改查(CRUD)。 │ │ ├─ PatientDao.h │ │ ├─ PatientDao.cpp │ │ ├─ MeasurementDao.h │ │ └─ MeasurementDao.cpp │ └─ entity/ # 数据库实体结构 │ ├─ PatientEntity.h │ └─ MeasurementEntity.h │ ├─ models/ # 领域模型 / Qt Model │ ├─ domain/ # 业务对象 │ │ ├─ Patient.h │ │ ├─ MeasurementResult.h │ │ └─ BodyComposition.h │ │ │ └─ table/ # QAbstractTableModel 等 │ ├─ PatientTableModel.h │ ├─ PatientTableModel.cpp │ ├─ MeasurementTableModel.h │ └─ MeasurementTableModel.cpp │ ├─ devices/ # 外设、串口、蓝牙、测量设备 │ ├─ SerialPortManager.h │ ├─ SerialPortManager.cpp │ ├─ BodyCompositionDevice.h │ ├─ BodyCompositionDevice.cpp │ └─ protocol/ │ ├─ DeviceProtocol.h │ ├─ DeviceProtocol.cpp │ ├─ PacketParser.h │ └─ PacketParser.cpp │ ├─ utils/ # 通用工具类,无业务状态 │ ├─ DateTimeUtils.h │ ├─ FileUtils.h │ ├─ StringUtils.h │ ├─ ValidationUtils.h │ └─ Logger.h │ ├─ config/ # 配置读写 │ ├─ AppConfig.h │ ├─ AppConfig.cpp │ ├─ DatabaseConfig.h │ └─ DeviceConfig.h │ ├─ reports/ # 报告生成、打印、导出 │ ├─ ReportGenerator.h │ ├─ ReportGenerator.cpp │ ├─ PdfExporter.h │ ├─ PdfExporter.cpp │ └─ templates/ │ └─ body_report.html │ ├─ resources/ # Qt 资源文件和静态资源 │ ├─ qrc/ │ │ └─ humanbodycomposition.qrc │ ├─ icons/ │ ├─ images/ │ ├─ styles/ │ │ ├─ app.qss │ │ └─ dark.qss │ └─ translations/ │ ├─ zh_CN.ts │ └─ en_US.ts │ ├─ common/ # 公共定义 │ ├─ Constants.h │ ├─ Enums.h │ ├─ Types.h │ └─ ErrorCode.h │ ├─ tests/ # 单元测试 / 集成测试 │ ├─ service_tests/ │ ├─ database_tests/ │ └─ device_tests/ │ ├─ docs/ # 项目文档 │ ├─ architecture.md │ ├─ database.md │ └─ protocol.md │ ├─ third_party/ # 第三方库 │ ├─ build/ # 构建输出,建议 git 忽略 │ ├─ HumanBodyComposition.sln ├─ HumanBodyComposition.vcxproj └─ README.md ui -> 界面,只处理显示、按钮点击、信号槽 services -> 业务流程,例如保存测量结果、生成报告 database -> 数据库连接和 CRUD models -> 业务数据结构、Qt 表格模型 devices -> 串口、设备协议、测量仪通信 utils -> 通用工具 config -> 配置管理 resources -> 图标、样式、翻译、qrc foreach(resource_file IN LISTS APP_RESOURCE_FILES) set(resource_alias "${resource_file}") string(REGEX REPLACE "^resources/" "" resource_alias "${resource_alias}") set_source_files_properties("${resource_file}" PROPERTIES QT_RESOURCE_ALIAS "${resource_alias}" ) endforeach() | 原始路径 | QT_RESOURCE_ALIAS | | --------------------------------- | ----------------------- | | resources/images/login_bg.png | images/login_bg.png | | resources/images/default_head.png | images/default_head.png | qt_add_qml_module( RESOURCES ${APP_RESOURCE_FILES} ) | 原始路径 | 最终 qrc 路径 | | --------------------------------- | ----------------------------------- | | resources/images/login_bg.png | qrc:/qt/qml/images/login_bg.png | | resources/images/default_head.png | qrc:/qt/qml/images/default_head.png |