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

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

Inheritance diagram for AdjustingScrollArea:
[legend]
Collaboration diagram for 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 ocuupy whole available space.

Definition at line 23 of file AdjustingScrollArea.h.

Constructor & Destructor Documentation

◆ AdjustingScrollArea()

AdjustingScrollArea::AdjustingScrollArea ( QWidget *  parent = 0)

Definition at line 19 of file AdjustingScrollArea.cpp.

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

Member Function Documentation

◆ eventFilter()

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

Definition at line 41 of file AdjustingScrollArea.cpp.

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

◆ setWidget()

void AdjustingScrollArea::setWidget ( QWidget *  w)

Definition at line 28 of file AdjustingScrollArea.cpp.

29 {
30  QScrollArea::setWidget(w);
31  w->installEventFilter(this);
32 }

Referenced by InstrumentEditorWidget::InstrumentEditorWidget().

◆ sizeHint()

QSize AdjustingScrollArea::sizeHint ( ) const

Definition at line 34 of file AdjustingScrollArea.cpp.

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

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