summaryrefslogtreecommitdiffstats
path: root/examples/widgets/statemachine
diff options
context:
space:
mode:
authorKarsten Heimrich <karsten.heimrich@qt.io>2020-08-18 14:26:50 +0200
committerKarsten Heimrich <karsten.heimrich@qt.io>2020-08-24 20:10:25 +0200
commita735038376e1c229c293c36bd67800851323baf1 (patch)
tree4b0621b9a0b322ecb45e3843b3d7c3bacd90296f /examples/widgets/statemachine
parent43f01ec2e5bc52b290098d0fca1dd4ae40f2c6d3 (diff)
Move QStateMachine from QtCore to QtScxml
Task-number: QTBUG-80316 Change-Id: I2ee74110fd55e94d86321d3b3dc5bb8297424ed4 Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Diffstat (limited to 'examples/widgets/statemachine')
-rw-r--r--examples/widgets/statemachine/CMakeLists.txt10
-rw-r--r--examples/widgets/statemachine/README6
-rw-r--r--examples/widgets/statemachine/eventtransitions/CMakeLists.txt35
-rw-r--r--examples/widgets/statemachine/eventtransitions/eventtransitions.pro7
-rw-r--r--examples/widgets/statemachine/eventtransitions/main.cpp130
-rw-r--r--examples/widgets/statemachine/factorial/CMakeLists.txt31
-rw-r--r--examples/widgets/statemachine/factorial/factorial.pro10
-rw-r--r--examples/widgets/statemachine/factorial/main.cpp181
-rw-r--r--examples/widgets/statemachine/pingpong/CMakeLists.txt31
-rw-r--r--examples/widgets/statemachine/pingpong/main.cpp149
-rw-r--r--examples/widgets/statemachine/pingpong/pingpong.pro10
-rw-r--r--examples/widgets/statemachine/rogue/CMakeLists.txt37
-rw-r--r--examples/widgets/statemachine/rogue/main.cpp64
-rw-r--r--examples/widgets/statemachine/rogue/movementtransition.h122
-rw-r--r--examples/widgets/statemachine/rogue/rogue.pro10
-rw-r--r--examples/widgets/statemachine/rogue/window.cpp261
-rw-r--r--examples/widgets/statemachine/rogue/window.h100
-rw-r--r--examples/widgets/statemachine/statemachine.pro12
-rw-r--r--examples/widgets/statemachine/trafficlight/CMakeLists.txt35
-rw-r--r--examples/widgets/statemachine/trafficlight/main.cpp200
-rw-r--r--examples/widgets/statemachine/trafficlight/trafficlight.pro9
-rw-r--r--examples/widgets/statemachine/twowaybutton/CMakeLists.txt35
-rw-r--r--examples/widgets/statemachine/twowaybutton/main.cpp91
-rw-r--r--examples/widgets/statemachine/twowaybutton/twowaybutton.pro9
24 files changed, 0 insertions, 1585 deletions
diff --git a/examples/widgets/statemachine/CMakeLists.txt b/examples/widgets/statemachine/CMakeLists.txt
deleted file mode 100644
index 90a7b3e263..0000000000
--- a/examples/widgets/statemachine/CMakeLists.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-# Generated from statemachine.pro.
-
-add_subdirectory(factorial)
-add_subdirectory(pingpong)
-if(TARGET Qt::Widgets)
- add_subdirectory(eventtransitions)
- add_subdirectory(rogue)
- add_subdirectory(trafficlight)
- add_subdirectory(twowaybutton)
-endif()
diff --git a/examples/widgets/statemachine/README b/examples/widgets/statemachine/README
deleted file mode 100644
index a0ac35a89b..0000000000
--- a/examples/widgets/statemachine/README
+++ /dev/null
@@ -1,6 +0,0 @@
-Qt is provided with a powerful hierchical finite state machine through
-the Qt State Machine classes.
-
-
-Documentation for these examples can be found via the Examples
-link in the main Qt documentation.
diff --git a/examples/widgets/statemachine/eventtransitions/CMakeLists.txt b/examples/widgets/statemachine/eventtransitions/CMakeLists.txt
deleted file mode 100644
index 642e6343db..0000000000
--- a/examples/widgets/statemachine/eventtransitions/CMakeLists.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-# Generated from eventtransitions.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(eventtransitions LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/statemachine/eventtransitions")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-add_qt_gui_executable(eventtransitions
- main.cpp
-)
-target_link_libraries(eventtransitions PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS eventtransitions
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/statemachine/eventtransitions/eventtransitions.pro b/examples/widgets/statemachine/eventtransitions/eventtransitions.pro
deleted file mode 100644
index 07c8be73d4..0000000000
--- a/examples/widgets/statemachine/eventtransitions/eventtransitions.pro
+++ /dev/null
@@ -1,7 +0,0 @@
-QT += widgets
-
-SOURCES = main.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/statemachine/eventtransitions
-INSTALLS += target
diff --git a/examples/widgets/statemachine/eventtransitions/main.cpp b/examples/widgets/statemachine/eventtransitions/main.cpp
deleted file mode 100644
index fe9518092f..0000000000
--- a/examples/widgets/statemachine/eventtransitions/main.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-#include <QEventTransition>
-#include <QPushButton>
-#include <QStateMachine>
-#include <QVBoxLayout>
-#include <QWidget>
-
-//! [0]
-class Window : public QWidget
-{
-public:
- Window(QWidget *parent = nullptr)
- : QWidget(parent)
- {
- QPushButton *button = new QPushButton(this);
- button->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
-
- QVBoxLayout *layout = new QVBoxLayout;
- layout->addWidget(button);
- layout->setContentsMargins(80, 80, 80, 80);
- setLayout(layout);
-//! [0]
-
-//! [1]
- QStateMachine *machine = new QStateMachine(this);
-
- QState *s1 = new QState();
- s1->assignProperty(button, "text", "Outside");
-
- QState *s2 = new QState();
- s2->assignProperty(button, "text", "Inside");
-//! [1]
-
-//! [2]
- QEventTransition *enterTransition = new QEventTransition(button, QEvent::Enter);
- enterTransition->setTargetState(s2);
- s1->addTransition(enterTransition);
-//! [2]
-
-//! [3]
- QEventTransition *leaveTransition = new QEventTransition(button, QEvent::Leave);
- leaveTransition->setTargetState(s1);
- s2->addTransition(leaveTransition);
-//! [3]
-
-//! [4]
- QState *s3 = new QState();
- s3->assignProperty(button, "text", "Pressing...");
-
- QEventTransition *pressTransition = new QEventTransition(button, QEvent::MouseButtonPress);
- pressTransition->setTargetState(s3);
- s2->addTransition(pressTransition);
-
- QEventTransition *releaseTransition = new QEventTransition(button, QEvent::MouseButtonRelease);
- releaseTransition->setTargetState(s2);
- s3->addTransition(releaseTransition);
-//! [4]
-
-//! [5]
- machine->addState(s1);
- machine->addState(s2);
- machine->addState(s3);
-
- machine->setInitialState(s1);
- machine->start();
- }
-};
-//! [5]
-
-//! [6]
-int main(int argc, char **argv)
-{
- QApplication app(argc, argv);
- Window window;
- window.resize(300, 300);
- window.show();
-
- return app.exec();
-}
-//! [6]
diff --git a/examples/widgets/statemachine/factorial/CMakeLists.txt b/examples/widgets/statemachine/factorial/CMakeLists.txt
deleted file mode 100644
index 17904e3cd2..0000000000
--- a/examples/widgets/statemachine/factorial/CMakeLists.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-# Generated from factorial.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(factorial LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/statemachine/factorial")
-
-find_package(Qt6 COMPONENTS Core)
-
-add_executable(factorial
- main.cpp
-)
-target_link_libraries(factorial PUBLIC
- Qt::Core
-)
-
-install(TARGETS factorial
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/statemachine/factorial/factorial.pro b/examples/widgets/statemachine/factorial/factorial.pro
deleted file mode 100644
index bf285acf4d..0000000000
--- a/examples/widgets/statemachine/factorial/factorial.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-QT = core
-CONFIG += cmdline
-
-SOURCES += main.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/statemachine/factorial
-INSTALLS += target
-
-
diff --git a/examples/widgets/statemachine/factorial/main.cpp b/examples/widgets/statemachine/factorial/main.cpp
deleted file mode 100644
index e6cbdcae29..0000000000
--- a/examples/widgets/statemachine/factorial/main.cpp
+++ /dev/null
@@ -1,181 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtCore>
-
-//! [0]
-class Factorial : public QObject
-{
- Q_OBJECT
- Q_PROPERTY(int x READ x WRITE setX)
- Q_PROPERTY(int fac READ fac WRITE setFac)
-public:
- using QObject::QObject;
-
- int x() const
- {
- return m_x;
- }
-
- void setX(int x)
- {
- if (x == m_x)
- return;
- m_x = x;
- emit xChanged(x);
- }
-
- int fac() const
- {
- return m_fac;
- }
-
- void setFac(int fac)
- {
- m_fac = fac;
- }
-
-Q_SIGNALS:
- void xChanged(int value);
-
-private:
- int m_x = -1;
- int m_fac = 1;
-};
-//! [0]
-
-//! [1]
-class FactorialLoopTransition : public QSignalTransition
-{
-public:
- FactorialLoopTransition(Factorial *fact)
- : QSignalTransition(fact, &Factorial::xChanged), m_fact(fact)
- {}
-
- bool eventTest(QEvent *e) override
- {
- if (!QSignalTransition::eventTest(e))
- return false;
- QStateMachine::SignalEvent *se = static_cast<QStateMachine::SignalEvent*>(e);
- return se->arguments().at(0).toInt() > 1;
- }
-
- void onTransition(QEvent *e) override
- {
- QStateMachine::SignalEvent *se = static_cast<QStateMachine::SignalEvent*>(e);
- int x = se->arguments().at(0).toInt();
- int fac = m_fact->property("fac").toInt();
- m_fact->setProperty("fac", x * fac);
- m_fact->setProperty("x", x - 1);
- }
-
-private:
- Factorial *m_fact;
-};
-//! [1]
-
-//! [2]
-class FactorialDoneTransition : public QSignalTransition
-{
-public:
- FactorialDoneTransition(Factorial *fact)
- : QSignalTransition(fact, &Factorial::xChanged), m_fact(fact)
- {}
-
- bool eventTest(QEvent *e) override
- {
- if (!QSignalTransition::eventTest(e))
- return false;
- QStateMachine::SignalEvent *se = static_cast<QStateMachine::SignalEvent*>(e);
- return se->arguments().at(0).toInt() <= 1;
- }
-
- void onTransition(QEvent *) override
- {
- qInfo() << m_fact->property("fac").toInt();
- }
-
-private:
- Factorial *m_fact;
-};
-//! [2]
-
-//! [3]
-int main(int argc, char **argv)
-{
- QCoreApplication app(argc, argv);
- Factorial factorial;
- QStateMachine machine;
-//! [3]
-
-//! [4]
- QState *compute = new QState(&machine);
- compute->assignProperty(&factorial, "fac", 1);
- compute->assignProperty(&factorial, "x", 6);
- compute->addTransition(new FactorialLoopTransition(&factorial));
-//! [4]
-
-//! [5]
- QFinalState *done = new QFinalState(&machine);
- FactorialDoneTransition *doneTransition = new FactorialDoneTransition(&factorial);
- doneTransition->setTargetState(done);
- compute->addTransition(doneTransition);
-//! [5]
-
-//! [6]
- machine.setInitialState(compute);
- QObject::connect(&machine, &QStateMachine::finished, &app, QCoreApplication::quit);
- machine.start();
-
- return app.exec();
-}
-//! [6]
-
-#include "main.moc"
diff --git a/examples/widgets/statemachine/pingpong/CMakeLists.txt b/examples/widgets/statemachine/pingpong/CMakeLists.txt
deleted file mode 100644
index 68cb4acb44..0000000000
--- a/examples/widgets/statemachine/pingpong/CMakeLists.txt
+++ /dev/null
@@ -1,31 +0,0 @@
-# Generated from pingpong.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(pingpong LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/statemachine/pingpong")
-
-find_package(Qt6 COMPONENTS Core)
-
-add_executable(pingpong
- main.cpp
-)
-target_link_libraries(pingpong PUBLIC
- Qt::Core
-)
-
-install(TARGETS pingpong
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/statemachine/pingpong/main.cpp b/examples/widgets/statemachine/pingpong/main.cpp
deleted file mode 100644
index c09060c502..0000000000
--- a/examples/widgets/statemachine/pingpong/main.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtCore>
-#include <stdio.h>
-
-//! [0]
-class PingEvent : public QEvent
-{
-public:
- PingEvent() : QEvent(QEvent::Type(QEvent::User+2))
- {}
-};
-
-class PongEvent : public QEvent
-{
-public:
- PongEvent() : QEvent(QEvent::Type(QEvent::User+3))
- {}
-};
-//! [0]
-
-//! [1]
-class Pinger : public QState
-{
-public:
- Pinger(QState *parent)
- : QState(parent) {}
-
-protected:
- void onEntry(QEvent *) override
- {
- machine()->postEvent(new PingEvent());
- fprintf(stdout, "ping?\n");
- }
-};
-//! [1]
-
-//! [3]
-class PongTransition : public QAbstractTransition
-{
-public:
- PongTransition() {}
-
-protected:
- bool eventTest(QEvent *e) override {
- return (e->type() == QEvent::User+3);
- }
- void onTransition(QEvent *) override
- {
- machine()->postDelayedEvent(new PingEvent(), 500);
- fprintf(stdout, "ping?\n");
- }
-};
-//! [3]
-
-//! [2]
-class PingTransition : public QAbstractTransition
-{
-public:
- PingTransition() {}
-
-protected:
- bool eventTest(QEvent *e) override {
- return (e->type() == QEvent::User+2);
- }
- void onTransition(QEvent *) override
- {
- machine()->postDelayedEvent(new PongEvent(), 500);
- fprintf(stdout, "pong!\n");
- }
-};
-//! [2]
-
-//! [4]
-int main(int argc, char **argv)
-{
- QCoreApplication app(argc, argv);
-
- QStateMachine machine;
- QState *group = new QState(QState::ParallelStates);
- group->setObjectName("group");
-//! [4]
-
-//! [5]
- Pinger *pinger = new Pinger(group);
- pinger->setObjectName("pinger");
- pinger->addTransition(new PongTransition());
-
- QState *ponger = new QState(group);
- ponger->setObjectName("ponger");
- ponger->addTransition(new PingTransition());
-//! [5]
-
-//! [6]
- machine.addState(group);
- machine.setInitialState(group);
- machine.start();
-
- return app.exec();
-}
-//! [6]
diff --git a/examples/widgets/statemachine/pingpong/pingpong.pro b/examples/widgets/statemachine/pingpong/pingpong.pro
deleted file mode 100644
index 18dee0400d..0000000000
--- a/examples/widgets/statemachine/pingpong/pingpong.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-QT = core
-CONFIG += cmdline
-
-SOURCES = main.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/statemachine/pingpong
-INSTALLS += target
-
-
diff --git a/examples/widgets/statemachine/rogue/CMakeLists.txt b/examples/widgets/statemachine/rogue/CMakeLists.txt
deleted file mode 100644
index 156b054311..0000000000
--- a/examples/widgets/statemachine/rogue/CMakeLists.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-# Generated from rogue.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(rogue LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/statemachine/rogue")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-add_qt_gui_executable(rogue
- main.cpp
- movementtransition.h
- window.cpp window.h
-)
-target_link_libraries(rogue PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS rogue
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/statemachine/rogue/main.cpp b/examples/widgets/statemachine/rogue/main.cpp
deleted file mode 100644
index 44ade770ee..0000000000
--- a/examples/widgets/statemachine/rogue/main.cpp
+++ /dev/null
@@ -1,64 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets>
-
-#include "window.h"
-
-int main(int argv, char **args)
-{
- QApplication app(argv, args);
-
- Window window;
- window.show();
-
- return app.exec();
-}
-
diff --git a/examples/widgets/statemachine/rogue/movementtransition.h b/examples/widgets/statemachine/rogue/movementtransition.h
deleted file mode 100644
index 74ffed6608..0000000000
--- a/examples/widgets/statemachine/rogue/movementtransition.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef MOVEMENTTRANSITION_H
-#define MOVEMENTTRANSITION_H
-
-#include <QtWidgets>
-
-#include "window.h"
-
-//![0]
-class MovementTransition : public QEventTransition
-{
- Q_OBJECT
-
-public:
- MovementTransition(Window *window) :
- QEventTransition(window, QEvent::KeyPress) {
- this->window = window;
- }
-//![0]
-
-//![1]
-protected:
- bool eventTest(QEvent *event) override {
- if (event->type() == QEvent::StateMachineWrapped &&
- static_cast<QStateMachine::WrappedEvent *>(event)->event()->type() == QEvent::KeyPress) {
- QEvent *wrappedEvent = static_cast<QStateMachine::WrappedEvent *>(event)->event();
-
- QKeyEvent *keyEvent = static_cast<QKeyEvent *>(wrappedEvent);
- int key = keyEvent->key();
-
- return key == Qt::Key_2 || key == Qt::Key_8 || key == Qt::Key_6 ||
- key == Qt::Key_4 || key == Qt::Key_Down || key == Qt::Key_Up ||
- key == Qt::Key_Right || key == Qt::Key_Left;
- }
- return false;
- }
-//![1]
-
-//![2]
- void onTransition(QEvent *event) override {
- QKeyEvent *keyEvent = static_cast<QKeyEvent *>(
- static_cast<QStateMachine::WrappedEvent *>(event)->event());
-
- int key = keyEvent->key();
- switch (key) {
- case Qt::Key_Left:
- case Qt::Key_4:
- window->movePlayer(Window::Left);
- break;
- case Qt::Key_Up:
- case Qt::Key_8:
- window->movePlayer(Window::Up);
- break;
- case Qt::Key_Right:
- case Qt::Key_6:
- window->movePlayer(Window::Right);
- break;
- case Qt::Key_Down:
- case Qt::Key_2:
- window->movePlayer(Window::Down);
- break;
- default:
- ;
- }
- }
-//![2]
-
-private:
- Window *window;
-};
-
-#endif
-
diff --git a/examples/widgets/statemachine/rogue/rogue.pro b/examples/widgets/statemachine/rogue/rogue.pro
deleted file mode 100644
index cf9657c7d6..0000000000
--- a/examples/widgets/statemachine/rogue/rogue.pro
+++ /dev/null
@@ -1,10 +0,0 @@
-QT += widgets
-
-HEADERS = window.h \
- movementtransition.h
-SOURCES = main.cpp \
- window.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/statemachine/rogue
-INSTALLS += target
diff --git a/examples/widgets/statemachine/rogue/window.cpp b/examples/widgets/statemachine/rogue/window.cpp
deleted file mode 100644
index a5363e2758..0000000000
--- a/examples/widgets/statemachine/rogue/window.cpp
+++ /dev/null
@@ -1,261 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets>
-
-#include "window.h"
-#include "movementtransition.h"
-
-//![0]
-Window::Window()
-{
- pX = 5;
- pY = 5;
-//![0]
-
- QFontDatabase database;
- QFont font;
- if (database.families().contains("Monospace")) {
- font = QFont("Monospace");
- }
- else {
- const QStringList fontFamilies = database.families();
- for (const QString &family : fontFamilies ) {
- if (database.isFixedPitch(family)) {
- font = QFont(family);
- break;
- }
- }
- }
- font.setPointSize(12);
- setFont(font);
-
-//![1]
- setupMap();
- buildMachine();
-}
-//![1]
-
-void Window::setStatus(const QString &status)
-{
- myStatus = status;
- repaint();
-}
-
-QString Window::status() const
-{
- return myStatus;
-}
-
-void Window::paintEvent(QPaintEvent * /* event */)
-{
- QFontMetrics metrics(font());
- QPainter painter(this);
- int fontHeight = metrics.height();
- int fontWidth = metrics.horizontalAdvance('X');
- int yPos = fontHeight;
- int xPos;
-
- painter.fillRect(rect(), Qt::black);
- painter.setPen(Qt::white);
-
- painter.drawText(QPoint(0, yPos), status());
-
- for (int y = 0; y < HEIGHT; ++y) {
- yPos += fontHeight;
- xPos = 0;
-
- for (int x = 0; x < WIDTH; ++x) {
- if (y == pY && x == pX) {
- xPos += fontWidth;
- continue;
- }
-
- painter.setPen(Qt::white);
-
- double x1 = static_cast<double>(pX);
- double y1 = static_cast<double>(pY);
- double x2 = static_cast<double>(x);
- double y2 = static_cast<double>(y);
-
- if (x2<x1) {
- x2+=0.5;
- } else if (x2>x1) {
- x2-=0.5;
- }
-
- if (y2<y1) {
- y2+=0.5;
- } else if (y2>y1) {
- y2-=0.5;
- }
-
- double dx = x2 - x1;
- double dy = y2 - y1;
-
- double length = qSqrt(dx*dx+dy*dy);
-
- dx /= length;
- dy /= length;
-
- double xi = x1;
- double yi = y1;
-
- while (length > 0) {
- int cx = static_cast<int>(xi+0.5);
- int cy = static_cast<int>(yi+0.5);
-
- if (x2 == cx && y2 == cy)
- break;
-
- if (!(x1==cx && y1==cy)
- && (map[cx][cy] == '#' || (length-10) > 0)) {
- painter.setPen(QColor(60,60,60));
- break;
- }
-
- xi += dx;
- yi += dy;
- --length;
- }
-
- painter.drawText(QPoint(xPos, yPos), map[x][y]);
- xPos += fontWidth;
- }
- }
- painter.setPen(Qt::white);
- painter.drawText(QPoint(pX * fontWidth, (pY + 2) * fontHeight), QChar('@'));
-}
-
-QSize Window::sizeHint() const
-{
- QFontMetrics metrics(font());
-
- return QSize(metrics.horizontalAdvance('X') * WIDTH, metrics.height() * (HEIGHT + 1));
-}
-
-//![2]
-void Window::buildMachine()
-{
- machine = new QStateMachine;
-
- QState *inputState = new QState(machine);
- inputState->assignProperty(this, "status", "Move the rogue with 2, 4, 6, and 8");
-
- MovementTransition *transition = new MovementTransition(this);
- inputState->addTransition(transition);
-//![2]
-
-//![3]
- QState *quitState = new QState(machine);
- quitState->assignProperty(this, "status", "Really quit(y/n)?");
-
- QKeyEventTransition *yesTransition = new
- QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Y);
- yesTransition->setTargetState(new QFinalState(machine));
- quitState->addTransition(yesTransition);
-
- QKeyEventTransition *noTransition =
- new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_N);
- noTransition->setTargetState(inputState);
- quitState->addTransition(noTransition);
-//![3]
-
-//![4]
- QKeyEventTransition *quitTransition =
- new QKeyEventTransition(this, QEvent::KeyPress, Qt::Key_Q);
- quitTransition->setTargetState(quitState);
- inputState->addTransition(quitTransition);
-//![4]
-
-//![5]
- machine->setInitialState(inputState);
-
- connect(machine, &QStateMachine::finished,
- qApp, &QApplication::quit);
-
- machine->start();
-}
-//![5]
-
-void Window::movePlayer(Direction direction)
-{
- switch (direction) {
- case Left:
- if (map[pX - 1][pY] != '#')
- --pX;
- break;
- case Right:
- if (map[pX + 1][pY] != '#')
- ++pX;
- break;
- case Up:
- if (map[pX][pY - 1] != '#')
- --pY;
- break;
- case Down:
- if (map[pX][pY + 1] != '#')
- ++pY;
- break;
- }
- repaint();
-}
-
-void Window::setupMap()
-{
- for (int x = 0; x < WIDTH; ++x)
- for (int y = 0; y < HEIGHT; ++y) {
- if (x == 0 || x == WIDTH - 1 || y == 0 || y == HEIGHT - 1 || QRandomGenerator::global()->bounded(40) == 0)
- map[x][y] = '#';
- else
- map[x][y] = '.';
- }
-}
-
diff --git a/examples/widgets/statemachine/rogue/window.h b/examples/widgets/statemachine/rogue/window.h
deleted file mode 100644
index af34815ffd..0000000000
--- a/examples/widgets/statemachine/rogue/window.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef WINDOW_H
-#define WINDOW_H
-
-#include <QWidget>
-
-QT_BEGIN_NAMESPACE
-class QState;
-class QStateMachine;
-class QTransition;
-QT_END_NAMESPACE
-
-#define WIDTH 35
-#define HEIGHT 20
-
-//![0]
-class Window : public QWidget
-{
- Q_OBJECT
- Q_PROPERTY(QString status READ status WRITE setStatus)
-
-public:
- enum Direction { Up, Down, Left, Right };
-
- Window();
-
- void movePlayer(Direction direction);
- void setStatus(const QString &status);
- QString status() const;
-
- QSize sizeHint() const override;
-
-protected:
- void paintEvent(QPaintEvent *event) override;
-//![0]
-
-//![1]
-private:
- void buildMachine();
- void setupMap();
-
- QChar map[WIDTH][HEIGHT];
- int pX, pY;
-
- QStateMachine *machine;
- QString myStatus;
-};
-//![1]
-
-#endif
-
diff --git a/examples/widgets/statemachine/statemachine.pro b/examples/widgets/statemachine/statemachine.pro
deleted file mode 100644
index 926e01cfda..0000000000
--- a/examples/widgets/statemachine/statemachine.pro
+++ /dev/null
@@ -1,12 +0,0 @@
-TEMPLATE = subdirs
-SUBDIRS = \
- factorial \
- pingpong
-
-qtHaveModule(widgets) {
- SUBDIRS += \
- eventtransitions \
- rogue \
- trafficlight \
- twowaybutton
-}
diff --git a/examples/widgets/statemachine/trafficlight/CMakeLists.txt b/examples/widgets/statemachine/trafficlight/CMakeLists.txt
deleted file mode 100644
index ca2ec2313a..0000000000
--- a/examples/widgets/statemachine/trafficlight/CMakeLists.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-# Generated from trafficlight.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(trafficlight LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/statemachine/trafficlight")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-add_qt_gui_executable(trafficlight
- main.cpp
-)
-target_link_libraries(trafficlight PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS trafficlight
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/statemachine/trafficlight/main.cpp b/examples/widgets/statemachine/trafficlight/main.cpp
deleted file mode 100644
index dd8bddcb37..0000000000
--- a/examples/widgets/statemachine/trafficlight/main.cpp
+++ /dev/null
@@ -1,200 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QApplication>
-#include <QFinalState>
-#include <QPainter>
-#include <QStateMachine>
-#include <QTimer>
-#include <QVBoxLayout>
-#include <QWidget>
-
-//! [0]
-class LightWidget : public QWidget
-{
- Q_OBJECT
- Q_PROPERTY(bool on READ isOn WRITE setOn)
-public:
- LightWidget(const QColor &color, QWidget *parent = nullptr)
- : QWidget(parent), m_color(color), m_on(false) {}
-
- bool isOn() const
- { return m_on; }
- void setOn(bool on)
- {
- if (on == m_on)
- return;
- m_on = on;
- update();
- }
-
-public slots:
- void turnOff() { setOn(false); }
- void turnOn() { setOn(true); }
-
-protected:
- void paintEvent(QPaintEvent *) override
- {
- if (!m_on)
- return;
- QPainter painter(this);
- painter.setRenderHint(QPainter::Antialiasing);
- painter.setBrush(m_color);
- painter.drawEllipse(0, 0, width(), height());
- }
-
-private:
- QColor m_color;
- bool m_on;
-};
-//! [0]
-
-//! [1]
-class TrafficLightWidget : public QWidget
-{
-public:
- TrafficLightWidget(QWidget *parent = nullptr)
- : QWidget(parent)
- {
- QVBoxLayout *vbox = new QVBoxLayout(this);
- m_red = new LightWidget(Qt::red);
- vbox->addWidget(m_red);
- m_yellow = new LightWidget(Qt::yellow);
- vbox->addWidget(m_yellow);
- m_green = new LightWidget(Qt::green);
- vbox->addWidget(m_green);
- QPalette pal = palette();
- pal.setColor(QPalette::Window, Qt::black);
- setPalette(pal);
- setAutoFillBackground(true);
- }
-
- LightWidget *redLight() const
- { return m_red; }
- LightWidget *yellowLight() const
- { return m_yellow; }
- LightWidget *greenLight() const
- { return m_green; }
-
-private:
- LightWidget *m_red;
- LightWidget *m_yellow;
- LightWidget *m_green;
-};
-//! [1]
-
-//! [2]
-QState *createLightState(LightWidget *light, int duration, QState *parent = nullptr)
-{
- QState *lightState = new QState(parent);
- QTimer *timer = new QTimer(lightState);
- timer->setInterval(duration);
- timer->setSingleShot(true);
- QState *timing = new QState(lightState);
- QObject::connect(timing, &QAbstractState::entered, light, &LightWidget::turnOn);
- QObject::connect(timing, &QAbstractState::entered, timer, QOverload<>::of(&QTimer::start));
- QObject::connect(timing, &QAbstractState::exited, light, &LightWidget::turnOff);
- QFinalState *done = new QFinalState(lightState);
- timing->addTransition(timer, &QTimer::timeout, done);
- lightState->setInitialState(timing);
- return lightState;
-}
-//! [2]
-
-//! [3]
-class TrafficLight : public QWidget
-{
-public:
- TrafficLight(QWidget *parent = nullptr)
- : QWidget(parent)
- {
- QVBoxLayout *vbox = new QVBoxLayout(this);
- TrafficLightWidget *widget = new TrafficLightWidget;
- vbox->addWidget(widget);
- vbox->setContentsMargins(QMargins());
-
- QStateMachine *machine = new QStateMachine(this);
- QState *redGoingYellow = createLightState(widget->redLight(), 3000);
- redGoingYellow->setObjectName("redGoingYellow");
- QState *yellowGoingGreen = createLightState(widget->yellowLight(), 1000);
- yellowGoingGreen->setObjectName("yellowGoingGreen");
- redGoingYellow->addTransition(redGoingYellow, &QState::finished, yellowGoingGreen);
- QState *greenGoingYellow = createLightState(widget->greenLight(), 3000);
- greenGoingYellow->setObjectName("greenGoingYellow");
- yellowGoingGreen->addTransition(yellowGoingGreen, &QState::finished, greenGoingYellow);
- QState *yellowGoingRed = createLightState(widget->yellowLight(), 1000);
- yellowGoingRed->setObjectName("yellowGoingRed");
- greenGoingYellow->addTransition(greenGoingYellow, &QState::finished, yellowGoingRed);
- yellowGoingRed->addTransition(yellowGoingRed, &QState::finished, redGoingYellow);
-
- machine->addState(redGoingYellow);
- machine->addState(yellowGoingGreen);
- machine->addState(greenGoingYellow);
- machine->addState(yellowGoingRed);
- machine->setInitialState(redGoingYellow);
- machine->start();
- }
-};
-//! [3]
-
-//! [4]
-int main(int argc, char **argv)
-{
- QApplication app(argc, argv);
-
- TrafficLight widget;
- widget.resize(110, 300);
- widget.show();
-
- return app.exec();
-}
-//! [4]
-
-#include "main.moc"
diff --git a/examples/widgets/statemachine/trafficlight/trafficlight.pro b/examples/widgets/statemachine/trafficlight/trafficlight.pro
deleted file mode 100644
index 85d9cda504..0000000000
--- a/examples/widgets/statemachine/trafficlight/trafficlight.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-QT += widgets
-
-SOURCES = main.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/statemachine/trafficlight
-INSTALLS += target
-
-
diff --git a/examples/widgets/statemachine/twowaybutton/CMakeLists.txt b/examples/widgets/statemachine/twowaybutton/CMakeLists.txt
deleted file mode 100644
index 91abfc0db0..0000000000
--- a/examples/widgets/statemachine/twowaybutton/CMakeLists.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-# Generated from twowaybutton.pro.
-
-cmake_minimum_required(VERSION 3.14)
-project(twowaybutton LANGUAGES CXX)
-
-set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-set(CMAKE_AUTOMOC ON)
-set(CMAKE_AUTORCC ON)
-set(CMAKE_AUTOUIC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/widgets/statemachine/twowaybutton")
-
-find_package(Qt6 COMPONENTS Core)
-find_package(Qt6 COMPONENTS Gui)
-find_package(Qt6 COMPONENTS Widgets)
-
-add_qt_gui_executable(twowaybutton
- main.cpp
-)
-target_link_libraries(twowaybutton PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Widgets
-)
-
-install(TARGETS twowaybutton
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/widgets/statemachine/twowaybutton/main.cpp b/examples/widgets/statemachine/twowaybutton/main.cpp
deleted file mode 100644
index 3d4fef3bbe..0000000000
--- a/examples/widgets/statemachine/twowaybutton/main.cpp
+++ /dev/null
@@ -1,91 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <QtWidgets>
-
-//! [0]
-int main(int argc, char **argv)
-{
- QApplication app(argc, argv);
- QPushButton button;
- QStateMachine machine;
-//! [0]
-
-//! [1]
- QState *off = new QState();
- off->assignProperty(&button, "text", "Off");
- off->setObjectName("off");
-
- QState *on = new QState();
- on->setObjectName("on");
- on->assignProperty(&button, "text", "On");
-//! [1]
-
-//! [2]
- off->addTransition(&button, &QAbstractButton::clicked, on);
- on->addTransition(&button, &QAbstractButton::clicked, off);
-//! [2]
-
-//! [3]
- machine.addState(off);
- machine.addState(on);
-//! [3]
-
-//! [4]
- machine.setInitialState(off);
- machine.start();
-//! [4]
-
-//! [5]
- button.resize(100, 50);
- button.show();
- return app.exec();
-}
-//! [5]
diff --git a/examples/widgets/statemachine/twowaybutton/twowaybutton.pro b/examples/widgets/statemachine/twowaybutton/twowaybutton.pro
deleted file mode 100644
index 22d19308ae..0000000000
--- a/examples/widgets/statemachine/twowaybutton/twowaybutton.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-QT += widgets
-
-SOURCES = main.cpp
-
-# install
-target.path = $$[QT_INSTALL_EXAMPLES]/widgets/statemachine/twowaybutton
-INSTALLS += target
-
-