OpenHantek
Loading...
Searching...
No Matches
sispinbox.h
1// SPDX-License-Identifier: GPL-2.0+
2
3#pragma once
4
5#include <QDoubleSpinBox>
6#include <QStringList>
7
8#include "utils/printutils.h"
9
14class SiSpinBox : public QDoubleSpinBox {
15 Q_OBJECT
16
17 public:
18 explicit SiSpinBox(QWidget *parent = 0);
19 SiSpinBox(Unit unit, QWidget *parent = 0);
20 ~SiSpinBox();
21
22 QValidator::State validate(QString &input, int &pos) const;
23 double valueFromText(const QString &text) const;
24 QString textFromValue(double val) const;
25 void fixup(QString &input) const;
26 void stepBy(int steps);
27 bool setUnit(Unit unit);
28 void setUnitPostfix(const QString &postfix);
29 void setSteps(const QList<double> &steps);
30 void setMode(const int mode);
31
32 private:
33 void init();
34 void setBackground();
35
36 Unit unit;
37 QString unitPostfix;
38 QList<double> steps;
39 int mode;
40
41 bool steppedTo;
42 int stepId;
43
44 signals:
45
46 private slots:
47 void resetSteppedTo();
48};
A spin box with SI prefix support. This spin box supports the SI prefixes (k/M/G/T) after its value a...
Definition sispinbox.h:14
bool setUnit(Unit unit)
Set the unit for this spin box.
Definition sispinbox.cpp:142
void setSteps(const QList< double > &steps)
Set the steps the spin box will take.
Definition sispinbox.cpp:156
~SiSpinBox()
Cleans up the main window.
Definition sispinbox.cpp:49
void stepBy(int steps)
Increase/decrease the values in fixed steps.
Definition sispinbox.cpp:90
QString textFromValue(double val) const
Get string representation of value.
Definition sispinbox.cpp:75
SiSpinBox(QWidget *parent=0)
Initializes the SiSpinBox internals.
Definition sispinbox.cpp:35
void setUnitPostfix(const QString &postfix)
Set the unit postfix for this spin box.
Definition sispinbox.cpp:151
void fixup(QString &input) const
Fixes the text after the user finished changing it.
Definition sispinbox.cpp:79
double valueFromText(const QString &text) const
Parse value from input text.
Definition sispinbox.cpp:70
void setMode(const int mode)
Set the mode.
Definition sispinbox.cpp:161
QValidator::State validate(QString &input, int &pos) const
Validates the text after user input.
Definition sispinbox.cpp:55