summaryrefslogtreecommitdiffstats
path: root/examples/widgets/widgets/sliders/window.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/widgets/widgets/sliders/window.cpp')
-rw-r--r--examples/widgets/widgets/sliders/window.cpp41
1 files changed, 36 insertions, 5 deletions
diff --git a/examples/widgets/widgets/sliders/window.cpp b/examples/widgets/widgets/sliders/window.cpp
index 916f206379..fc6ac6f193 100644
--- a/examples/widgets/widgets/sliders/window.cpp
+++ b/examples/widgets/widgets/sliders/window.cpp
@@ -50,10 +50,8 @@
#include "slidersgroup.h"
#include "window.h"
-
#include <QCheckBox>
#include <QComboBox>
-#include <QHBoxLayout>
#include <QLabel>
#include <QSpinBox>
#include <QStackedWidget>
@@ -81,9 +79,10 @@ Window::Window(QWidget *parent)
connect(valueSpinBox, &QSpinBox::valueChanged,
horizontalSliders, &SlidersGroup::setValue);
- QHBoxLayout *layout = new QHBoxLayout;
- layout->addWidget(controlsGroup);
- layout->addWidget(stackedWidget);
+ layout = new QGridLayout;
+ layout->addWidget(stackedWidget, 0, 1);
+ layout->addWidget(controlsGroup, 0, 0);
+
setLayout(layout);
minimumSpinBox->setValue(0);
@@ -157,5 +156,37 @@ void Window::createControls(const QString &title)
controlsLayout->addWidget(invertedKeyBindings, 1, 2);
controlsLayout->addWidget(orientationCombo, 3, 0, 1, 3);
controlsGroup->setLayout(controlsLayout);
+
}
//! [8]
+
+
+void Window::resizeEvent(QResizeEvent *e)
+{
+ if (width() == 0 || height() == 0)
+ return;
+
+ const double aspectRatio = double(width()) / double(height());
+
+ if ((aspectRatio < 1.0) && (oldAspectRatio > 1.0)) {
+ layout->removeWidget(controlsGroup);
+ layout->removeWidget(stackedWidget);
+
+ layout->addWidget(stackedWidget, 1, 0);
+ layout->addWidget(controlsGroup, 0, 0);
+
+ oldAspectRatio = aspectRatio;
+ }
+ else if ((aspectRatio > 1.0) && (oldAspectRatio < 1.0)) {
+ layout->removeWidget(controlsGroup);
+ layout->removeWidget(stackedWidget);
+
+ layout->addWidget(stackedWidget, 0, 1);
+ layout->addWidget(controlsGroup, 0, 0);
+
+ oldAspectRatio = aspectRatio;
+ }
+}
+
+
+