diff --git a/examples/Examples.cpp b/examples/Examples.cpp index 90615db..51136a8 100644 --- a/examples/Examples.cpp +++ b/examples/Examples.cpp @@ -126,25 +126,9 @@ QGroupBox* Examples::createProgressBarCounter() startStop.click(); } }); - QObject::connect( - &startStopButtonCounter_, &QPushButton::clicked, &progressBarCounter_, - [&timer = progressCounterTimer_, &startStop = startStopButtonCounter_, - &bar = progressBarCounter_]() - { - const bool running = bar.isRunning(); - if (running) - { - bar.stop(); - timer.stop(); - } - else - { - bar.start(); - timer.start(); - } - startStop.setText( - (running ? QStringLiteral("start") : QStringLiteral("stop"))); - }); + QObject::connect(&startStopButtonCounter_, &QPushButton::clicked, this, + &Examples::counterButtonClicked); + return wrapProgressBar(QStringLiteral("Counter progress bar"), &progressBarCounter_, &startStopButtonCounter_); } @@ -214,3 +198,20 @@ void Examples::infiniteButtonClicked() startStopButtonInfinite_.setText(QStringLiteral("stop")); } } + +void Examples::counterButtonClicked() +{ + const bool running = progressBarCounter_.isRunning(); + if (running) + { + progressBarCounter_.stop(); + progressCounterTimer_.stop(); + startStopButtonCounter_.setText(QStringLiteral("start")); + } + else + { + progressBarCounter_.start(); + progressCounterTimer_.start(); + startStopButtonCounter_.setText(QStringLiteral("stop")); + } +} diff --git a/examples/Examples.h b/examples/Examples.h index 6fa6b72..25d1921 100644 --- a/examples/Examples.h +++ b/examples/Examples.h @@ -80,4 +80,6 @@ private slots: void filterStringsValuesChanged(QStringList bannedItems); void infiniteButtonClicked(); + + void counterButtonClicked(); };