mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-19 23:25:09 -05:00
allow current widget to dictate size of stacked widget for metatile/collision and events pages
This commit is contained in:
25
include/ui/adjustingstackedwidget.h
Normal file
25
include/ui/adjustingstackedwidget.h
Normal 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
|
||||
Reference in New Issue
Block a user