-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathQtSerialConfigBox.cpp
More file actions
53 lines (44 loc) · 976 Bytes
/
QtSerialConfigBox.cpp
File metadata and controls
53 lines (44 loc) · 976 Bytes
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
#include "QtSerialConfigBox.h"
QtSerialConfigBox::QtSerialConfigBox(std::vector<std::string> ports, QWidget* parent)
: QWidget(parent)
{
ui.setupUi(this);
for (std::string p : ports)
{
ui.portComboBox->addItem(p.c_str());
}
setAttribute(Qt::WA_DeleteOnClose);
connect(ui.deleteSerialDevice, &QToolButton::clicked, this, &QtSerialConfigBox::close);
adjustParentHeight(0);
}
QtSerialConfigBox::~QtSerialConfigBox()
{
adjustParentHeight(1);
}
Ui::QtSerialConfigBox* QtSerialConfigBox::getUi()
{
return &ui;
}
void QtSerialConfigBox::adjustParentHeight(int offset)
{
try
{
QWidget* parent = parentWidget();
QObjectList children = parent->children();
int contentHeight = 0;
if (children.size() > 1)
{
for (int i = 1; i < children.size() - offset; i++)
{
QWidget* child = (QWidget*)children[i];
if (child)
{
contentHeight += child->height() + 10;
}
}
parent->setFixedHeight(contentHeight);
}
}
catch(...)
{ }
}