-
Notifications
You must be signed in to change notification settings - Fork 0
/
customwidgets.cpp
92 lines (80 loc) · 3.1 KB
/
customwidgets.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
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include "customwidgets.h"
LabelHexSpinBox::LabelHexSpinBox(QWidget *parent, QString text, int value) : QWidget(parent)
{
type = value;
m_Label= new QLabel(text);
(type==0)?m_HexSpinBox = new HexSpinBox:m_QSpinBox = new QSpinBox;
m_Label->setBuddy((type==0)?m_HexSpinBox:m_QSpinBox);
m_HBoxLayout= new QHBoxLayout;
m_HBoxLayout->setSizeConstraint(QLayout::SetFixedSize);
m_HBoxLayout->addWidget(m_Label);
m_HBoxLayout->addWidget((type==0)?m_HexSpinBox:m_QSpinBox);
(type==0)?m_HexSpinBox->setMinimumWidth(90):m_QSpinBox->setMinimumWidth(90);
(type==0)?connect(m_HexSpinBox,SIGNAL(valueChanged(int)),this,SLOT(setValue(int))):
connect(m_QSpinBox,SIGNAL(valueChanged(int)),this,SLOT(setValue(int)));
(type==0)?connect(this,SIGNAL(valueChanged(int)),m_HexSpinBox,SLOT(setValue(int))):
connect(this,SIGNAL(valueChanged(int)),m_QSpinBox,SLOT(setValue(int)));
this->setLayout(m_HBoxLayout);
}
void LabelHexSpinBox::setRange(int value1, int value2)
{
(type==0)?m_HexSpinBox->setRange(value1,value2):m_QSpinBox->setRange(value1,value2);
}
SectionDescriptor::SectionDescriptor(QWidget *parent, QString text)
: QGroupBox(parent)
{
this->setTitle(text);
m_HBoxLayout= new QHBoxLayout;
m_HBoxLayout->setSizeConstraint(QLayout::SetFixedSize);
this->setLayout(m_HBoxLayout);
}
SectionLoop::SectionLoop(QWidget *parent, QString text)
: QGroupBox(parent)
{
this->setTitle(text);
m_VBoxLayout= new QVBoxLayout;
m_VBoxLayout->setSizeConstraint(QLayout::SetFixedSize);
this->setLayout(m_VBoxLayout);
}
ElementSectionDescriptor::ElementSectionDescriptor(QWidget *parent)
: QWidget(parent)
{
m_HBoxLayout = new QHBoxLayout;
m_HBoxLayout->setSizeConstraint(QLayout::SetFixedSize);
this->setLayout(m_HBoxLayout);
}
ElementDescriptor::ElementDescriptor(QWidget *parent, QStringList *StringList)
: QWidget(parent)
{
m_HBoxLayout = new QHBoxLayout;
m_HBoxLayout->setSizeConstraint(QLayout::SetFixedSize);
this->setLayout(m_HBoxLayout);
m_QStringList=*StringList;
if(StringList->size()>2)
{
foreach (QString string, m_QStringList) {
qDebug()<<string<<m_QStringList.size();
m_HBoxLayout->addWidget(new QLabel(string));
m_HBoxLayout->addWidget(new HexSpinBox);
}
}
}
LabelLineEdit::LabelLineEdit(QWidget *parent, QString text)
: QWidget(parent)
{
m_Label = new QLabel(text);
m_LineEdit = new QLineEdit;
m_Label->setBuddy(m_LineEdit);
m_HBoxLayout = new QHBoxLayout;
m_HBoxLayout->setSizeConstraint(QLayout::SetFixedSize);
m_HBoxLayout->addWidget(m_Label);
m_HBoxLayout->addWidget(m_LineEdit);
connect(m_LineEdit,SIGNAL(textChanged(QString)),this,SLOT(setText(QString)));
connect(this,SIGNAL(textChanged(QString)),m_LineEdit,SLOT(setText(QString)));
this->setLayout(m_HBoxLayout);
}
void LabelLineEdit::setLength(int length){
m_LineEdit->setMaxLength(length);
m_LineEdit->setMaximumWidth(11*length);
m_LineEdit->setMinimumWidth(11*length);
}