-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRectEditorWidget.cpp
More file actions
executable file
·76 lines (63 loc) · 1.81 KB
/
RectEditorWidget.cpp
File metadata and controls
executable file
·76 lines (63 loc) · 1.81 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "RectEditorWidget.h"
#include <QBoxLayout>
#include <QLabel>
#include <QSpinBox>
RectEditorWidget::RectEditorWidget(QWidget *parent) : QWidget(parent)
{
setAutoFillBackground(true);
// Position Widgets
QWidget* posWrap = new QWidget;
QLabel* posLabel = new QLabel("Pos");
spinBoxX = new QSpinBox;
spinBoxX->setMinimum(-10000);
spinBoxX->setMaximum(10000);
spinBoxY = new QSpinBox;
spinBoxY->setMinimum(-10000);
spinBoxY->setMaximum(10000);
QHBoxLayout* posLayout = new QHBoxLayout(posWrap);
posLayout->setMargin(0);
posLayout->setContentsMargins(0, 0, 0, 0);
posLayout->setSpacing(0);
posLayout->addWidget(posLabel);
posLayout->addWidget(spinBoxX);
posLayout->addWidget(spinBoxY);
// Size Widgets
QWidget* sizeWrap = new QWidget;
QLabel* sizeLabel = new QLabel("Size");
spinBoxW = new QSpinBox;
spinBoxW->setMinimum(0);
spinBoxW->setMaximum(10000);
spinBoxH = new QSpinBox;
spinBoxH->setMinimum(0);
spinBoxH->setMaximum(10000);
QHBoxLayout* sizeLayout = new QHBoxLayout(sizeWrap);
sizeLayout->setMargin(0);
sizeLayout->setContentsMargins(0, 0, 0, 0);
sizeLayout->setSpacing(0);
sizeLayout->addWidget(sizeLabel);
sizeLayout->addWidget(spinBoxW);
sizeLayout->addWidget(spinBoxH);
// Main layout
QVBoxLayout* editorLayout = new QVBoxLayout(this);
editorLayout->setMargin(0);
editorLayout->setContentsMargins(0, 0, 0, 0);
editorLayout->setSpacing(0);
editorLayout->addWidget(posWrap);
editorLayout->addWidget(sizeWrap);
}
void RectEditorWidget::setRect(QRect rect)
{
spinBoxX->setValue(rect.x());
spinBoxY->setValue(rect.y());
spinBoxW->setValue(rect.width());
spinBoxH->setValue(rect.height());
}
QRect RectEditorWidget::getRect()
{
QRect rect;
rect.setX(spinBoxX->value());
rect.setY(spinBoxY->value());
rect.setWidth(spinBoxW->value());
rect.setHeight(spinBoxH->value());
return rect;
}