QHexView
QHexView is a hexadecimal widget for Qt5
Features
- Customizable data backend (see more below).
- Document/View based.
- Unlimited Undo/Redo.
- Fully Customizable.
- Fast rendering.
- Easy to Use.
Buffer Backends
These are the available buffer backends:
- QMemoryBuffer: A simple, flat memory array.
- QMemoryRefBuffer: QHexView just display the referenced data, editing is disabled.
It's also possible to create new data backends from scratch.
Usage
The data is managed by QHexView through QHexDocument class.
You can load a generic QIODevice using the method fromDevice() of QHexDocument class with various buffer backends.
Helper methods are provided in order to load a QFile a In-Memory buffer in QHexView:
// Load data from In-Memory Buffer...
QHexDocument* document = QHexDocument::fromMemory<QMemoryBuffer>(bytearray);
// ...from a generic I/O device...
QHexDocument* document = QHexDocument::fromDevice<QMemoryBuffer>(iodevice);
/* ...or from File */
QHexDocument* document = QHexDocument::fromFile<QMemoryBuffer>("data.bin");
QHexView* hexview = new QHexView();
hexview->setDocument(document); // Associate QHexEditData with this QHexEdit
// 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
QHexMetadata* hexmetadata = document->metadata();
hexmetadata->background(6, 0, 10, Qt::red); // Highlight background to line 6, from 0 to 10
hexmetadata->foreground(8, 0, 15, Qt::darkBlue); // Highlight foreground to line 8, from 0 to 15
hexmetadata->comment(16, 0, 16, "I'm a comment!"); // Add a comment to line 16, from 0 to 16
hexmetadata->clear(); // Reset styling
License
QHexEdit is released under MIT license