Skip to content

Commit

Permalink
Move reaction logic for FilterIntegers change from lambda to dedicate…
Browse files Browse the repository at this point in the history
…d slot.
  • Loading branch information
przemek83 committed Dec 26, 2024
1 parent ec32897 commit 5f9340c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
19 changes: 10 additions & 9 deletions examples/Examples.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,10 @@ DoubleSlider* Examples::getDoubleSlider()
return &doubleSlider_;
}

FilterNumbers* Examples::createFilterIntegers()
FilterNumbers* Examples::getFilterIntegers()
{
QObject::connect(
&filterIntegers_, &FilterIntegers::newNumericFilter, &info_,
[&info = info_](int min, int max)
{
info.setText("Integers Filter: " + QString::number(min) + " | " +
QString::number(max));
});
QObject::connect(&filterIntegers_, &FilterIntegers::newNumericFilter, this,
&Examples::filterIntegersValuesChanged);

filterIntegers_.setCheckable(true);
return &filterIntegers_;
Expand Down Expand Up @@ -103,7 +98,7 @@ QVBoxLayout* Examples::createLeftWidgetColumn()
layout->addWidget(getDoubleSlider());
groupBox->setLayout(layout);
leftLayout->addWidget(groupBox);
leftLayout->addWidget(createFilterIntegers());
leftLayout->addWidget(getFilterIntegers());
leftLayout->addWidget(createFilterDoubles());
leftLayout->addWidget(createFilterDates());
leftLayout->addWidget(createFilterStrings());
Expand Down Expand Up @@ -205,3 +200,9 @@ void Examples::doubleSliderMaxChanged(double max)
{
info_.setText("Double Slider: max = " + QString::number(max));
}

void Examples::filterIntegersValuesChanged(int min, int max)
{
info_.setText("Integers Filter: " + QString::number(min) + " | " +
QString::number(max));
}
4 changes: 3 additions & 1 deletion examples/Examples.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Examples : public QWidget

private:
DoubleSlider* getDoubleSlider();
FilterNumbers* createFilterIntegers();
FilterNumbers* getFilterIntegers();
FilterNumbers* createFilterDoubles();
FilterDates* createFilterDates();
FilterStrings* createFilterStrings();
Expand Down Expand Up @@ -57,4 +57,6 @@ class Examples : public QWidget
private slots:
void doubleSliderMinChanged(double min);
void doubleSliderMaxChanged(double max);

void filterIntegersValuesChanged(int min, int max);
};

0 comments on commit 5f9340c

Please sign in to comment.