From kde-commits Tue Aug 05 07:50:56 2014 From: =?utf-8?b?QXVyw6lsaWVuIEfDonRlYXU=?= Date: Tue, 05 Aug 2014 07:50:56 +0000 To: kde-commits Subject: [kwidgetsaddons] /: New class: KColumnResizer Message-Id: X-MARC-Message: https://marc.info/?l=kde-commits&m=140722506711398 Git commit 909d74d8c683c6b632352d7179d36a8f6a79578a by Aur=C3=A9lien G=C3= =A2teau. Committed on 05/08/2014 at 07:50. Pushed by gateau into branch 'master'. New class: KColumnResizer Makes it easy to vertically align widgets across groups REVIEW: 118514 M +7 -1 autotests/CMakeLists.txt A +59 -0 autotests/kcolumnresizertest-forms.ui A +75 -0 autotests/kcolumnresizertest-grid-and-form.ui A +61 -0 autotests/kcolumnresizertest-grids.ui A +87 -0 autotests/kcolumnresizertest.cpp [License: LGPL (v2.1+)] A +34 -0 autotests/kcolumnresizertest.h [License: LGPL (v2.1+)] A +- -- docs/pics/kcolumnresizer.png M +2 -0 src/CMakeLists.txt A +248 -0 src/kcolumnresizer.cpp [License: LGPL (v2.1+)] A +126 -0 src/kcolumnresizer.h [License: LGPL (v2.1+)] M +6 -0 tests/CMakeLists.txt A +64 -0 tests/kcolumnresizertestapp.cpp [License: LGPL (v2.1+)] A +41 -0 tests/kcolumnresizertestapp.h [License: LGPL (v2.1+)] A +188 -0 tests/kcolumnresizertestapp.ui http://commits.kde.org/kwidgetsaddons/909d74d8c683c6b632352d7179d36a8f6a795= 78a diff --git a/autotests/CMakeLists.txt b/autotests/CMakeLists.txt index 7ba9cfe..26c479f 100644 --- a/autotests/CMakeLists.txt +++ b/autotests/CMakeLists.txt @@ -1,7 +1,7 @@ = include(ECMAddTests) = -find_package(Qt5 5.2.0 CONFIG REQUIRED Test) +find_package(Qt5 5.2.0 CONFIG REQUIRED Test UiTools) = ecm_add_tests( kcolorbuttontest.cpp @@ -14,3 +14,9 @@ ecm_add_tests( kpagedialogautotest.cpp LINK_LIBRARIES Qt5::Test KF5::WidgetsAddons ) + +ecm_add_tests( + kcolumnresizertest.cpp + NAME_PREFIX "kwidgetsaddons-" + LINK_LIBRARIES Qt5::Test KF5::WidgetsAddons Qt5::UiTools +) diff --git a/autotests/kcolumnresizertest-forms.ui b/autotests/kcolumnresiz= ertest-forms.ui new file mode 100644 index 0000000..16a0808 --- /dev/null +++ b/autotests/kcolumnresizertest-forms.ui @@ -0,0 +1,59 @@ + + + Form + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + GroupBox + + + + + + Short: + + + + + + + + + + + + + GroupBox + + + + + + Some long label: + + + + + + + + + + + + + + diff --git a/autotests/kcolumnresizertest-grid-and-form.ui b/autotests/kcol= umnresizertest-grid-and-form.ui new file mode 100644 index 0000000..d035098 --- /dev/null +++ b/autotests/kcolumnresizertest-grid-and-form.ui @@ -0,0 +1,75 @@ + + + Form + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + GroupBox + + + + + + + + + Short: + + + + + + + CheckBox + + + + + + + PushButton + + + + + + + + + + GroupBox + + + + + + Some long label: + + + + + + + + + + + groupBox_2 + groupBox + + + + diff --git a/autotests/kcolumnresizertest-grids.ui b/autotests/kcolumnresiz= ertest-grids.ui new file mode 100644 index 0000000..d204b24 --- /dev/null +++ b/autotests/kcolumnresizertest-grids.ui @@ -0,0 +1,61 @@ + + + Form + + + + 0 + 0 + 400 + 300 + + + + Form + + + + + + GroupBox + + + + + + Short: + + + + + + + + + + + + + GroupBox + + + + + + Some long label: + + + + + + + + + + + groupBox_2 + groupBox + + + + diff --git a/autotests/kcolumnresizertest.cpp b/autotests/kcolumnresizertes= t.cpp new file mode 100644 index 0000000..817ff57 --- /dev/null +++ b/autotests/kcolumnresizertest.cpp @@ -0,0 +1,87 @@ +/* This file is part of the KDE frameworks + * + * Copyright (c) 2014 Aur=C3=A9lien G=C3=A2teau + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA + */ + +#include + +#include + +#include +#include +#include +#include +#include +#include + +QTEST_MAIN(KColumnResizerTest) + +static QWidget *loadUi(const QString &name) +{ + QUiLoader loader; + QFile file(name); + file.open(QFile::ReadOnly); + return loader.load(&file); +} + +void KColumnResizerTest::test_data() +{ + QTest::addColumn("uiFilePath"); + QTest::newRow("forms") << QFINDTESTDATA("kcolumnresizertest-forms.ui"); + QTest::newRow("grids") << QFINDTESTDATA("kcolumnresizertest-grids.ui"); + QTest::newRow("grid-and-form") << QFINDTESTDATA("kcolumnresizertest-gr= id-and-form.ui"); +} + +void KColumnResizerTest::test() +{ + // This test checks the x coordinate of the widgets from the column + // immediately after the resized column, rather than checking the widt= h of + // the resized column itself because checking the width of the column = cannot + // be done the same way for all layout types. + QFETCH(QString, uiFilePath); + QScopedPointer parent(loadUi(uiFilePath)); + QVERIFY(parent.data()); + + auto layout1 =3D parent->findChild(QStringLiteral("layout1"= )); + auto layout2 =3D parent->findChild(QStringLiteral("layout2"= )); + auto widget1 =3D parent->findChild(QStringLiteral("widget1"= )); + auto widget2 =3D parent->findChild(QStringLiteral("widget2"= )); + QVERIFY(layout1); + QVERIFY(layout2); + QVERIFY(widget1); + QVERIFY(widget2); + + // Show the widget so that geometries are updated + parent->show(); + + int widget1x =3D widget1->x(); + int widget2x =3D widget2->x(); + QVERIFY(widget1x < widget2x); + + auto resizer =3D new KColumnResizer(parent.data()); + resizer->addWidgetsFromLayout(layout1); + resizer->addWidgetsFromLayout(layout2); + + // Wait for resizer to do the work + QCoreApplication::processEvents(); + // Now wait for the layout change to propagate + QCoreApplication::processEvents(); + + QCOMPARE(widget1->x(), widget2x); + QCOMPARE(widget2->x(), widget2x); +} diff --git a/autotests/kcolumnresizertest.h b/autotests/kcolumnresizertest.h new file mode 100644 index 0000000..a96fa6a --- /dev/null +++ b/autotests/kcolumnresizertest.h @@ -0,0 +1,34 @@ +/* This file is part of the KDE frameworks + * + * Copyright (c) 2014 Aur=C3=A9lien G=C3=A2teau + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA + */ +#ifndef KCOLUMNRESIZERTEST_H +#define KCOLUMNRESIZERTEST_H + +#include + +class KColumnResizerTest : public QObject +{ + Q_OBJECT + +private Q_SLOTS: + void test_data(); + void test(); +}; + +#endif /* KCOLUMNRESIZERTEST_H */ diff --git a/docs/pics/kcolumnresizer.png b/docs/pics/kcolumnresizer.png new file mode 100644 index 0000000..81c27ee Binary files /dev/null and b/docs/pics/kcolumnresizer.png differ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 27b9084..d5d3db0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,6 +7,7 @@ set(kwidgetsaddons_SRCS kcharselect.cpp kcharselectdata.cpp kcolorbutton.cpp + kcolumnresizer.cpp kdatecombobox.cpp kdatepicker.cpp kdatetable.cpp @@ -96,6 +97,7 @@ ecm_generate_headers(KWidgetsAddons_HEADERS KAnimatedButton KCharSelect KColorButton + KColumnResizer KDateComboBox KDatePicker KDateTimeEdit diff --git a/src/kcolumnresizer.cpp b/src/kcolumnresizer.cpp new file mode 100644 index 0000000..6316bff --- /dev/null +++ b/src/kcolumnresizer.cpp @@ -0,0 +1,248 @@ +/* This file is part of the KDE frameworks + * + * Copyright (c) 2014 Aur=C3=A9lien G=C3=A2teau + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA + */ +#include + +#include +#include +#include +#include +#include +#include +#include + +class FormLayoutWidgetItem : public QWidgetItem +{ +public: + FormLayoutWidgetItem(QWidget *widget, QFormLayout *formLayout, QFormLa= yout::ItemRole itemRole) + : QWidgetItem(widget) + , m_width(-1) + , m_formLayout(formLayout) + , m_itemRole(itemRole) + {} + + void setWidth(int width) + { + if (width !=3D m_width) { + m_width =3D width; + invalidate(); + } + } + + QFormLayout *formLayout() const + { + return m_formLayout; + } + + QSize sizeHint() const Q_DECL_OVERRIDE + { + QSize size =3D QWidgetItem::sizeHint(); + if (m_width !=3D -1) { + size.setWidth(m_width); + } + return size; + } + + QSize minimumSize() const Q_DECL_OVERRIDE + { + QSize size =3D QWidgetItem::minimumSize(); + if (m_width !=3D -1) { + size.setWidth(m_width); + } + return size; + } + + QSize maximumSize() const Q_DECL_OVERRIDE + { + QSize size =3D QWidgetItem::maximumSize(); + if (m_width !=3D -1) { + size.setWidth(m_width); + } + return size; + } + + void setGeometry(const QRect &_rect) Q_DECL_OVERRIDE + { + QRect rect =3D _rect; + int width =3D widget()->sizeHint().width(); + if (m_itemRole =3D=3D QFormLayout::LabelRole && m_formLayout->labe= lAlignment() & Qt::AlignRight) { + rect.setLeft(rect.right() - width); + } + QWidgetItem::setGeometry(rect); + } + +private: + int m_width; + QFormLayout *m_formLayout; + QFormLayout::ItemRole m_itemRole; +}; + +struct GridColumnInfo +{ + GridColumnInfo(QGridLayout *layout_, int column_) + : layout(layout_) + , column(column_) + {} + QGridLayout *layout; + int column; +}; + +class KColumnResizerPrivate +{ +public: + KColumnResizerPrivate(KColumnResizer *q_ptr) + : q(q_ptr) + , m_updateTimer(new QTimer(q)) + { + m_updateTimer->setSingleShot(true); + m_updateTimer->setInterval(0); + QObject::connect(m_updateTimer, SIGNAL(timeout()), q, SLOT(updateW= idth())); + } + + void scheduleWidthUpdate() + { + m_updateTimer->start(); + } + + void updateWidth() + { + int width =3D 0; + Q_FOREACH(QWidget *widget, m_widgets) { + width =3D qMax(widget->sizeHint().width(), width); + } + Q_FOREACH(FormLayoutWidgetItem *item, m_formWidgetItemList) { + item->setWidth(width); + item->formLayout()->update(); + } + Q_FOREACH(const GridColumnInfo &info, m_gridColumnInfoList) { + info.layout->setColumnMinimumWidth(info.column, width); + } + } + + void addWidgetsFromGridLayout(QGridLayout *layout, int column) + { + for (int row =3D 0; row < layout->rowCount(); ++row) { + QLayoutItem *item =3D layout->itemAtPosition(row, column); + if (!item) { + continue; + } + QWidget *widget =3D item->widget(); + if (!widget) { + continue; + } + q->addWidget(widget); + } + m_gridColumnInfoList << GridColumnInfo(layout, column); + } + + void addWidgetsFromFormLayout(QFormLayout *layout, QFormLayout::ItemRo= le role) + { + for (int row =3D 0; row < layout->rowCount(); ++row) { + QLayoutItem *item =3D layout->itemAt(row, role); + if (!item) { + continue; + } + QWidget *widget =3D item->widget(); + if (!widget) { + continue; + } + // Replace the QWidgetItem with our own + layout->removeItem(item); + delete item; + FormLayoutWidgetItem *newItem =3D new FormLayoutWidgetItem(wid= get, layout, role); + layout->setItem(row, role, newItem); + m_formWidgetItemList << newItem; + + q->addWidget(widget); + } + } + + KColumnResizer *q; + QTimer *m_updateTimer; + QSet m_widgets; + QList m_formWidgetItemList; + QList m_gridColumnInfoList; +}; + +KColumnResizer::KColumnResizer(QObject *parent) + : QObject(parent) + , d(new KColumnResizerPrivate(this)) +{} + +KColumnResizer::~KColumnResizer() +{ + delete d; +} + +void KColumnResizer::addWidget(QWidget *widget) +{ + if (d->m_widgets.contains(widget)) { + return; + } + d->m_widgets.insert(widget); + widget->installEventFilter(this); + d->scheduleWidthUpdate(); +} + +void KColumnResizer::removeWidget(QWidget *widget) +{ + if (!d->m_widgets.remove(widget)) { + return; + } + widget->removeEventFilter(this); + d->scheduleWidthUpdate(); +} + +bool KColumnResizer::eventFilter(QObject *, QEvent *event) +{ + if (event->type() =3D=3D QEvent::Resize) { + d->scheduleWidthUpdate(); + } + return false; +} + +void KColumnResizer::addWidgetsFromLayout(QLayout *layout, int column) +{ + Q_ASSERT(column >=3D 0); + if (column < 0) { + qWarning() << "column must be >=3D 0"; + return; + } + QGridLayout *gridLayout =3D qobject_cast(layout); + if (gridLayout) { + d->addWidgetsFromGridLayout(gridLayout, column); + return; + } + QFormLayout *formLayout =3D qobject_cast(layout); + if (formLayout) { + Q_ASSERT(column <=3D QFormLayout::SpanningRole); + if (column > QFormLayout::SpanningRole) { + qWarning() << "column should not be more than" << QFormLayout:= :SpanningRole << "for QFormLayout"; + return; + } + QFormLayout::ItemRole role =3D static_cast(= column); + d->addWidgetsFromFormLayout(formLayout, role); + } else { + qWarning() << "Don't know how to handle layout" << layout; + Q_ASSERT(0); + } +} + +#include +// vi: ts=3D4 sw=3D4 et diff --git a/src/kcolumnresizer.h b/src/kcolumnresizer.h new file mode 100644 index 0000000..6855f57 --- /dev/null +++ b/src/kcolumnresizer.h @@ -0,0 +1,126 @@ +/* This file is part of the KDE frameworks + * + * Copyright (c) 2014 Aur=C3=A9lien G=C3=A2teau + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA + */ +#ifndef KCOLUMNRESIZER_H +#define KCOLUMNRESIZER_H + +#include + +#include +#include + +class QEvent; +class QGridLayout; +class QLayout; +class QWidget; + +class KColumnResizerPrivate; + +/** + * @short Maintains consistent column sizes across layouts + * + * KColumnResizer is a helper class which can force columns of different l= ayouts + * to keep the same width. It is useful to keep label columns consistent. + * + * It works with QGridLayout and QFormLayout. + * + * @image html kcolumnresizer.png "left: without KColumnResizer - right: w= ith KColumnResizer" + * + * Here is a typical example: + * + * @code + * void Window::createWidgets() + * { + * QVBoxLayout *layout =3D new QVBoxLayout(this); + * + * QGroupBox *box1 =3D new QGroupBox(); + * // Fill box1 + * // ... + * layout->addWidget(box1); + * + * QGroupBox *box2 =3D new QGroupBox(); + * // Fill box2 + * // ... + * layout->addWidget(box2); + * + * KColumnResizer *resizer =3D new KColumnResizer(this); + * resizer->addWidgetsFromLayout(box1->layout(), 0); + * resizer->addWidgetsFromLayout(box2->layout(), 0); + * } + * @endcode + * + * In this example box1 and box2 children can be organized using QGridLayo= ut or + * QFormLayout, resizer will ensure the first columns of the two QGroupBox= stay + * the same width. + * + * @author Aur=C3=A9lien G=C3=A2teau + * + * @since 5.1 + */ +class KWIDGETSADDONS_EXPORT KColumnResizer : public QObject +{ + Q_OBJECT +public: + /** + * Constructs a KColumnResizer. + */ + explicit KColumnResizer(QObject *parent =3D 0); + + ~KColumnResizer(); + + /** + * Add all widgets from @p layout which are in column @p column to the= list + * of widgets to manage. + * + * @param layout The layout containing the widgets to add. KColumnResi= zer + * supports QGridLayout and QFormLayout. + * @param column The column number which contains the widgets. If layo= ut is + * a QFormLayout, column should not be higher than QFormLayout::Spanni= ngRole + */ + void addWidgetsFromLayout(QLayout *layout, int column =3D 0); + + /** + * Add a single widget to the list of widgets whose width is monitored. + * + * It is more common to use addWidgetsFromLayout(), but adding single + * widgets can be useful if you want to keep a single button the same = width + * as a column in a layout. + * + * @param widget The widget to add + */ + void addWidget(QWidget *widget); + + /** + * Remove a widget previously added by addWidget or addWidgetsFromLayo= ut. + * + * @param widget The widget to remove + */ + void removeWidget(QWidget *widget); + +protected: + bool eventFilter(QObject *, QEvent *event) Q_DECL_OVERRIDE; + +private: + KColumnResizerPrivate *const d; + Q_DISABLE_COPY(KColumnResizer) + + Q_PRIVATE_SLOT(d, void updateWidth()) +}; + +#endif /* KCOLUMNRESIZER_H */ diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index eccf887..5086ac0 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -44,3 +44,9 @@ add_executable(kdatetabletest kdatetabletest.cpp ../src/k= datetable.cpp) target_include_directories(kdatetabletest PRIVATE ../src) target_link_libraries(kdatetabletest Qt5::Widgets) ecm_mark_as_test(kdatetabletest) + +set(kcolumnresizertestapp_SRCS kcolumnresizertestapp.cpp) +qt5_wrap_ui(kcolumnresizertestapp_SRCS kcolumnresizertestapp.ui) +add_executable(kcolumnresizertestapp ${kcolumnresizertestapp_SRCS}) +target_link_libraries(kcolumnresizertestapp KF5::WidgetsAddons Qt5::Widget= s) +ecm_mark_as_test(kcolumnresizertestapp) diff --git a/tests/kcolumnresizertestapp.cpp b/tests/kcolumnresizertestapp.= cpp new file mode 100644 index 0000000..a750cfd --- /dev/null +++ b/tests/kcolumnresizertestapp.cpp @@ -0,0 +1,64 @@ +/* This file is part of the KDE frameworks + * + * Copyright (c) 2011-2014 Aur=C3=A9lien G=C3=A2teau + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA + */ +#include +#include + +#include + +#include + +#include + +Window::Window() +{ + m_ui =3D new Ui_ColumnResizerTestWidget; + m_ui->setupUi(this); + + KColumnResizer *resizer =3D new KColumnResizer(this); + resizer->addWidgetsFromLayout(m_ui->gridGroupBox1->layout(), 0); + resizer->addWidgetsFromLayout(m_ui->formGroupBox1->layout(), 0); + resizer->addWidgetsFromLayout(m_ui->formGroupBox2->layout(), 0); + resizer->addWidgetsFromLayout(m_ui->gridGroupBox2->layout(), 0); + + connect(m_ui->spinBox, SIGNAL(valueChanged(int)), SLOT(updateAdjustabl= eLabel())); + updateAdjustableLabel(); +} + +Window::~Window() +{ + delete m_ui; +} + +void Window::updateAdjustableLabel() +{ + QString txt; + txt.fill(QLatin1Char('#'), m_ui->spinBox->value()); + m_ui->adjustableLabel->setText(QStringLiteral("Spin me %1:").arg(txt)); +} + +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + Window window; + window.show(); + return app.exec(); +} + +#include diff --git a/tests/kcolumnresizertestapp.h b/tests/kcolumnresizertestapp.h new file mode 100644 index 0000000..d71dac9 --- /dev/null +++ b/tests/kcolumnresizertestapp.h @@ -0,0 +1,41 @@ +/* This file is part of the KDE frameworks + * + * Copyright (c) 2011-2014 Aur=C3=A9lien G=C3=A2teau + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301 USA + */ +#ifndef KCOLUMNRESIZERTESTAPP_H +#define KCOLUMNRESIZERTESTAPP_H + +#include + +class Ui_ColumnResizerTestWidget; + +class Window : public QWidget +{ + Q_OBJECT +public: + Window(); + ~Window(); + +public Q_SLOTS: + void updateAdjustableLabel(); + +private: + Ui_ColumnResizerTestWidget *m_ui; +}; + +#endif /* KCOLUMNRESIZERTESTAPP_H */ diff --git a/tests/kcolumnresizertestapp.ui b/tests/kcolumnresizertestapp.ui new file mode 100644 index 0000000..4100824 --- /dev/null +++ b/tests/kcolumnresizertestapp.ui @@ -0,0 +1,188 @@ + + + ColumnResizerTestWidget + + + + 0 + 0 + 376 + 580 + + + + ColumnResizer Test + + + + + + GridLayout + + + + + + A line edit: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + Spin me: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + A check box + + + + + + + + + + FormLayout + + + + QFormLayout::ExpandingFieldsGrow + + + + + One line: + + + + + + + + + + A much bigger text area: + + + + + + + + + + + + + FormLayout2 + + + + + + + + + Time: + + + + + + + Show seconds + + + + + + + Details: + + + + + + + Option &1 + + + true + + + + + + + Option &2 + + + + + + + + + + Crazy QGridLayout + + + + + + PushButton + + + + + + + PushButton + + + + + + + PushButton + + + + + + + + 0 + 0 + + + + PushButton + + + + + + + + + + +