Commit e93ddb81 authored by oberion's avatar oberion

Added HexSpinBox files

parent d4616625
#include "HexSpinBox.h"
#include <qregexp.h>
HexSpinBox::HexSpinBox(QWidget *parent)
: QSpinBox(parent), validator(NULL)
{
setRange(0, 0x7fffffff);
validator = new QRegExpValidator(QRegExp("[0-9A-Fa-f]{1,8}"), this);
}
HexSpinBox::~HexSpinBox(void)
{
if(this->validator)
{
delete this->validator;
this->validator = NULL;
}
}
QValidator::State HexSpinBox::validate(QString &text, int &pos) const
{
return validator->validate(text, pos);
}
QString HexSpinBox::textFromValue(int value) const
{
return QString::number(value, 16).toUpper();
}
int HexSpinBox::valueFromText(const QString &text) const
{
bool ok;
return text.toInt(&ok, 16);
}
\ No newline at end of file
#ifndef HEXSPINBOX_H_
#define HEXSPINBOX_H_
#include <qspinbox.h>
class QRegExpValidator;
class HexSpinBox : public QSpinBox
{
Q_OBJECT
public:
HexSpinBox(QWidget *parent = 0);
~HexSpinBox(void);
protected:
QValidator::State validate(QString &text, int &pos) const;
int valueFromText(const QString &text) const;
QString textFromValue(int value) const;
private:
QRegExpValidator *validator;
};
#endif // HEXSPINBOX_H_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment