# QXmlModel **Repository Path**: sunstom/qxml-model ## Basic Information - **Project Name**: QXmlModel - **Description**: QXmlModel is a high-performance XML tree model class for Qt5/Qt6/C++17 based on QAbstractItemModel. - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-05-07 - **Last Updated**: 2026-05-08 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # QXmlModel QXmlModel is a high-performance XML tree model class for Qt5/Qt6/C++17 based on `QAbstractItemModel`. It uses `QXmlStreamReader` for efficient streaming XML parsing with low memory footprint. ## Features - **High Performance**: Uses `QXmlStreamReader` for streaming XML parsing (no DOM overhead) - **Qt Model/View**: Full `QAbstractItemModel` implementation for use with `QTreeView` - **Editable**: Supports editing of tag names and text content - **3-Column Display**: Name, Value, and Attributes columns - **XML Export**: Round-trip support via `toXml()` method - **Exception Filtering**: Skip specific tags during parsing - **Qt5 & Qt6 Support**: Automatic version detection via CMake ## Build Instructions ### Requirements - CMake 3.16+ - C++17-compatible compiler - Qt5 or Qt6 (Core, Gui, Widgets, Xml modules) ### Building ```bash # Configure cmake -B build -G Ninja # Build cmake --build build ``` ### Running Tests ```bash ./build/tests/QXmlModelTest ``` ## Usage ### C++ Example ```cpp #include "QXmlModel.hpp" #include // Create model and load XML file QXmlModel *model = new QXmlModel; QTreeView *view = new QTreeView; view->setModel(model); model->load("example.xml"); // Or load from byte array model->loadXml(xmlData); // Export back to XML QByteArray exported = model->toXml(); ``` ### CMake Integration ```cmake # Add as subdirectory add_subdirectory(QXmlModel) # Link to your target target_link_libraries(your_app PRIVATE QXmlModel) ``` ## API Reference ### QXmlModel | Method | Description | |--------|-------------| | `load(fileName)` | Load XML from file path | | `load(device)` | Load XML from QIODevice | | `loadXml(data)` | Load XML from QByteArray | | `toXml(indent)` | Export model to XML QByteArray | | `addException(list)` | Set tag names to skip during parsing | ### Model Columns | Column | Header | Content | |--------|--------|---------| | 0 | Name | XML element tag name | | 1 | Value | Text content of the element | | 2 | Attributes | Formatted attribute string | ## License MIT License - See [LICENSE](LICENSE) for details.