- Notifications
You must be signed in to change notification settings - Fork104
A versatile Hexadecimal widget for Qt6 (and Qt5)
License
Dax89/QHexView
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
QHexView is a free, independent, MIT-licensed open-source project.
It began years ago as a simple viewer for hexadecimal data and has since evolvedinto a highly customizable widget for managing binary data, thanks to valuable feedback from users. QHexView hides the complexity ofdrawing and input, allowing users to focus on providing the data as a model.
- 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.
If you enjoy using QHexView, consider supporting its development bysponsoring me.
Your support helps keep the project alive and thriving!
QHexView manages data through theQHexDocument
class.
You can load a genericQIODevice
using theQHexDocument
methodfromDevice()
with various buffer backends.
Additionally, helper methods are available to load aQFile
as an in-memory buffer:
#include<QHexView/qhexview.h>QHexOptions options;options.grouplength =2;// Pack bytes as AABBoptions.bytecolors[0x00] = {Qt::lightGray,QColor()};// Highlight '00'soptions.bytecolors[0xFF] = {Qt::darkBlue,QColor()};// Highlight 'FF'shexview.setOptions(options);QHexDocument* document = QHexDocument::fromMemory<QMemoryBuffer>(bytearray);/* Load data from In-Memory Buffer...*///QHexDocument* document = QHexDocument::fromDevice<QMemoryBuffer>(iodevice); /* ...from a generic I/O device... *///QHexDocument* document = QHexDocument::fromFile<QMemoryBuffer>("data.bin"); /* ...or from File... */QHexView* hexview =new QHexView();hexview->setDocument(document);// Associate QHexEditData with this QHexEdit (ownership is not changed)// Document editingQByteArray data = document->read(24,78);// Read 78 bytes starting to offset 24document->insert(4,"Hello QHexEdit");// Insert a string to offset 4document->remove(6,10);// Delete bytes from offset 6 to offset 10document->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 highlightinghexview->clearMetadata();// Reset all styles
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!
About
A versatile Hexadecimal widget for Qt6 (and Qt5)