#include <qhexedit.h>
Public Slots | |
void | redo () |
void | setAddressWidth (int addressWidth) |
void | setAddressArea (bool addressArea) |
void | setAsciiArea (bool asciiArea) |
void | setHighlighting (bool mode) |
void | undo () |
Signals | |
void | currentAddressChanged (int address) |
void | currentSizeChanged (int size) |
void | dataChanged () |
void | overwriteModeChanged (bool state) |
Public Member Functions | |
QHexEdit (QWidget *parent=0) | |
int | indexOf (const QByteArray &ba, int from=0) const |
void | insert (int i, const QByteArray &ba) |
void | insert (int i, char ch) |
int | lastIndexOf (const QByteArray &ba, int from=0) const |
void | remove (int pos, int len=1) |
void | replace (int pos, int len, const QByteArray &after) |
QString | toReadableString () |
QString | selectionToReadableString () |
Properties | |
QByteArray | data |
int | addressOffset |
QColor | addressAreaColor |
int | cursorPosition |
QColor | highlightingColor |
QColor | selectionColor |
bool | overwriteMode |
bool | readOnly |
QFont | font |
QHexEdit is a hex editor widget written in C++ for the Qt (Qt4, Qt5) framework. It is a simple editor for binary data, just like QPlainTextEdit is for text data. There are sip configuration files included, so it is easy to create bindings for PyQt and you can use this widget also in python 2 and 3.
QHexEdit takes the data of a QByteArray (setData()) and shows it. You can use the mouse or the keyboard to navigate inside the widget. If you hit the keys (0..9, a..f) you will change the data. Changed data is highlighted and can be accessed via data().
Normaly QHexEdit works in the overwrite Mode. You can set overwriteMode(false) and insert data. In this case the size of data() increases. It is also possible to delete bytes (del or backspace), here the size of data decreases.
You can select data with keyboard hits or mouse movements. The copy-key will copy the selected data into the clipboard. The cut-key copies also but delets it afterwards. In overwrite mode, the paste function overwrites the content of the (does not change the length) data. In insert mode, clipboard data will be inserted. The clipboard content is expected in ASCII Hex notation. Unknown characters will be ignored.
QHexEdit comes with undo/redo functionality. All changes can be undone, by pressing the undo-key (usually ctr-z). They can also be redone afterwards. The undo/redo framework is cleared, when setData() sets up a new content for the editor. You can search data inside the content with indexOf() and lastIndexOf(). The replace() function is to change located subdata. This 'replaced' data can also be undone by the undo/redo framework.
This widget can only handle small amounts of data. The size has to be below 10 megabytes, otherwise the scroll sliders ard not shown and you can't scroll any more.
QHexEdit::QHexEdit | ( | QWidget * | parent = 0 | ) |
|
signal |
Contains the address, where the cursor is located.
|
signal |
Contains the size of the data to edit.
|
signal |
The signal is emited every time, the data is changed.
int QHexEdit::indexOf | ( | const QByteArray & | ba, |
int | from = 0 |
||
) | const |
Returns the index position of the first occurrence of the byte array ba in this byte array, searching forward from index position from. Returns -1 if ba could not be found. In addition to this functionality of QByteArray the cursorposition is set to the end of found bytearray and it will be selected.
void QHexEdit::insert | ( | int | i, |
const QByteArray & | ba | ||
) |
Inserts a byte array.
i | Index position, where to insert |
ba | byte array, which is to insert In overwrite mode, the existing data will be overwritten, in insertmode ba will be inserted and size of data grows. |
void QHexEdit::insert | ( | int | i, |
char | ch | ||
) |
Inserts a char.
i | Index position, where to insert |
ch | Char, which is to insert In overwrite mode, the existing data will be overwritten, in insertmode ba will be inserted and size of data grows. |
int QHexEdit::lastIndexOf | ( | const QByteArray & | ba, |
int | from = 0 |
||
) | const |
Returns the index position of the last occurrence of the byte array ba in this byte array, searching backwards from index position from. Returns -1 if ba could not be found. In addition to this functionality of QByteArray the cursorposition is set to the beginning of found bytearray and it will be selected.
|
signal |
The signal is emited every time, the overwrite mode is changed.
|
slot |
docNever
Redoes the last operation. If there is no operation to redo, i.e. there is no redo step in the undo/redo history, nothing happens.
void QHexEdit::remove | ( | int | pos, |
int | len = 1 |
||
) |
Removes len bytes from the content.
pos | Index position, where to remove |
len | Amount of bytes to remove In overwrite mode, the existing bytes will be overwriten with 0x00. |
void QHexEdit::replace | ( | int | pos, |
int | len, | ||
const QByteArray & | after | ||
) |
Replaces len bytes from index position pos with the byte array after.
QString QHexEdit::selectionToReadableString | ( | ) |
Gives back a formatted image of the selected content of QHexEdit
|
slot |
Switch the address area on or off.
addressArea | true (show it), false (hide it). |
|
slot |
Set the minimum width of the address area.
addressWidth | Width in characters. |
|
slot |
Switch the ascii area on or off.
asciiArea | true (show it), false (hide it). |
|
slot |
Switch the highlighting feature on or of.
mode | true (show it), false (hide it). |
QString QHexEdit::toReadableString | ( | ) |
Gives back a formatted image of the content of QHexEdit
|
slot |
Undoes the last operation. If there is no operation to undo, i.e. there is no undo step in the undo/redo history, nothing happens.
|
readwrite |
Property address area color sets (setAddressAreaColor()) the backgorund color of address areas. You can also read the color (addressaAreaColor()).
|
readwrite |
Property addressOffset is added to the Numbers of the Address Area. A offset in the address area (left side) is sometimes usefull, whe you show only a segment of a complete memory picture. With setAddressOffset() you set this property - with addressOffset() you get the actual value.
|
readwrite |
Porperty cursorPosition sets or gets the position of the editor cursor in QHexEdit.
|
readwrite |
|
readwrite |
Set the font of the widget. Please use fixed width fonts like Mono or Courier.
|
readwrite |
Property highlighting color sets (setHighlightingColor()) the backgorund color of highlighted text areas. You can also read the color (highlightingColor()).
|
readwrite |
Porperty overwrite mode sets (setOverwriteMode()) or gets (overwriteMode()) the mode in which the editor works. In overwrite mode the user will overwrite existing data. The size of data will be constant. In insert mode the size will grow, when inserting new data.
|
readwrite |
Porperty readOnly sets (setReadOnly()) or gets (isReadOnly) the mode in which the editor works. In readonly mode the the user can only navigate through the data and select data; modifying is not possible. This property's default is false.
|
readwrite |
Property selection color sets (setSelectionColor()) the backgorund color of selected text areas. You can also read the color (selectionColor()).