From e5f4e1405947bcecd78f15bd76162ad6b54c2502 Mon Sep 17 00:00:00 2001 From: Assam Boudjelthia Date: Wed, 12 Feb 2020 17:27:36 +0200 Subject: Examples: enable HighDPI scaling for examples on Android These examples show very tiny UI elements on Android devices, thus enabling HighDPI. Task-number: QTBUG-80717 Change-Id: I813801d5249dc1fcfc6f61a8d146f60dd19901f6 Reviewed-by: BogDan Vatra --- examples/widgets/painting/affine/main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'examples/widgets/painting/affine') diff --git a/examples/widgets/painting/affine/main.cpp b/examples/widgets/painting/affine/main.cpp index 6ce8efe482..641fc5c204 100644 --- a/examples/widgets/painting/affine/main.cpp +++ b/examples/widgets/painting/affine/main.cpp @@ -55,7 +55,9 @@ int main(int argc, char **argv) { Q_INIT_RESOURCE(affine); - +#ifdef Q_OS_ANDROID + qputenv("QT_SCALE_FACTOR", "2"); +#endif QApplication app(argc, argv); XFormWidget xformWidget(nullptr); -- cgit v1.2.3 From b711ee255515440b923a898f65f6afe13d63916f Mon Sep 17 00:00:00 2001 From: Assam Boudjelthia Date: Sun, 23 Feb 2020 23:37:11 +0200 Subject: 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 --- examples/widgets/painting/affine/xform.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'examples/widgets/painting/affine') diff --git a/examples/widgets/painting/affine/xform.cpp b/examples/widgets/painting/affine/xform.cpp index 4e7cb91ce1..d7ed2125d2 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); -- cgit v1.2.3