You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

verticalscrollarea.cpp 575B

12345678910111213141516171819202122
  1. #include "verticalscrollarea.h"
  2. #include <QVBoxLayout>
  3. VerticalScrollArea::VerticalScrollArea(QWidget *parent) : QScrollArea(parent)
  4. {
  5. setWidgetResizable(true);
  6. }
  7. void VerticalScrollArea::setWidget(QWidget *widget)
  8. {
  9. if(widget != 0)
  10. widget->installEventFilter(this);
  11. QScrollArea::setWidget(widget);
  12. }
  13. bool VerticalScrollArea::eventFilter(QObject *o, QEvent *e)
  14. {
  15. if(o == widget() && e->type() == QEvent::Resize)
  16. setMinimumWidth(widget()->minimumSizeHint().width() + verticalScrollBar()->width());
  17. return false;
  18. }