https://github.com/Dax89/QHexView
A versatile Hexadecimal widget for Qt5
https://github.com/Dax89/QHexView
c-plus-plus hex-editor hexedit-widget qt qt-widgets qt5
Last synced: 4 months ago
JSON representation
A versatile Hexadecimal widget for Qt5
- Host: GitHub
- URL: https://github.com/Dax89/QHexView
- Owner: Dax89
- License: mit
- Created: 2013-12-29T14:17:16.000Z (almost 12 years ago)
- Default Branch: 5.0
- Last Pushed: 2024-10-21T16:34:53.000Z (about 1 year ago)
- Last Synced: 2024-10-22T00:49:13.371Z (about 1 year ago)
- Topics: c-plus-plus, hex-editor, hexedit-widget, qt, qt-widgets, qt5
- Language: C++
- Homepage:
- Size: 896 KB
- Stars: 321
- Watchers: 27
- Forks: 102
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
QHexView is a free, independent, MIT-licensed open-source project.
It began years ago as a simple viewer for hexadecimal data and has since evolved
into a highly customizable widget for managing binary data, thanks to valuable feedback from users. QHexView hides the complexity of
drawing and input, allowing users to focus on providing the data as a model.
## Table Of Content
- [Features](#features)
- [Sponsors](#sponsors)
- [Usage](#usage)
- [Loading Data](#loading-data)
- [Backends](#backends)
## Features
- **Document/View Architecture**: Built on a robust document/view design pattern.
- **Unlimited Undo/Redo**: Seamlessly revert or reapply changes without limits.
- **Fully Customizable**: Tailor every aspect to your specific needs.
- **Fast rendering**: Optimized for speed and efficiency.
- **Developer Friendly**: Intuitive and easy to integrate in your codebase.
## Sponsors
If you enjoy using QHexView, consider supporting its development by [sponsoring me](https://github.com/sponsors/Dax89).
Your support helps keep the project alive and thriving!
## Usage
### Loading Data
QHexView manages data through the `QHexDocument` class.
You can load a generic `QIODevice` using the `QHexDocument` method `fromDevice()` with various buffer backends.
Additionally, helper methods are available to load a `QFile` as an in-memory buffer:
```cpp
#include
QHexOptions options;
options.grouplength = 2; // Pack bytes as AABB
options.bytecolors[0x00] = {Qt::lightGray, QColor()}; // Highlight '00's
options.bytecolors[0xFF] = {Qt::darkBlue, QColor()}; // Highlight 'FF's
hexview.setOptions(options);
QHexDocument* document = QHexDocument::fromMemory(bytearray); /* Load data from In-Memory Buffer... */
//QHexDocument* document = QHexDocument::fromDevice(iodevice); /* ...from a generic I/O device... */
//QHexDocument* document = QHexDocument::fromFile("data.bin"); /* ...or from File... */
QHexView* hexview = new QHexView();
hexview->setDocument(document); // Associate QHexEditData with this QHexEdit (ownership is not changed)
// Document editing
QByteArray data = document->read(24, 78); // Read 78 bytes starting to offset 24
document->insert(4, "Hello QHexEdit"); // Insert a string to offset 4
document->remove(6, 10); // Delete bytes from offset 6 to offset 10
document->replace(30, "New Data"); // Replace bytes from offset 30 with the string "New Data"
// Metatadata management (available from QHexView too)
hexview->setBackground(5, 10, Qt::Red); // Highlight background at offset range [5, 10)
hexview->setForeground(15, 30, Qt::darkBLue); // Highlight background at offset range [15, 30)
hexview->setComment(12, 42, "I'm a comment!"); // Add a comment at offset range [12, 42)
hexview->unhighlight(); // Reset highlighting
hexview->clearMetadata(); // Reset all styles
```
### Backends
These are the available buffer backends:
- **QMemoryBuffer**: A simple, flat memory.
- **QMemoryRefBuffer**: QHexView just display the referenced data, editing is disabled.
- **QDeviceBuffer**: A read-only view for QIODevice.
- **QMappedFileBuffer**: MMIO wrapper for QFile.
*It's also possible to create new data backends from scratch!*
