allow current widget to dictate size of stacked widget for metatile/collision and events pages

This commit is contained in:
garakmon
2020-04-30 19:44:54 -04:00
committed by huderlem
parent ac92534576
commit 37c849f9b5
4 changed files with 33 additions and 1 deletions

View File

@@ -0,0 +1,25 @@
#ifndef ADJUSTINGSTACKEDWIDGET_H
#define ADJUSTINGSTACKEDWIDGET_H
#include <QStackedWidget>
class AdjustingStackedWidget : public QStackedWidget
{
Q_OBJECT
public:
AdjustingStackedWidget(QWidget *parent = nullptr) : QStackedWidget(parent) {}
// override this to allow the stacked widget's current page to dictate size
virtual void setCurrentIndex(int index) {
QStackedWidget::setCurrentIndex(index);
for (int i = 0; i < this->count(); ++i) {
this->widget(i)->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
}
this->widget(index)->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
}
};
#endif // ADJUSTINGSTACKEDWIDGET_H