diff options
author | Assam Boudjelthia <[email protected]> | 2020-02-23 23:37:11 +0200 |
---|---|---|
committer | Assam Boudjelthia <[email protected]> | 2020-03-03 19:35:46 +0200 |
commit | b711ee255515440b923a898f65f6afe13d63916f (patch) | |
tree | 3dfeb07f8ac246a1dc041f9b3d0024e707e6c745 | |
parent | 8a6e1de87c32fcbf8d7946f688635a3ca2a78203 (diff) |
Examples: add scrollbar to allow viewing all options on Android
This fix is most relevant for Android for affine and gradients examples.
Currently, if the screen size is small the settings will show cramped
and not usable. Thus, adding a scrollbar to fix that.
Task-number: QTBUG-80717
Change-Id: Ic25460e5ce37a5c53bbcae48e11b6b787c45e999
Reviewed-by: BogDan Vatra <[email protected]>
-rw-r--r-- | examples/widgets/painting/affine/xform.cpp | 22 | ||||
-rw-r--r-- | examples/widgets/painting/gradients/gradients.cpp | 23 |
2 files changed, 33 insertions, 12 deletions
diff --git a/examples/widgets/painting/affine/xform.cpp b/examples/widgets/painting/affine/xform.cpp index 4e7cb91ce1d..d7ed2125d23 100644 --- a/examples/widgets/painting/affine/xform.cpp +++ b/examples/widgets/painting/affine/xform.cpp @@ -787,8 +787,8 @@ XFormWidget::XFormWidget(QWidget *parent) view = new XFormView(this); view->setMinimumSize(200, 200); - QGroupBox *mainGroup = new QGroupBox(this); - mainGroup->setFixedWidth(180); + QWidget *mainContentWidget = new QWidget(); + QGroupBox *mainGroup = new QGroupBox(mainContentWidget); mainGroup->setTitle(tr("Affine Transformations")); QGroupBox *rotateGroup = new QGroupBox(mainGroup); @@ -837,10 +837,6 @@ XFormWidget::XFormWidget(QWidget *parent) whatsThisButton->setText(tr("What's This?")); whatsThisButton->setCheckable(true); - QHBoxLayout *viewLayout = new QHBoxLayout(this); - viewLayout->addWidget(view); - viewLayout->addWidget(mainGroup); - QVBoxLayout *rotateGroupLayout = new QVBoxLayout(rotateGroup); rotateGroupLayout->addWidget(rotateSlider); @@ -871,6 +867,20 @@ XFormWidget::XFormWidget(QWidget *parent) #endif mainGroupLayout->addWidget(whatsThisButton); + mainGroup->setLayout(mainGroupLayout); + + QVBoxLayout *mainContentLayout = new QVBoxLayout(); + mainContentLayout->addWidget(mainGroup); + mainContentWidget->setLayout(mainContentLayout); + + QScrollArea *mainScrollArea = new QScrollArea(); + mainScrollArea->setWidget(mainContentWidget); + mainScrollArea->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); + + QHBoxLayout *viewLayout = new QHBoxLayout(this); + viewLayout->addWidget(view); + viewLayout->addWidget(mainScrollArea); + connect(rotateSlider, &QSlider::valueChanged, view, &XFormView::changeRotation); connect(shearSlider, &QSlider::valueChanged, view, &XFormView::changeShear); connect(scaleSlider, &QSlider::valueChanged, view, &XFormView::changeScale); diff --git a/examples/widgets/painting/gradients/gradients.cpp b/examples/widgets/painting/gradients/gradients.cpp index d62ae93a15c..cb1a0177e95 100644 --- a/examples/widgets/painting/gradients/gradients.cpp +++ b/examples/widgets/painting/gradients/gradients.cpp @@ -282,7 +282,8 @@ GradientWidget::GradientWidget(QWidget *parent) m_renderer = new GradientRenderer(this); - QGroupBox *mainGroup = new QGroupBox(this); + QWidget *mainContentWidget = new QWidget(); + QGroupBox *mainGroup = new QGroupBox(mainContentWidget); mainGroup->setTitle(tr("Gradients")); QGroupBox *editorGroup = new QGroupBox(mainGroup); @@ -327,11 +328,6 @@ GradientWidget::GradientWidget(QWidget *parent) whatsThisButton->setText(tr("What's This?")); whatsThisButton->setCheckable(true); - // Layouts - QHBoxLayout *mainLayout = new QHBoxLayout(this); - mainLayout->addWidget(m_renderer); - mainLayout->addWidget(mainGroup); - mainGroup->setFixedWidth(200); QVBoxLayout *mainGroupLayout = new QVBoxLayout(mainGroup); mainGroupLayout->addWidget(editorGroup); @@ -370,6 +366,21 @@ GradientWidget::GradientWidget(QWidget *parent) defaultsGroupLayout->addWidget(default3Button); editorGroupLayout->addWidget(default4Button); + mainGroup->setLayout(mainGroupLayout); + + QVBoxLayout *mainContentLayout = new QVBoxLayout(); + mainContentLayout->addWidget(mainGroup); + mainContentWidget->setLayout(mainContentLayout); + + QScrollArea *mainScrollArea = new QScrollArea(); + mainScrollArea->setWidget(mainContentWidget); + mainScrollArea->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred); + + // Layouts + QHBoxLayout *mainLayout = new QHBoxLayout(this); + mainLayout->addWidget(m_renderer); + mainLayout->addWidget(mainScrollArea); + connect(m_editor, &GradientEditor::gradientStopsChanged, m_renderer, &GradientRenderer::setGradientStops); connect(m_linearButton, &QRadioButton::clicked, |