BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
ModelView::AdjustingScrollArea Class Reference

Modification of standard scroll area, which makes widget with dynamic layout occupy the whole available space. More...

Inheritance diagram for ModelView::AdjustingScrollArea:
[legend]
Collaboration diagram for ModelView::AdjustingScrollArea:
[legend]

Public Member Functions

 AdjustingScrollArea (QWidget *parent=0)
 
void setWidget (QWidget *w)
 
QSize sizeHint () const
 

Private Member Functions

bool eventFilter (QObject *obj, QEvent *ev)
 

Detailed Description

Modification of standard scroll area, which makes widget with dynamic layout occupy the whole available space.

Definition at line 26 of file adjustingscrollarea.h.

Constructor & Destructor Documentation

◆ AdjustingScrollArea()

AdjustingScrollArea::AdjustingScrollArea ( QWidget *  parent = 0)

Definition at line 21 of file adjustingscrollarea.cpp.

21  : QScrollArea(parent)
22 {
23  setObjectName("AdjustingScrollArea");
24  setContentsMargins(0, 0, 0, 0);
25  setWidgetResizable(true);
26  setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
27  setStyleSheet("QScrollArea#AdjustingScrollArea {border: 0px; background-color:transparent;}");
28 }

Member Function Documentation

◆ eventFilter()

bool AdjustingScrollArea::eventFilter ( QObject *  obj,
QEvent *  ev 
)
private

Definition at line 43 of file adjustingscrollarea.cpp.

44 {
45  if (obj == widget() && ev->type() != QEvent::Resize) {
46  widget()->setMaximumWidth(viewport()->width());
47  setMaximumHeight(height() - viewport()->height() + widget()->height());
48  }
49 
50  return QScrollArea::eventFilter(obj, ev);
51 }

◆ setWidget()

void AdjustingScrollArea::setWidget ( QWidget *  w)

Definition at line 30 of file adjustingscrollarea.cpp.

31 {
32  QScrollArea::setWidget(w);
33  w->installEventFilter(this);
34 }

Referenced by gui2::RecentProjectWidget::createRecentProjectScrollArea().

◆ sizeHint()

QSize AdjustingScrollArea::sizeHint ( ) const

Definition at line 36 of file adjustingscrollarea.cpp.

37 {
38  auto horizontal = horizontalScrollBar();
39  QSize result(viewport()->width(), widget()->height() + horizontal->height() * 2);
40  return result;
41 }

The documentation for this class was generated from the following files: