-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwidgetscrollarea.cpp
More file actions
90 lines (76 loc) · 2.87 KB
/
Copy pathwidgetscrollarea.cpp
File metadata and controls
90 lines (76 loc) · 2.87 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include "widgetscrollarea.h"
#include <QVBoxLayout>
#include <QScrollArea>
#include <QFontMetrics>
#include <QSpacerItem>
#include "widgets.h"
#include "widgetsettings.h"
WidgetScrollArea::WidgetScrollArea(const QString &caption,
const QString hint,
QWidget *parent) :
QWidget(parent),
m_helpLabel(WidgetSettings::newHelpLabel()),
m_buttonLayout(new QVBoxLayout()),
m_scrollArea(new QScrollArea())
{
m_helpLabel->setText(hint);
m_centralWidget = new QWidget(this);
QVBoxLayout *totalLayout = new QVBoxLayout(this);
totalLayout->setContentsMargins(0, 0, 0, 0);
QVBoxLayout *centralLayout = new QVBoxLayout(m_centralWidget);
m_centralWidget->setLayout(centralLayout);
centralLayout->setContentsMargins(UI_LIST_LEFTMARGIN,
UI_LIST_BOTTOMTOPMARGIN,
UI_LIST_RIGHTMARGIN,
UI_LIST_BOTTOMTOPMARGIN);
centralLayout->setSpacing(0);
centralLayout->setAlignment(Qt::AlignHCenter | Qt::AlignTop);
m_buttonLayout->setContentsMargins(0, 0, 0, 0);
m_buttonLayout->setSpacing(0);
m_buttonLayout->setAlignment(m_buttonLayout, Qt::AlignRight | Qt::AlignVCenter);
m_centralWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_heading = WidgetSettings::newHeading3Label();
m_heading->setText(caption);
totalLayout->addWidget(m_heading);
//m_buttonLayout->addWidget(m_helpLabel);
QHBoxLayout *sideBySide = new QHBoxLayout();
sideBySide->addWidget(m_scrollArea);
sideBySide->addLayout(m_buttonLayout);
totalLayout->addLayout(sideBySide);
totalLayout->addWidget(m_helpLabel);
m_scrollArea->setWidget(m_centralWidget);
m_scrollArea->setWidgetResizable(true);
m_scrollArea->setFrameRect(QRect(0, 0, 0, 0));
m_scrollArea->setFrameShape(QFrame::NoFrame);
this->setLayout(totalLayout);
}
void WidgetScrollArea::append(QWidget *w)
{
m_centralWidget->layout()->addWidget(w);
}
void WidgetScrollArea::addButton(QWidget *b)
{
for (int i = 0; i < m_buttonLayout->count(); i++)
{
QSpacerItem *si = m_buttonLayout->itemAt(i)->spacerItem();
if (si)
{
m_buttonLayout->removeItem(si);
delete si;
i--;
}
}
/*m_buttonLayout->insertItem(0, new QSpacerItem(0, 10,
QSizePolicy::Expanding,
QSizePolicy::Ignored));*/
m_buttonLayout->addWidget(b);
m_buttonLayout->addSpacerItem(new QSpacerItem(0, 0,
QSizePolicy::Maximum,
QSizePolicy::Expanding));
}
void WidgetScrollArea::enterEvent(QEvent *e)
{
}
void WidgetScrollArea::leaveEvent(QEvent *e)
{
}