summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDmitriy Purgin <dmitriy.purgin@sequality.at>2020-01-07 15:50:40 +0100
committerDmitriy Purgin <dpurgin@gmail.com>2020-02-10 15:04:39 +0100
commit95577150167951c47f25071adade8562fbe91d25 (patch)
treec10664d7a783bceba0f65faebb397e123368216d /src
parentf415c5ad2392ff79930c6268698703482d6747ab (diff)
std::chrono overload added to QStateMachine::postDelayedEvent()
Some Qt classes already accept std::chrono durations in their methods (see, for example, QTimer). The proposed change adds an overload with std::chrono::milliseconds to QStateMachine::postDelayedEvent(). Change-Id: I360fd2bb54fedc7415e9ec17e096095be3604d41 Reviewed-by: Erik Verbruggen <erik.verbruggen@me.com>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/statemachine/qstatemachine.cpp20
-rw-r--r--src/corelib/statemachine/qstatemachine.h11
2 files changed, 31 insertions, 0 deletions
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp
index 9d2505ba2e..a257cbc306 100644
--- a/src/corelib/statemachine/qstatemachine.cpp
+++ b/src/corelib/statemachine/qstatemachine.cpp
@@ -3273,6 +3273,26 @@ QStateMachine::WrappedEvent::~WrappedEvent()
\sa QStateMachine::running
*/
+/*!
+ \fn QStateMachine::postDelayedEvent(QEvent *event, std::chrono::milliseconds delay)
+ \since 5.15
+ \overload
+ \threadsafe
+
+ Posts the given \a event for processing by this state machine, with the
+ given \a delay in milliseconds. Returns an identifier associated with the
+ delayed event, or -1 if the event could not be posted.
+
+ This function returns immediately. When the delay has expired, the event
+ will be added to the state machine's event queue for processing. The state
+ machine takes ownership of the event and deletes it once it has been
+ processed.
+
+ You can only post events when the state machine is running.
+
+ \sa cancelDelayedEvent(), postEvent()
+*/
+
QT_END_NAMESPACE
#include "qstatemachine.moc"
diff --git a/src/corelib/statemachine/qstatemachine.h b/src/corelib/statemachine/qstatemachine.h
index 07781d09a4..b3c87a959b 100644
--- a/src/corelib/statemachine/qstatemachine.h
+++ b/src/corelib/statemachine/qstatemachine.h
@@ -48,6 +48,10 @@
#include <QtCore/qset.h>
#include <QtCore/qvariant.h>
+#if __has_include(<chrono>)
+# include <chrono>
+#endif
+
QT_REQUIRE_CONFIG(statemachine);
QT_BEGIN_NAMESPACE
@@ -145,6 +149,13 @@ public:
bool eventFilter(QObject *watched, QEvent *event) override;
#endif
+#if __has_include(<chrono>) || defined(Q_QDOC)
+ int postDelayedEvent(QEvent *event, std::chrono::milliseconds delay)
+ {
+ return postDelayedEvent(event, int(delay.count()));
+ }
+#endif
+
public Q_SLOTS:
void start();
void stop();