BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
adjustingscrollarea.cpp
Go to the documentation of this file.
1 // ************************************************************************************************
2 //
3 // qt-mvvm: Model-view-view-model framework for large GUI applications
4 //
5 //! @file mvvm/view/mvvm/widgets/adjustingscrollarea.cpp
6 //! @brief Implements class CLASS?
7 //!
8 //! @homepage http://www.bornagainproject.org
9 //! @license GNU General Public License v3 or higher (see COPYING)
10 //! @copyright Forschungszentrum Jülich GmbH 2020
11 //! @authors Gennady Pospelov et al, Scientific Computing Group at MLZ (see CITATION, AUTHORS)
12 //
13 // ************************************************************************************************
14 
16 #include <QEvent>
17 #include <QScrollBar>
18 
19 using namespace ModelView;
20 
21 AdjustingScrollArea::AdjustingScrollArea(QWidget* parent) : 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 }
29 
31 {
32  QScrollArea::setWidget(w);
33  w->installEventFilter(this);
34 }
35 
37 {
38  auto horizontal = horizontalScrollBar();
39  QSize result(viewport()->width(), widget()->height() + horizontal->height() * 2);
40  return result;
41 }
42 
43 bool AdjustingScrollArea::eventFilter(QObject* obj, QEvent* ev)
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 }
Defines class CLASS?
bool eventFilter(QObject *obj, QEvent *ev)
materialitems.h Collection of materials to populate MaterialModel.