From 8cf812231405e011b422a1505d9a219618fe5cee Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Fri, 7 Dec 2018 14:15:36 +0100 Subject: Cleanup Widgets examples - new signal/slot syntax MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cleanup the Widget examples - use the new signal/slot syntax where possible - animation, effects and graphicsview subdirectory Change-Id: I6cbaea6e628eb06f8e0ca6a0b795030a66b83878 Reviewed-by: Luca Beldi Reviewed-by: Topi Reiniƶ --- examples/widgets/animation/stickman/lifecycle.cpp | 16 +++++++++------- examples/widgets/animation/stickman/stickman.cpp | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'examples/widgets/animation/stickman') diff --git a/examples/widgets/animation/stickman/lifecycle.cpp b/examples/widgets/animation/stickman/lifecycle.cpp index dbe9a299b4..5d4c406b2e 100644 --- a/examples/widgets/animation/stickman/lifecycle.cpp +++ b/examples/widgets/animation/stickman/lifecycle.cpp @@ -61,11 +61,11 @@ class KeyPressTransition: public QSignalTransition { public: KeyPressTransition(GraphicsView *receiver, Qt::Key key) - : QSignalTransition(receiver, SIGNAL(keyPressed(int))), m_key(key) + : QSignalTransition(receiver, &GraphicsView::keyPressed), m_key(key) { } KeyPressTransition(GraphicsView *receiver, Qt::Key key, QAbstractState *target) - : QSignalTransition(receiver, SIGNAL(keyPressed(int))), m_key(key) + : QSignalTransition(receiver, &GraphicsView::keyPressed), m_key(key) { setTargetState(target); } @@ -132,8 +132,10 @@ LifeCycle::LifeCycle(StickMan *stickMan, GraphicsView *keyReceiver) QTimer *timer = new QTimer(lightningBlink); timer->setSingleShot(true); timer->setInterval(100); - QObject::connect(lightningBlink, SIGNAL(entered()), timer, SLOT(start())); - QObject::connect(lightningBlink, SIGNAL(exited()), timer, SLOT(stop())); + QObject::connect(lightningBlink, &QAbstractState::entered, + timer, QOverload<>::of(&QTimer::start)); + QObject::connect(lightningBlink, &QAbstractState::exited, + timer, &QTimer::stop); //! [5] m_dead = new QState(m_machine); @@ -151,7 +153,7 @@ LifeCycle::LifeCycle(StickMan *stickMan, GraphicsView *keyReceiver) // Lightning strikes at random m_alive->addTransition(new LightningStrikesTransition(lightningBlink)); //! [0] - lightningBlink->addTransition(timer, SIGNAL(timeout()), m_dead); + lightningBlink->addTransition(timer, &QTimer::timeout, m_dead); //! [0] m_machine->setInitialState(m_alive); @@ -206,14 +208,14 @@ QState *LifeCycle::makeState(QState *parentState, const QString &animationFileNa topLevel->setInitialState(frameState); else //! [2] - previousState->addTransition(previousState, SIGNAL(propertiesAssigned()), frameState); + previousState->addTransition(previousState, &QState::propertiesAssigned, frameState); //! [2] previousState = frameState; } // Loop - previousState->addTransition(previousState, SIGNAL(propertiesAssigned()), topLevel->initialState()); + previousState->addTransition(previousState, &QState::propertiesAssigned, topLevel->initialState()); return topLevel; diff --git a/examples/widgets/animation/stickman/stickman.cpp b/examples/widgets/animation/stickman/stickman.cpp index b7a2d87ada..8b183d87d5 100644 --- a/examples/widgets/animation/stickman/stickman.cpp +++ b/examples/widgets/animation/stickman/stickman.cpp @@ -126,7 +126,7 @@ StickMan::StickMan() // Set up start position of limbs for (int i=0; i