toddming/QFluentKit
关于
A beautiful and modern Qt Fluent Design component library with 90+ high-quality out-of-the-box components
网站与应用开发可以做什么
- 🎨 Fluent Design Style - Modern Microsoft Fluent Design UI specifications
- 🌓 Dark/Light Theme - Automatic theme switching with custom theme color support
- 🧩 90+ Advanced Components - Covering input, display, layout, dialogs, and complete scenarios
- 🦦 Qt5/Qt6 Dual Support - One codebase, fully compatible with both versions
实测星标增长
- 24小时
- +2
- 7天
- +2
- 15天
- +3
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README_ZH.md
原文QFluentKit
衍生作品声明:本项目是 PyQt-Fluent-Widgets(作者 zhiyiYo)的 C++ 移植版本。作为衍生作品,本项目遵照原项目许可证以 GPL-3.0 发布。
简介
QFluentKit 是一个基于 Qt 的 Fluent Design 风格组件库,提供完整的现代化 UI 组件集合。项目采用 C++17 标准,支持 Qt5/Qt6 双版本,兼容 Windows、Linux 和 macOS 平台。


核心特性
- 🎨 Fluent Design 设计风格 - 现代化的 Microsoft Fluent Design UI 规范
- 🌓 深色/浅色主题 - 自动主题切换,支持自定义主题色
- 🧩 90+ 高级组件 - 涵盖输入、显示、布局、对话框等完整场景
- 🦦 Qt5/Qt6 双支持 - 一套代码,两个版本完全兼容
- 🖥️ 跨平台 - 支持 Windows、Linux、macOS
- 📦 易于集成 - 动态库形式,CMake 集成简单
- 🎭 丰富的动画效果 - 内置多种流畅动画系统
- 🎭 Acrylic 材质效果 - 支持 Windows 亚克力毛玻璃效果
系统支持
| 平台 | 支持状态 | 备注 |
|---|---|---|
| Windows 10/11 | ✅ 完全支持 | 推荐,最佳体验 |
| Linux | ✅ 支持 | Qt5/Qt6 均可 |
| macOS | ✅ 支持 | Qt5/Qt6 均可 |
环境要求
Qt 版本
- Qt 5.12 或更高版本
- Qt 6.x 完全支持
编译器
| 平台 | 推荐编译器 |
|---|---|
| Windows | MinGW 8.0+ 或 MSVC 2017+ |
| Linux | GCC 7+ 或 Clang 5+ |
| macOS | Clang (Xcode 10+) |
依赖工具
- CMake 3.15+
- Qt Modules: Core, Widgets, Svg, Xml
快速开始
1. 克隆项目
git clone https://github.com/toddming/QFluentKit.git
cd QFluentKit
2. 构建项目
Windows (MinGW)
mkdir build && cd build
cmake -G "MinGW Makefiles" ..
mingw32-make
Windows (MSVC)
mkdir build && cd build
cmake ..
cmake --build . --config Release
Linux/macOS
mkdir build && cd build
cmake ..
make -j$(nproc)
运行示例程序:
cd build/QFluentExample
./QFluentExample # Linux/macOS
QFluentExample.exe # Windows
说明: MinimalExample 项目仅在 QFluent 已安装时才会构建(通过 find_package(QFluent) 检测)。这用于测试已安装库的集成效果。
集成到你的项目
方式一:安装到 Qt 目录(推荐)
将 QFluentKit 安装到 Qt 安装目录后,所有 Qt 项目都可以直接使用。
步骤 1:构建和安装
Windows (MSVC)
mkdir build && cd build
cmake -G "Visual Studio 17 2022" -A x64 -DQFLUENT_INSTALL_TO_QT=ON ..
cmake --build . --config Release
cmake --install . --config Release
Windows (MinGW)
mkdir build && cd build
cmake -G "MinGW Makefiles" -DQFLUENT_INSTALL_TO_QT=ON ..
mingw32-make
mingw32-make install
Linux/macOS
mkdir build && cd build
cmake -DQFLUENT_INSTALL_TO_QT=ON ..
make -j$(nproc)
sudo make install
步骤 2:在项目中使用
安装完成后,只需在 CMakeLists.txt 中添加:
find_package(QFluent REQUIRED)
target_link_libraries(MyApp PRIVATE QFluent::QFluent)
安装目录结构
安装完成后,文件组织如下(以 Qt 6.8.3 MSVC 为例):
E:/Qt/6.8.3/msvc2022_64/
├── bin/
│ ├── QFluent.dll # Release 动态库
│ ├── QFluentd.dll # Debug 动态库(带 'd' 后缀)
│ ├── QFluent.pdb # Debug PDB 文件(仅 MSVC)
│ ├── QFluent.dll.debug # 调试符号文件(仅 MinGW)
│ └── ...
├── lib/
│ ├── QFluent.lib # Release 导入库
│ ├── QFluentd.lib # Debug 导入库(带 'd' 后缀)
│ └── cmake/
│ └── QFluent/ # CMake 配置文件
│ ├── QFluentConfig.cmake
│ ├── QFluentConfigVersion.cmake
│ └── QFluentTargets.cmake
├── include/
│ └── QFluent/ # 头文件
│ ├── FluentGlobal.h
│ ├── Theme.h
│ ├── FluentIcon.h
│ └── ...
└── share/
└── QFluent/
└── res/ # 资源文件(图标、样式表)
说明:
- Debug 版本的库文件使用
d后缀(如QFluentd.dll、QFluentd.lib),遵循 Qt 的命名惯例。这样 Debug 和 Release 版本可以共存于同一目录,互不覆盖。 - MSVC:Debug PDB 文件会随 DLL 一起安装,便于调试。
- MinGW:调试符号会被提取到独立的
.debug文件(如QFluent.dll.debug),减小 DLL 体积的同时保留调试能力。
方式二:安装到自定义目录
也可以安装到自定义位置:
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=/path/to/install ..
cmake --build . --config Release
cmake --install . --config Release
然后在项目中指定安装路径:
# 方式 1:添加到 CMAKE_PREFIX_PATH
set(CMAKE_PREFIX_PATH "/path/to/install/lib/cmake/QFluent;${CMAKE_PREFIX_PATH}")
find_package(QFluent REQUIRED)
target_link_libraries(MyApp PRIVATE QFluent::QFluent)
或设置 QFluent_DIR:
# 方式 2:设置 QFluent_DIR
set(QFluent_DIR "/path/to/install/lib/cmake/QFluent")
find_package(QFluent REQUIRED)
target_link_libraries(MyApp PRIVATE QFluent::QFluent)
方式三:子目录集成
将 QFluentKit 作为子目录添加到项目中:
# 添加 QFluentKit 子目录
add_subdirectory(QFluentKit)
# 链接 QFluent
target_link_libraries(MyApp PRIVATE QFluent)
方式四:手动集成
- 编译 QFluentKit 生成
QFluent.dll(Windows) 或libQFluent.so(Linux/macOS) - 在你的项目中包含头文件目录:
QFluentKit/QFluent/src/ - 链接生成的库文件
CMake 选项说明
| 选项 | 默认值 | 说明 |
|---|---|---|
QFLUENT_INSTALL_TO_QT |
ON | 安装到 Qt 安装目录 |
CMAKE_INSTALL_PREFIX |
系统默认 | 自定义安装路径 |
QFLUENT_BUILD_TESTS |
顶层工程时为 ON | 构建 tests/ 下的单元测试 |
BUILD_QWINDOWKIT |
OFF | 启用 QWindowKit 集成 |
运行测试
cmake -S . -B build -DQFLUENT_INSTALL_TO_QT=OFF
cmake --build build --parallel
ctest --test-dir build --output-on-failure
测试覆盖主题色派生、样式表注册与缓存、组件创建销毁,并包含内存占用与
主题切换耗时检查。测试通过 offscreen 平台插件运行,无需显示环境。
可选:启用 QWindowKit 集成
QWindowKit 提供高级窗口管理功能(无边框窗口、毛玻璃效果等):
# 在构建示例程序时启用
set(BUILD_QWINDOWKIT ON CACHE BOOL "Build with QWindowKit support" FORCE)
# 或者通过 CMake 参数启用
cmake -DBUILD_QWINDOWKIT=ON ..
启用后,USE_QWINDOWKIT 宏会被定义,可使用增强的窗口功能。
基本用法
Hello World
#include <QWidget>
#include <QApplication>
#include "QFluent/LineEdit.h"
#include "QFluent/PushButton.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
// 创建 Fluent 窗口
QWidget window;
window.setWindowTitle("QFluentKit 示例");
window.resize(800, 600);
// 创建按钮
auto *button = new PrimaryPushButton(&window);
button->setText("点击我");
button->move(350, 280);
// 创建输入框
auto *lineEdit = new LineEdit(&window);
lineEdit->setPlaceholderText("请输入内容...");
lineEdit->move(350, 340);
window.show();
return app.exec();
}
组件列表
基础输入
- Button, PrimaryButton, HyperlinkButton
- CheckBox, RadioButton
- ComboBox, LineEdit, Slider, SpinBox
- SwitchButton, PushButton
显示组件
- Label, CaptionLabel, StrongLabel
- ImageLabel, IconWidget
- CardWidget, Loading
日期时间
- DatePicker, TimePicker
- CalendarPicker, CalendarView
- CycleListWidget
菜单导航
- RoundMenu, NavigationPanel, NavigationBar
- Pivot, TabBar
对话框
- MessageDialog, ColorDialog, Flyout, TeachingTip
容器布局
- StackedWidget, ScrollArea, TableView
- ListView, FlowLayout, ExpandLayout
进度状态
- ProgressBar, ProgressRing
- IndeterminateProgressBar, IndeterminateProgressRing
- InfoBar, ToolTip
设置卡片
- SettingCard, SettingCardGroup
- ExpandSettingCard, OptionsSettingCard
材料效果
- AcrylicWidget, AcrylicLabel, AcrylicMenu, AcrylicToolTip
项目结构
QFluentKit/
├── QFluent/ # 核心动态库
│ ├── src/
│ │ ├── FluentGlobal.h # 全局枚举 (ThemeMode, IconType, ThemeStyle)
│ │ ├── Theme.h # 主题管理系统 (AUTO/LIGHT/DARK)
│ │ ├── Router.h # 路由系统 (配合 StackedWidget)
│ │ ├── FluentIcon.h # 图标系统 (248+ 内置 SVG 图标)
│ │ ├── StyleSheet.h # 样式表管理系统
│ │ ├── Animation.h # 动画系统基类
│ │ ├── QFluent/ # 公开组件头文件
│ │ │ ├── BasicInput/ # 基础输入组件
│ │ │ ├── Display/ # 显示组件
│ │ │ ├── DateTime/ # 日期时间组件
│ │ │ ├── Menu/ # 菜单组件
│ │ │ ├── Dialog/ # 对话框
│ │ │ ├── Layout/ # 布局容器
│ │ │ ├── Progress/ # 进度组件
│ │ │ ├── Setting/ # 设置卡片
│ │ │ └── Material/ # 材质效果
│ │ └── Private/ # PIMPL 私有实现
│ └── res/ # 资源文件
│ ├── images/icons/ # Fluent Design SVG 图标
│ └── style/ # QSS 样式表 (light/dark)
├── QFluentExample/ # 示例应用程序
│ ├── src/
│ │ ├── Interface/ # 15 个演示界面
│ │ │ ├── HomeInterface.h
│ │ │ ├── BasicInputInterface.h
│ │ │ └── ...
│ │ └── Window/ # 自定义窗口示例
│ │ ├── LoginWindow.h
│ │ ├── NavbarWindow.h
│ │ └── SplitWindow.h
│ └── libs/qwindowkit/ # 可选窗口管理库
├── CMakeLists.txt # 根 CMake 配置
└── README.md
许可证
QFluentKit 采用 GNU 通用公共许可证 v3.0 授权。
贡献
欢迎提交 Issue 和 Pull Request!
致谢
- 核心窗口管理:QWindowKit
- 基于:PyQt-Fluent-Widgets — 本项目是 PyQt-Fluent-Widgets 的 C++ 移植/衍生作品。
⭐ 如果觉得这个项目对你有帮助,请给个 Star! 🐧 欢迎加入QQ群交流: 1084320682
探索相关项目
加载中…