-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathOdorantConfigBox.cpp
More file actions
53 lines (44 loc) · 962 Bytes
/
OdorantConfigBox.cpp
File metadata and controls
53 lines (44 loc) · 962 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 "OdorantConfigBox.h"
OdorantConfigBox::OdorantConfigBox(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
for (int i = 0; i < ui.odorantComboBox->count(); i++)
{
ui.odorantComboBox->setItemData(i, i + 1);
}
setAttribute(Qt::WA_DeleteOnClose);
connect(ui.deleteOdorant, &QToolButton::clicked, this, &OdorantConfigBox::close);
adjustParentHeight(0);
}
OdorantConfigBox::~OdorantConfigBox()
{
adjustParentHeight(1);
}
Ui::OdorantConfigBox* OdorantConfigBox::getUi()
{
return &ui;
}
void OdorantConfigBox::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(...)
{}
}