-
Notifications
You must be signed in to change notification settings - Fork 0
/
pointform.cpp
50 lines (40 loc) · 1.34 KB
/
pointform.cpp
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
#include "pointform.h"
PointForm::PointForm(QWidget *parent) : QDialog(parent)
{
this->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
QVBoxLayout *main_lt = new QVBoxLayout();
QHBoxLayout *arg_lt = new QHBoxLayout();
arg_lt->addWidget(new QLabel("x: "));
arg_in = new QDoubleSpinBox();
arg_in->setRange(-5000, 5000);
arg_lt->addWidget(arg_in);
QHBoxLayout *val_lt = new QHBoxLayout();
val_lt->addWidget(new QLabel("y: "));
val_in = new QDoubleSpinBox();
val_in->setRange(-5000, 5000);
val_lt->addWidget(val_in);
QHBoxLayout *menu_lt = new QHBoxLayout();
add_btn = new QPushButton("Add");
cancel_btn = new QPushButton("Cancel");
menu_lt->addSpacerItem(new QSpacerItem(10,10, QSizePolicy::Expanding));
menu_lt->addWidget(add_btn);
menu_lt->addWidget(cancel_btn);
main_lt->addLayout(arg_lt);
main_lt->addLayout(val_lt);
main_lt->addSpacing(40);
main_lt->addLayout(menu_lt);
this->setLayout(main_lt);
connect(this->add_btn, SIGNAL(clicked(bool)), this, SLOT(onAdd()));
connect(this->cancel_btn, SIGNAL(clicked(bool)), this, SLOT(close()));
this->show();
}
void PointForm::onAdd()
{
emit save(arg_in->value(), val_in->value());
this->accept();
}
void PointForm::set(double x, double y)
{
arg_in->setValue(x);
val_in->setValue(y);
}