From 89ce9a1c5a29e3f420931baa88c705856b99ac25 Mon Sep 17 00:00:00 2001 From: Elias Hautala Date: Thu, 28 Jul 2022 16:09:11 +0300 Subject: Basiclayouts: Add scrolling to example Adds scrolling to basic layouts example because the user interface in the example doesn't fit properly on smaller screen sizes. Fixes: QTCREATORBUG-27634 Pick-to: 6.2 6.3 6.4 Change-Id: I61e6eac2b28e5b3ff0f984894fe38167b3f46a9c Reviewed-by: Assam Boudjelthia Reviewed-by: Markku Nokkala --- examples/widgets/layouts/basiclayouts/dialog.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/examples/widgets/layouts/basiclayouts/dialog.cpp b/examples/widgets/layouts/basiclayouts/dialog.cpp index aeace90822..a0825167d9 100644 --- a/examples/widgets/layouts/basiclayouts/dialog.cpp +++ b/examples/widgets/layouts/basiclayouts/dialog.cpp @@ -36,9 +36,24 @@ Dialog::Dialog() mainLayout->addWidget(formGroupBox); mainLayout->addWidget(bigEditor); mainLayout->addWidget(buttonBox); -//! [4] //! [5] - setLayout(mainLayout); +//! [4] + QWidget *scrollAreaContent = new QWidget; + scrollAreaContent->setLayout(mainLayout); + QScrollArea *scrollArea = new QScrollArea; + scrollArea->setFrameShape(QFrame::NoFrame); + scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + scrollArea->setWidgetResizable(true); + scrollArea->verticalScrollBar()->setStyleSheet("QScrollBar:vertical {width: 20px;}"); + + scrollArea->setWidget(scrollAreaContent); + + QVBoxLayout *scrollLayout = new QVBoxLayout; + scrollLayout->setContentsMargins(0,0,0,0); + scrollLayout->addWidget(scrollArea); + +//! [5] + setLayout(scrollLayout); setWindowTitle(tr("Basic Layouts")); } //! [5] -- cgit v1.2.3