QHexEdit
 All Classes Functions Properties
Public Slots | Signals | Public Member Functions | Properties | List of all members
QHexEdit Class Reference

#include <qhexedit.h>

Inheritance diagram for QHexEdit:

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
 

Detailed Description

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.

Constructor & Destructor Documentation

QHexEdit::QHexEdit ( QWidget *  parent = 0)

Creates an instance of QHexEdit.

Parameters
parentParent widget of QHexEdit.

Member Function Documentation

void QHexEdit::currentAddressChanged ( int  address)
signal

Contains the address, where the cursor is located.

void QHexEdit::currentSizeChanged ( int  size)
signal

Contains the size of the data to edit.

void QHexEdit::dataChanged ( )
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.

Parameters
iIndex position, where to insert
babyte 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.

Parameters
iIndex position, where to insert
chChar, 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.

void QHexEdit::overwriteModeChanged ( bool  state)
signal

The signal is emited every time, the overwrite mode is changed.

void QHexEdit::redo ( )
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.

Parameters
posIndex position, where to remove
lenAmount 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

void QHexEdit::setAddressArea ( bool  addressArea)
slot

Switch the address area on or off.

Parameters
addressAreatrue (show it), false (hide it).
void QHexEdit::setAddressWidth ( int  addressWidth)
slot

Set the minimum width of the address area.

Parameters
addressWidthWidth in characters.
void QHexEdit::setAsciiArea ( bool  asciiArea)
slot

Switch the ascii area on or off.

Parameters
asciiAreatrue (show it), false (hide it).
void QHexEdit::setHighlighting ( bool  mode)
slot

Switch the highlighting feature on or of.

Parameters
modetrue (show it), false (hide it).
QString QHexEdit::toReadableString ( )

Gives back a formatted image of the content of QHexEdit

void QHexEdit::undo ( )
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.

Property Documentation

QColor QHexEdit::addressAreaColor
readwrite

Property address area color sets (setAddressAreaColor()) the backgorund color of address areas. You can also read the color (addressaAreaColor()).

int QHexEdit::addressOffset
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.

int QHexEdit::cursorPosition
readwrite

Porperty cursorPosition sets or gets the position of the editor cursor in QHexEdit.

QByteArray QHexEdit::data
readwrite

Property data holds the content of QHexEdit. Call setData() to set the content of QHexEdit, data() returns the actual content.

QFont QHexEdit::font
readwrite

Set the font of the widget. Please use fixed width fonts like Mono or Courier.

QColor QHexEdit::highlightingColor
readwrite

Property highlighting color sets (setHighlightingColor()) the backgorund color of highlighted text areas. You can also read the color (highlightingColor()).

bool QHexEdit::overwriteMode
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.

bool QHexEdit::readOnly
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.

QColor QHexEdit::selectionColor
readwrite

Property selection color sets (setSelectionColor()) the backgorund color of selected text areas. You can also read the color (selectionColor()).


The documentation for this class was generated from the following file: