qt_ival_box.h
1.19 KB
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
49
50
51
52
53
54
55
56
#include "ival_box.h"
#include <iostream>
using namespace std;
#include <QtGui>
class QT_ival_slider : public Ival_box // interface
,
protected QDialog // implementation
{
private:
int lastval;
QSlider* slider;
public:
QT_ival_slider(QWidget* parent = 0) : QDialog(parent), lastval(-1)
{
slider = new QSlider(Qt::Horizontal);
slider->setRange(0, 99);
slider->setValue(0);
QPushButton* qb = new QPushButton("OK", this);
QVBoxLayout* layout = new QVBoxLayout;
layout->addWidget(slider);
layout->addWidget(qb);
setLayout(layout);
QObject::connect(qb, SIGNAL(clicked()), this, SLOT(accept()));
};
virtual int get_value()
{
return slider->sliderPosition();
};
virtual void set_value(int i)
{
slider->setSliderPosition(i);
};
virtual void reset_value(int i)
{
slider->setSliderPosition(i);
lastval = i;
};
virtual void prompt()
{
show();
exec();
hide();
};
virtual bool was_changed() const
{
return slider->sliderPosition() != lastval;
};
virtual ~QT_ival_slider(){};
};