/****************************************************************************
**
** Copyright (C) 2018 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** 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.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
** $QT_END_LICENSE$
**
****************************************************************************/

/*!
    \example quicksubscription
    \title Quick MQTT Example
    \ingroup qtmqtt-examples
    \brief Registering QMqttClient to QML and using it in a Qt Quick user
    interface.

    \image quicksubscription.png

    \e {Quick MQTT} demonstrates how to register QMqttClient as a QML type and
    use it in a Qt Quick application.

    \l {Qt MQTT} does not provide a QML API in its current version. However,
    you can make the C++ classes of the module available to QML.

    \section1 Creating a Client

    We create a \c QmlMqttClient class with the QMqttClient class as a base
    class:

    \quotefromfile quicksubscription/qmlmqttclient.cpp
    \skipto QmlMqttClient(
    \printuntil }

    We use the \c subscribe() function to create a subscription object:

    \printuntil }

    We connect to QMqttSubscription::messageReceived( ) to receive all messages
    sent to the broker:

    \printuntil }

    We use an QMqttMessage object to store the payload of a received
    message:

    \skipto handleMessage
    \printuntil }

    \section1 Registering Classes in QML

    In the \c main.cpp file, we register the \c QmlMqttClient class as a
    QML type, MqttClient:

    \quotefromfile quicksubscription/main.cpp
    \skipto main(int
    \printuntil qmlRegisterType

    In addition, we register the \c QmlMqttSubscription class as an uncreatable
    type:

    \printuntil qmlRegisterUncreatableType

    We can now use the MqttClient type in the \c main.qml file to create an
    MQTT client:

    \quotefromfile quicksubscription/main.qml
    \skipto MqttClient {
    \printuntil }
*/
