-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathspinbox.h
More file actions
49 lines (38 loc) · 801 Bytes
/
Copy pathspinbox.h
File metadata and controls
49 lines (38 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef SPINBOX_H
#define SPINBOX_H
#include <QString>
#include <QDoubleSpinBox>
#include <QValidator>
#include <inttypes.h>
class SpinBox : public QDoubleSpinBox
{
Q_OBJECT
public:
SpinBox(QWidget *parent = 0) : QDoubleSpinBox(parent)
{
}
void setDisplayIntegerBase(int)
{
}
protected:
QString textFromValue(double value) const
{
uint32_t v = value;
return QString::number(v, 16).toUpper();
}
double valueFromText(const QString &text) const
{
//bool ok;
return text.toUInt(0, 16);//text.toLongLong(&ok, 16);
}
virtual QValidator::State validate(QString &text, int &) const
{
bool okay;
text.toUInt(&okay, 16);
if (!okay)
return QValidator::Invalid;
QValidator::State state = QValidator::Acceptable;
return state;
}
};
#endif