summaryrefslogtreecommitdiffstats
path: root/src/corelib/doc/snippets
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2025-07-17 16:52:36 +0200
committerMarc Mutz <marc.mutz@qt.io>2025-07-18 10:07:38 +0200
commita5ecf321ea6322b12e710f2f139eb4c497411591 (patch)
tree25cf48a10b119184f2610883ee4e3e20b3ee5455 /src/corelib/doc/snippets
parenta09f9b8d71198dd43973a564135c80b13610c979 (diff)
QDeadlineTimer: link to cppreference.com for chrono_literals
Also don't use 'using namespace chrono' in snippets, but spell the types (nanoseconds, steady_clock) out in full. That doesn't break line-length limitations and makes it clearer (for the reader, and eventually, qdoc (when QTBUG-138535 lands) where each identifier comes from. Also remove the using namespace std::chrono_literals from the code snippets. They are repetitive and the linked cppreference.com gives all the available options how to import them, not just the one chosen here. Amends 12eacc3bab00f23d187a295b35e4a0d283ba85f4. Pick-to: 6.10 6.9 6.8 6.5 Task-number: QTBUG-138538 Change-Id: Id983c74cae16e98344e09d5575dc9927c76bec77 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/doc/snippets')
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_kernel_qdeadlinetimer.cpp13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qdeadlinetimer.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qdeadlinetimer.cpp
index f7440f2bb0f..52fcc6964b7 100644
--- a/src/corelib/doc/snippets/code/src_corelib_kernel_qdeadlinetimer.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qdeadlinetimer.cpp
@@ -1,6 +1,8 @@
// Copyright (C) 2018 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+using namespace std::chrono_literals;
+
//! [0]
void executeOperation(int msecs)
{
@@ -14,30 +16,23 @@
//! [0]
//! [1]
- using namespace std::chrono;
- using namespace std::chrono_literals;
-
QDeadlineTimer deadline(30s);
device->waitForReadyRead(deadline);
- if (deadline.remainingTime<nanoseconds>() > 300ms)
+ if (deadline.remainingTime<std::chrono::nanoseconds>() > 300ms)
cleanup();
//! [1]
//! [2]
- using namespace std::chrono;
- using namespace std::chrono_literals;
- auto now = steady_clock::now();
+ auto now = std::chrono::steady_clock::now();
QDeadlineTimer deadline(now + 1s);
Q_ASSERT(deadline == now + 1s);
//! [2]
//! [3]
- using namespace std::chrono_literals;
QDeadlineTimer deadline(250ms);
//! [3]
//! [4]
- using namespace std::chrono_literals;
deadline.setRemainingTime(250ms);
//! [4]