Warning, file /frameworks/kwidgetsaddons/tests/kcollapsiblegroupboxtest.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002     This file is part of the KDE libraries
0003     SPDX-FileCopyrightText: 2015 David Edmundson <davidedmundson@kde.org>
0004     Based on test program by Dominik Haumann <dhaumann@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.1-or-later
0007 */
0008 #include <QApplication>
0009 #include <QCheckBox>
0010 #include <QLabel>
0011 #include <QLineEdit>
0012 #include <QVBoxLayout>
0013 #include <QWidget>
0014 
0015 #include "kdatepicker.h"
0016 #include <kcollapsiblegroupbox.h>
0017 
0018 int main(int argc, char *argv[])
0019 {
0020     QApplication app(argc, argv);
0021     app.setAttribute(Qt::AA_UseHighDpiPixmaps, true);
0022 
0023     QWidget mainWindow;
0024 
0025     QVBoxLayout mainWindowLayout(&mainWindow);
0026 
0027     // add a layout with many items to make sure it doesn't shuffle them weirdly when animating
0028     {
0029         auto groupBox = new KCollapsibleGroupBox;
0030         groupBox->setTitle(QStringLiteral("&Advanced Options"));
0031 
0032         auto *innerLayout = new QVBoxLayout(groupBox);
0033         for (int i = 0; i < 6; i++) {
0034             auto checkBox = new QCheckBox(QStringLiteral("Some text"));
0035             innerLayout->addWidget(checkBox);
0036         }
0037         auto checkBox = new QCheckBox(QStringLiteral("Some really long text that goes on and on and on for ever and ever"));
0038         innerLayout->addWidget(checkBox);
0039 
0040         auto label = new QLabel(groupBox);
0041         label->setText(QStringLiteral("Some input field:"));
0042         // Word-wrapping in labels triggers a bug in the layout positioning.
0043         label->setWordWrap(true);
0044         innerLayout->addWidget(label);
0045 
0046         auto lineEdit = new QLineEdit(groupBox);
0047         innerLayout->addWidget(lineEdit);
0048 
0049         auto hiddenCheckBox = new QCheckBox(QStringLiteral("This will be always hidden"));
0050         innerLayout->addWidget(hiddenCheckBox);
0051         hiddenCheckBox->hide();
0052 
0053         mainWindowLayout.addWidget(groupBox);
0054     }
0055 
0056     // another item which should expand to fill width
0057     {
0058         auto groupBox = new KCollapsibleGroupBox;
0059         groupBox->setTitle(QStringLiteral("Pick a &date"));
0060 
0061         auto innerLayout = new QVBoxLayout(groupBox);
0062         auto datePicker = new KDatePicker();
0063         innerLayout->addWidget(datePicker);
0064         mainWindowLayout.addWidget(groupBox);
0065     }
0066 
0067     mainWindowLayout.addStretch();
0068 
0069     mainWindow.resize(400, 300);
0070     mainWindow.show();
0071 
0072     return app.exec();
0073 }
0074 
0075 // kate: replace-tabs on;