Skip to content

Commit

Permalink
Use slots methods instead of lambdas for DoubleSlider usage example.
Browse files Browse the repository at this point in the history
  • Loading branch information
przemek83 committed Dec 26, 2024
1 parent 0cf7691 commit 70882a0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
22 changes: 14 additions & 8 deletions examples/Examples.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,11 @@ Examples::Examples() : info_(QStringLiteral("Status"))
DoubleSlider* Examples::createDoubleSlider()
{
auto* slider{new DoubleSlider(MIN, MAX)};
QObject::connect(
slider, &DoubleSlider::currentMinChanged, &info_,
[&info = info_](double min)
{ info.setText("Double Slider: min = " + QString::number(min)); });
QObject::connect(slider, &DoubleSlider::currentMinChanged, this,
&Examples::doubleSliderMinChanged);

QObject::connect(
slider, &DoubleSlider::currentMaxChanged, &info_,
[&info = info_](double max)
{ info.setText("Double Slider: max = " + QString::number(max)); });
QObject::connect(slider, &DoubleSlider::currentMaxChanged, this,
&Examples::doubleSliderMaxChanged);

return slider;
}
Expand Down Expand Up @@ -209,3 +205,13 @@ QVBoxLayout* Examples::createRightWidgetColumn()
rightLayout->addStretch();
return rightLayout;
}

void Examples::doubleSliderMinChanged(double min)
{
info_.setText("Double Slider: min = " + QString::number(min));
}

void Examples::doubleSliderMaxChanged(double max)
{
info_.setText("Double Slider: max = " + QString::number(max));
}
4 changes: 4 additions & 0 deletions examples/Examples.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,8 @@ class Examples : public QWidget
static constexpr int DEFAULT_SPACING{10};

QLabel info_;

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

0 comments on commit 70882a0

Please sign in to comment.