source: trunk/FACT++/gui/SpinBoxHex.h@ 11618

Last change on this file since 11618 was 11104, checked in by tbretz, 13 years ago
Properly display a 32bit word.
File size: 932 bytes
Line 
1#ifndef FACT_SpinBoxHex
2#define FACT_SpinBoxHex
3
4#include <QSpinBox>
5
6#include <iostream>
7class QRegExpValidator;
8
9class SpinBoxHex : public QSpinBox
10{
11public:
12 SpinBoxHex(QWidget *p=0) : QSpinBox(p)
13 {
14 }
15
16protected:
17 QValidator::State validate(QString &txt, int &/*pos*/) const
18 {
19 bool ok;
20 txt.toInt(&ok, 16);
21
22 return ok ? QValidator::Acceptable : QValidator::Invalid;
23 }
24
25 QString textFromValue(int val) const
26 {
27 return QString::number(val, 16).right(8).rightJustified(8, '0').toLower().insert(4, ':');
28 }
29
30 int valueFromText(const QString &txt) const
31 {
32 bool ok;
33 return txt.toInt(&ok, 16);
34 }
35};
36
37#endif
38
39// **************************************************************************
40/** @class SpinBoxHex
41
42@brief A QSpinBox which displays the value as hex-value
43
44*/
45// **************************************************************************
Note: See TracBrowser for help on using the repository browser.