From 1f6bfc220774e9407fe88916843b76ed103cff72 Mon Sep 17 00:00:00 2001 From: Cristian Maureira-Fredes Date: Mon, 3 Sep 2018 14:02:13 +0200 Subject: Doc: Move literal code block to a separate file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We need to override this snippet for the documentation we generate for Qt for Python, and it is easier to have it on a separate file. Task-number: PYSIDE-801 Task-number: PYSIDE-691 Change-Id: Ideb5b6af25024279f167137d3b65660bb9c96a7e Reviewed-by: Topi Reiniƶ --- .../snippets/code/src_corelib_global_qglobal.cpp | 61 ++++++++++++++++++++++ 1 file changed, 61 insertions(+) (limited to 'src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp') diff --git a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp index 9d029e5d4d..c73e782b76 100644 --- a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp @@ -725,3 +725,64 @@ bool readConfiguration(const QFile &file) #include #endif //! [qt-version-check] + +//! [is-empty] + qgetenv(varName).isEmpty() +//! [is-empty] + +//! [to-int] + qgetenv(varName).toInt(ok, 0) +//! [to-int] + +//! [is-null] + !qgetenv(varName).isNull() +//! [is-null] + +//! [as-const-0] + QString s = ...; + for (QChar ch : s) // detaches 's' (performs a deep-copy if 's' was shared) + process(ch); + for (QChar ch : qAsConst(s)) // ok, no detach attempt + process(ch); +//! [as-const-0] + +//! [as-const-1] + const QString s = ...; + for (QChar ch : s) // ok, no detach attempt on const objects + process(ch); +//! [as-const-1] + +//! [as-const-2] + for (QChar ch : funcReturningQString()) + process(ch); // OK, the returned object is kept alive for the loop's duration +//! [as-const-2] + +//! [as-const-3] + for (QChar ch : qAsConst(funcReturningQString())) + process(ch); // ERROR: ch is copied from deleted memory +//! [as-const-3] + +//! [as-const-4] + for (QChar ch : qAsConst(funcReturningQString())) + process(ch); // ERROR: ch is copied from deleted memory +//! [as-const-4] + +//! [qterminate] + try { expr; } catch(...) { qTerminate(); } +//! [qterminate] + +//! [qdecloverride] + // generate error if this doesn't actually override anything: + virtual void MyWidget::paintEvent(QPaintEvent*) Q_DECL_OVERRIDE; +//! [qdecloverride] + +//! [qdeclfinal-1] + // more-derived classes no longer permitted to override this: + virtual void MyWidget::paintEvent(QPaintEvent*) Q_DECL_FINAL; +//! [qdeclfinal-1] + +//! [qdeclfinal-2] + class QRect Q_DECL_FINAL { // cannot be derived from + // ... + }; +//! [qdeclfinal-2] -- cgit v1.2.3