QtMermaid is an extensible chart component library based on the Qt framework, supporting parsing, rendering, and editing of various chart types. Through modular design and factory pattern, it realizes flexible expansion of chart functions, facilitating developers to quickly integrate or secondary develop.
QtMermaid is committed to providing a universal and easy-to-use chart solution, with core features including:
- Multi-type Support: Supports multiple basic chart types, with reserved extension interfaces in design for easy addition of new types
- Modular Architecture: Separates interfaces from implementations, enabling dynamic creation and management of components through factory pattern
- Convenient Editing: The accompanying sample editor provides syntax highlighting, real-time preview and other functions to simplify chart creation
- Cross-platform Compatibility: Based on the Qt framework, supporting mainstream operating systems such as Windows, Linux, and macOS
Currently supported chart types include:
- Flowchart: Used to display process steps, decision nodes, and flow relationships
- Gantt chart: Used for project schedule planning and time management, showing tasks, milestones, and timeline relationships
- Text Parsing: Convert text with specific syntax into chart data structures
- Chart Rendering: Realize high-quality chart drawing and display based on Qt graphics framework
- Syntax Highlighting: Provide syntax highlighting and error marking for different chart types
- Flexible Expansion: New chart types can be quickly added through registration mechanism without modifying core logic
- Sample Tool: Provide a complete editor example to intuitively demonstrate the usage of components
QtMermaid/
├── CMakeLists.txt # Root directory build script for overall project compilation configuration
├── CMakePresets.json # CMake preset configuration to simplify building in multiple environments
├── LICENSE # Project license file
├── cmake/
│ └── QtMermaidConfig.cmake.in # Project installation configuration template, supporting external projects to reference via find_package
├── doc/
│ └── Doxyfile # Doxygen configuration file for generating project API documentation
├── editor/ # Sample editor module
│ ├── CMakeLists.txt # Editor build script
│ ├── include/ # Editor-related header files (main window, text editing controls, etc.)
│ └── src/ # Editor implementation code
├── extend/ # Chart extension module
│ └── [ChartType]/ # Subdirectories divided by chart type, storing parsers, highlighters, etc. for corresponding types
│ ├── include/ # Extension function header files
│ └── src/ # Extension function implementation code
├── interface/ # Core interface definition module
│ ├── CMakeLists.txt # Interface module build script
│ └── include/ # Core interface and data structure definitions (chart data, factory interfaces, etc.)
└── modules/ # Chart core implementation module
└── [ChartType]/ # Subdirectories divided by chart type, storing core implementations for corresponding types
├── CMakeLists.txt # Module build script
├── README.md # Module function description
├── example/ # Module usage sample code
├── include/ # Core implementation header files (scene, view, layout, etc.)
└── src/ # Core implementation code
- Qt 5.15 or higher (compatible with Qt 6)
- CMake 3.16 or higher
- Compiler supporting C++17 (GCC 7+, Clang 5+, MSVC 2017+)
-
Clone the repository and navigate to the directory
git clone https://github.com/zicowarn/QtMermaid.git cd QtMermaid -
Create a build directory and compile
mkdir build && cd build cmake .. -DCMAKE_PREFIX_PATH=/path/to/qt/installation make -j$(nproc) # Linux/macOS # For Windows, you can open the generated solution with Visual Studio
-
Run the sample editor
./editor/QtMermaidEditor # Path may vary by platform
QtMermaid is designed with the factory pattern. To extend a new chart type, simply follow these steps:
- Define the chart type enumeration (add in
QtMermaidTypeinInterfaces.h) - Implement the chart data structure (inherit from
ChartGraph) - Implement core interfaces (subclasses of
Core,Renderer,Parser,SyntaxHighlighter) - Bind the type with the implementation through registration macros (
REGISTER_CORE,REGISTER_RENDERER, etc.) - The new type can be directly created through the factory class without modifying existing logic
- API Documentation: Generate by executing
doxygen doc/Doxyfile, then viewdoc/html/index.html - Module Description:
README.mdof each chart module contains detailed functions and usage instructions - Sample Code: The
exampledirectory of each module provides basic usage examples
This project is open-source under the MIT License. For details, see the LICENSE file.
- Author: Barbossa Zhang
- Creation Time: 2025/04/22