diff options
Diffstat (limited to 'src/corelib/doc/snippets')
4 files changed, 102 insertions, 2 deletions
diff --git a/src/corelib/doc/snippets/code/doc_src_properties.cpp b/src/corelib/doc/snippets/code/doc_src_properties.cpp index 9a25918d47..7a70200cce 100644 --- a/src/corelib/doc/snippets/code/doc_src_properties.cpp +++ b/src/corelib/doc/snippets/code/doc_src_properties.cpp @@ -40,8 +40,8 @@ //! [0] Q_PROPERTY(type name - READ getFunction - [WRITE setFunction] + (READ getFunction [WRITE setFunction] | + MEMBER memberName [(READ getFunction | WRITE setFunction)]) [RESET resetFunction] [NOTIFY notifySignal] [REVISION int] @@ -130,3 +130,20 @@ object->setProperty("priority", "VeryHigh"); //! [7] Q_CLASSINFO("Version", "3.0.0") //! [7] + +//! [8] + Q_PROPERTY(QColor color MEMBER m_color NOTIFY colorChanged) + Q_PROPERTY(qreal spacing MEMBER m_spacing NOTIFY spacingChanged) + Q_PROPERTY(QString text MEMBER m_text NOTIFY textChanged) + ... +signals: + void colorChanged(); + void spacingChanged(); + void textChanged(const QString &newText); + +private: + QColor m_color; + qreal m_spacing; + QString m_text; +//! [8] + diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp index cbb5a9db5d..c349a6dbba 100644 --- a/src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qcoreapplication.cpp @@ -57,7 +57,14 @@ foreach (const QString &path, app.libraryPaths()) //! [3] +// Called once QCoreApplication exists +static void preRoutineMyDebugTool() +{ + MyDebugTool* tool = new MyDebugTool(QCoreApplication::instance()); + QCoreApplication::instance()->installEventFilter(tool); +} +Q_COREAPP_STARTUP_FUNCTION(preRoutineMyDebugTool) //! [3] diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qpoint.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qpoint.cpp index a83fd9a71f..8c6751cbaa 100644 --- a/src/corelib/doc/snippets/code/src_corelib_tools_qpoint.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_tools_qpoint.cpp @@ -79,6 +79,13 @@ p *= 2.5; // p becomes (-3, 10) //! [5] +//! [16] +QPoint p( 3, 7); +QPoint q(-1, 4); +int lengthSquared = QPoint::dotProduct(p, q); // lengthSquared becomes 25 +//! [16] + + //! [6] QPoint p(-3, 10); p /= 2.5; // p becomes (-1, 4) @@ -147,3 +154,10 @@ p *= 2.5; // p becomes (-2.75, 10.25) QPointF p(-2.75, 10.25); p /= 2.5; // p becomes (-1.1, 4.1) //! [15] + + +//! [17] +QPointF p( 3.1, 7.1); +QPointF q(-1.0, 4.1); +int lengthSquared = QPointF::dotProduct(p, q); // lengthSquared becomes 26.01 +//! [17] diff --git a/src/corelib/doc/snippets/qmessageauthenticationcode/main.cpp b/src/corelib/doc/snippets/qmessageauthenticationcode/main.cpp new file mode 100644 index 0000000000..4441fbd9a1 --- /dev/null +++ b/src/corelib/doc/snippets/qmessageauthenticationcode/main.cpp @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Ruslan Nigmatullin <euroelessar@yandex.ru> +** Contact: http://www.qt-project.org/legal +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** 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 Digia Plc and its Subsidiary(-ies) 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> + +int main(int argc, char *argv[]) +{ + QCoreApplication app(argc, argv); + +//! [0] + QByteArray key = "key"; + QByteArray message = "The quick brown fox jumps over the lazy dog"; +//! [0] + +//! [1] + QMessageAuthenticationCode code(QCryptographicHash::Sha1); + code.setKey(key); + code.addData(message); + code.result().toHex(); // returns "de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9" +//! [1] + +//! [2] + QMessageAuthenticationCode::hash(message, key, QCryptographicHash::Sha1).toHex(); +//! [2] +} |