Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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: about 2 months ago
JSON representation

A versatile Hexadecimal widget for Qt5

Awesome Lists containing this project

README

        


QHexView logo


An hexadecimal widget for Qt5















Features
-----
- Document/View based
- Unlimited Undo/Redo
- Fully Customizable
- Fast rendering
- Easy to Use

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.

Usage
-----
Data is managed by QHexView through QHexDocument class.

It's possible to load a generic QIODevice with QHexDocument's method `fromDevice()` with various buffer backends.

Helper methods are provided in order to load a QFile as 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
```