BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
layoututils.h
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/layoututils.h
6 //! @brief Defines 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 
15 #ifndef BORNAGAIN_MVVM_VIEW_MVVM_WIDGETS_LAYOUTUTILS_H
16 #define BORNAGAIN_MVVM_VIEW_MVVM_WIDGETS_LAYOUTUTILS_H
17 
18 #include "mvvm/view_export.h"
19 
20 class QLayout;
21 class QGridLayout;
22 class QWidget;
23 
24 //! @namespace LayoutUtils
25 //! @brief Utility functions to add/remove widgets to the layout on the fly.
26 //! Taken from https://stackoverflow.com/questions/5395266/removing-widgets-from-qgridlayout
27 //! Caveat: according to explanations given, grid layouts can only grow and never shrink.
28 
29 namespace LayoutUtils {
30 
31 //! Removes content from box layout.
32 MVVM_VIEW_EXPORT void clearLayout(QLayout* layout, bool deleteWidgets = true);
33 
34 //! Removes row from grid layout (important: doesn't change row count).
35 MVVM_VIEW_EXPORT void removeRow(QGridLayout* layout, int row, bool deleteWidgets = true);
36 
37 //! Removes column from grid layout.
38 MVVM_VIEW_EXPORT void removeColumn(QGridLayout* layout, int column, bool deleteWidgets = true);
39 
40 //! Clear layout completely.
41 MVVM_VIEW_EXPORT void clearGridLayout(QGridLayout* layout, bool deleteWidgets = true);
42 
43 //! Returns empty widget to occupy place in layout.
44 MVVM_VIEW_EXPORT QWidget* placeHolder();
45 
46 } // namespace LayoutUtils
47 
48 #endif // BORNAGAIN_MVVM_VIEW_MVVM_WIDGETS_LAYOUTUTILS_H
Utility functions to add/remove widgets to the layout on the fly.
Definition: LayoutUtils.h:25
void removeRow(QGridLayout *layout, int row, bool deleteWidgets=true)
Removes row from grid layout (important: doesn't change row count).
Definition: LayoutUtils.cpp:58
void removeColumn(QGridLayout *layout, int column, bool deleteWidgets=true)
Removes column from grid layout.
Definition: LayoutUtils.cpp:74
void clearLayout(QLayout *layout, bool deleteWidgets=true)
Removes content from box layout.
Definition: LayoutUtils.cpp:21
QWidget * placeHolder()
Returns empty widget to occupy place in layout.
void clearGridLayout(QGridLayout *layout, bool deleteWidgets=true)
Clear layout completely.
Definition: LayoutUtils.cpp:81