• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KHexEdit

KHexEdit

Introduction

The KHexEdit interfaces - also called KHE interfaces - are a set of well-defined interfaces which a library can implement to provide byte level editing services. Programs which utilise these interfaces can thus allow the user to choose which implementation of the hex editor component to use. At the time of KDE Platform 4.6 the only implementation known is the Okteta Component (found in kdesdk/okteta/parts/kbytesedit).

How to use the KHexEdit Interfaces

This HOWTO will explain step by step how to create a KHexEdit component and prepare it for usage.

The code lines

The following source code tries to create a hexedit component. If the component could not be created, a simple message label is created. Otherwise we set the data and configure it to our needs by using the different interfaces if available.

// used interfaces
#include <khexedit/byteseditinterface.h>
#include <khexedit/valuecolumninterface.h>
#include <khexedit/charcolumninterface.h>
#include <khexedit/clipboardinterface.h>
//
const char *data = 0;
int dataSize = 0;
// create data field and set dataSize
// ...
QWidget *bytesEditWidget = KHE::createBytesEditWidget( parent );
// no hexedit component installed?
if( !bytesEditWidget )
{
bytesEditWidget = new QLabel( parent, i18n("Could not find a hexedit component.") );
}
// component found and widget created
else
{
// fetch the editor interface
KHE::BytesEditInterface *bytesEdit = KHE::bytesEditInterface( bytesEditWidget );
Q_ASSERT( bytesEdit ); // This should not fail!
// now use the editor.
bytesEdit->setData( data, dataSize, -1 );
bytesEdit->setMaxDataSize( dataSize );
bytesEdit->setReadOnly( false );
bytesEdit->setAutoDelete( true );
KHE::ValueColumnInterface *valueColumn = KHE::valueColumnInterface( bytesEditWidget );
if( valueColumn )
{
valueColumn->setCoding( KHE::ValueColumnInterface::BinaryCoding );
valueColumn->setByteSpacingWidth( 2 );
valueColumn->setNoOfGroupedBytes( 4 );
valueColumn->setGroupSpacingWidth( 12 );
}
KHE::CharColumnInterface *charColumn = KHE::charColumnInterface( bytesEditWidget );
if( charColumn )
{
charColumn->setShowUnprintable( false );
charColumn->setSubstituteChar( '*' );
}
KHE::ClipboardInterface *clipboard = KHE::clipboardInterface( bytesEditWidget );
if( clipboard )
{
// Yes, use bytesEditWidget, not clipboard, because that's the QObject, indeed hacky...
connect( bytesEditWidget, SIGNAL(copyAvailable(bool)), this, SLOT(offerCopy(bool)) );
}
}
// now you can use bytesEditWidget like any other widget object...
byteseditinterface.h
charcolumninterface.h
KHE::BytesEditInterface
An interface for a hex edit editor/viewer for arrays of byte.
Definition: byteseditinterface.h:74
KHE::BytesEditInterface::setReadOnly
virtual void setReadOnly(bool RO=true)=0
sets whether the given array should be handled read only or not.
KHE::BytesEditInterface::setMaxDataSize
virtual void setMaxDataSize(int MS)=0
sets the maximal size of the actual byte array.
KHE::BytesEditInterface::setData
virtual void setData(char *D, int S, int RS=-1, bool KM=true)=0
hands over to the editor a new byte array.
KHE::BytesEditInterface::setAutoDelete
virtual void setAutoDelete(bool AD=true)=0
sets whether the array should be deleted on the widget's end or if a new array is set.
KHE::CharColumnInterface
A simple interface for the access to the char column of a hex edit widget.
Definition: charcolumninterface.h:34
KHE::CharColumnInterface::setSubstituteChar
virtual void setSubstituteChar(QChar SC)=0
sets the substitute character for "unprintable" chars Default is '.
KHE::CharColumnInterface::setShowUnprintable
virtual void setShowUnprintable(bool SU=true)=0
sets whether "unprintable" chars (value<32) should be displayed in the text column with their corresp...
KHE::ClipboardInterface
A simple interface for interaction with the clipboard.
Definition: clipboardinterface.h:48
KHE::ValueColumnInterface
Interface for the value displaying column of a hexedit widget.
Definition: valuecolumninterface.h:34
KHE::ValueColumnInterface::setCoding
virtual void setCoding(KCoding C)=0
sets the format of the hex column.
KHE::ValueColumnInterface::setByteSpacingWidth
virtual void setByteSpacingWidth(int BSW)=0
sets the spacing between the bytes.
KHE::ValueColumnInterface::BinaryCoding
@ BinaryCoding
bit by bit coding
Definition: valuecolumninterface.h:49
KHE::ValueColumnInterface::setGroupSpacingWidth
virtual void setGroupSpacingWidth(int GSW)=0
sets the spacing between the groups.
KHE::ValueColumnInterface::setNoOfGroupedBytes
virtual void setNoOfGroupedBytes(int NoGB)=0
sets the numbers of grouped bytes, 0 means no grouping.
QLabel
QWidget
clipboardinterface.h
i18n
QString i18n(const char *text)
KHE::charColumnInterface
CharColumnInterface * charColumnInterface(T *t)
tries to get the charcolumn interface of t
Definition: charcolumninterface.h:97
KHE::bytesEditInterface
BytesEditInterface * bytesEditInterface(T *t)
tries to get the bytesedit interface of t
Definition: byteseditinterface.h:153
KHE::valueColumnInterface
ValueColumnInterface * valueColumnInterface(T *t)
tries to get the valuecolumn interface of t
Definition: valuecolumninterface.h:163
KHE::clipboardInterface
ClipboardInterface * clipboardInterface(T *t)
tries to get the clipboard interface of t
Definition: clipboardinterface.h:79
KHE::createBytesEditWidget
QWidget * createBytesEditWidget(QWidget *Parent=0)
tries to create an instance of a hexedit widget for arrays of chars (char[])
Definition: byteseditinterface.h:165
valuecolumninterface.h

Notes

As the KHexEdit interfaces are header-only, you don't need to link against any additional libraries.

Author(s):
Friedrich W. H. Kossebau <kossebau@kde.org>
Maintainer(s):
Friedrich W. H. Kossebau <kossebau@kde.org>
License(s):
LGPLv2
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KHexEdit

Skip menu "KHexEdit"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Members
  • File List
  • Related Pages

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal