diff --git a/examples/Examples.cpp b/examples/Examples.cpp index 21b917e..05bbee3 100644 --- a/examples/Examples.cpp +++ b/examples/Examples.cpp @@ -9,7 +9,6 @@ #include #include -#include #include #include #include @@ -17,7 +16,7 @@ #include #include -Examples::Examples() : info_(QStringLiteral("Status")) +Examples::Examples() : info_(QStringLiteral("Status")), doubleSlider_{MIN, MAX} { setWindowTitle("Wble library examples"); QHBoxLayout* widgetLayout{new QHBoxLayout(this)}; @@ -28,16 +27,15 @@ Examples::Examples() : info_(QStringLiteral("Status")) setLayout(widgetLayout); } -DoubleSlider* Examples::createDoubleSlider() +DoubleSlider* Examples::getDoubleSlider() { - auto* slider{new DoubleSlider(MIN, MAX)}; - QObject::connect(slider, &DoubleSlider::currentMinChanged, this, + QObject::connect(&doubleSlider_, &DoubleSlider::currentMinChanged, this, &Examples::doubleSliderMinChanged); - QObject::connect(slider, &DoubleSlider::currentMaxChanged, this, + QObject::connect(&doubleSlider_, &DoubleSlider::currentMaxChanged, this, &Examples::doubleSliderMaxChanged); - return slider; + return &doubleSlider_; } FilterNumbers* Examples::createFilterIntegers() @@ -110,7 +108,7 @@ QVBoxLayout* Examples::createLeftWidgetColumn() leftLayout->setSpacing(DEFAULT_SPACING); auto* groupBox{new QGroupBox(QStringLiteral("Double Slider"))}; auto* layout{new QVBoxLayout(groupBox)}; - layout->addWidget(createDoubleSlider()); + layout->addWidget(getDoubleSlider()); groupBox->setLayout(layout); leftLayout->addWidget(groupBox); leftLayout->addWidget(createFilterIntegers()); diff --git a/examples/Examples.h b/examples/Examples.h index 7a8fd56..e6ac9fe 100644 --- a/examples/Examples.h +++ b/examples/Examples.h @@ -3,7 +3,8 @@ #include #include -class DoubleSlider; +#include + class FilterNumbers; class FilterDates; class FilterStrings; @@ -18,7 +19,7 @@ class Examples : public QWidget Examples(); private: - DoubleSlider* createDoubleSlider(); + DoubleSlider* getDoubleSlider(); FilterNumbers* createFilterIntegers(); FilterNumbers* createFilterDoubles(); FilterDates* createFilterDates(); @@ -39,6 +40,8 @@ class Examples : public QWidget QLabel info_; + DoubleSlider doubleSlider_; + private slots: void doubleSliderMinChanged(double min); void doubleSliderMaxChanged(double max);