Skip to content

Instantly share code, notes, and snippets.

@ArthurSonzogni
Created April 13, 2016 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ArthurSonzogni/7c379708d9ee09b09fe429e7442d6692 to your computer and use it in GitHub Desktop.
Save ArthurSonzogni/7c379708d9ee09b09fe429e7442d6692 to your computer and use it in GitHub Desktop.
/// ----------------------------------------------------------
/// Author : ArthurSonzogni
/// License : MIT
/// Description : wrap a QVboxLayout into a QScrollArea
/// if the QVBoxLayout is to big, a scroll bar
/// appear and let the user scroll
/// ----------------------------------------------------------
#ifndef BUILDSCROLLABLEWIDGETLIST_H
#define BUILDSCROLLABLEWIDGETLIST_H
#include <QScrollArea>
#include <QVBoxLayout>
#include <QWidget>
static inline QScrollArea* buildScrollableWidgetList(QVBoxLayout* list)
{
auto scroll = new QScrollArea;
scroll->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
scroll->setWidgetResizable(true);
auto w = new QWidget;
w->setLayout(list);
scroll->setWidget(w);
return scroll;
}
#endif /* end of include guard: BUILDSCROLLABLEWIDGETLIST_H */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment