QHexEdit Class Reference

#include <qhexedit.h>

List of all members.

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.

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:
parent Parent 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,
char  ch 
)

Inserts a char.

Parameters:
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.

void QHexEdit::insert ( int  i,
const QByteArray &  ba 
)

Inserts a byte array.

Parameters:
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.

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]

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:
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

void QHexEdit::setAddressArea ( bool  addressArea  )  [slot]

Switch the address area on or off.

Parameters:
addressArea true (show it), false (hide it).

void QHexEdit::setAddressWidth ( int  addressWidth  )  [slot]

Set the minimum width of the address area.

Parameters:
addressWidth Width in characters.

void QHexEdit::setAsciiArea ( bool  asciiArea  )  [slot]

Switch the ascii area on or off.

Parameters:
asciiArea true (show it), false (hide it).

void QHexEdit::setHighlighting ( bool  mode  )  [slot]

Switch the highlighting feature on or of.

Parameters:
mode true (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 [read, write]

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

int QHexEdit::addressOffset [read, write]

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 [read, write]

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

QByteArray QHexEdit::data [read, write]

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

QFont QHexEdit::font [read, write]

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

QColor QHexEdit::highlightingColor [read, write]

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

bool QHexEdit::overwriteMode [read, write]

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 [read, write]

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 [read, write]

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:

Generated on Fri Apr 10 15:02:02 2015 for QHexEdit by  doxygen 1.5.9