Skip to content

Commit

Permalink
Use automatic memory instead of dynamic one for storing DoubleSlider …
Browse files Browse the repository at this point in the history
…example object.
  • Loading branch information
przemek83 committed Dec 26, 2024
1 parent 70882a0 commit 485b87c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
14 changes: 6 additions & 8 deletions examples/Examples.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@
#include <QVBoxLayout>
#include <QWindow>

#include <wble/DoubleSlider.h>
#include <wble/FilterDates.h>
#include <wble/FilterDoubles.h>
#include <wble/FilterIntegers.h>
#include <wble/FilterStrings.h>
#include <wble/ProgressBarCounter.h>
#include <wble/ProgressBarInfinite.h>

Examples::Examples() : info_(QStringLiteral("Status"))
Examples::Examples() : info_(QStringLiteral("Status")), doubleSlider_{MIN, MAX}
{
setWindowTitle("Wble library examples");
QHBoxLayout* widgetLayout{new QHBoxLayout(this)};
Expand All @@ -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()
Expand Down Expand Up @@ -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());
Expand Down
7 changes: 5 additions & 2 deletions examples/Examples.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
#include <QLabel>
#include <QWidget>

class DoubleSlider;
#include <wble/DoubleSlider.h>

class FilterNumbers;
class FilterDates;
class FilterStrings;
Expand All @@ -18,7 +19,7 @@ class Examples : public QWidget
Examples();

private:
DoubleSlider* createDoubleSlider();
DoubleSlider* getDoubleSlider();
FilterNumbers* createFilterIntegers();
FilterNumbers* createFilterDoubles();
FilterDates* createFilterDates();
Expand All @@ -39,6 +40,8 @@ class Examples : public QWidget

QLabel info_;

DoubleSlider doubleSlider_;

private slots:
void doubleSliderMinChanged(double min);
void doubleSliderMaxChanged(double max);
Expand Down

0 comments on commit 485b87c

Please sign in to comment.