/****************************************************************************
**
** Copyright (C) 2020 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$
**
****************************************************************************/

/*!
    \page qml-changes-qt6.html
    \title Changes to Qt QML
    \ingroup changes-qt-5-to-6
    \brief Migrate Qt QML to Qt 6.

    Qt 6 is a result of the conscious effort to make the framework more
    efficient and easy to use.

    We try to maintain binary and source compatibility for all the public
    APIs in each release. But some changes were inevitable in an effort to
    make Qt a better framework.

    In this topic we summarize those changes in Qt QML, and provide
    guidance to handle them.

    \section1 QML language

    \section2 URL resolution

    In Qt 5, relative urls were often, albeit inconsistently, directly resolved, especially when
    assigned to an url property. In Qt 6 this is no longer the case.

    If you had a QML file stored under "/home/qml/example.qml", and "example.qml" contained
    \code
    property url imageFolder: "./images"
    \endcode
    then the url property would store the URL "/home/qml/images". This made it impossible to use
    relative URLs in QML in this way, so in Qt 6, the URL stays relative, and only gets resolved
    when this is required (e.g. when it is used as the source of an Image component).
    If you depend on the old behavior, you can use \c Qt.resolvedUrl
    \oldcode
    property url imageFolder: "./images"
    \newcode
    property url imageFolder: Qt.resolvedUrl("./images")
    \endcode
    Qt.resolvedUrl can be used in both Qt 5 and 6.

    \section2 Variant Properties

    \c variant properties, which have been marked as obsolete since Qt 5, are now treated in exactly
    the same way as \c var properties.
    Code that relied on implicit string conversion triggered on assignment to variant properties
    should be updated to explicitly create an object of the correct type.
    \oldcode
    property variant myColor: "red"
    \newcode
    property variant myColor: Qt.color("red")
    \endcode

    Implicit conversions were done for strings that could be parsed as
    \list
    \li color (use Qt.color instead instead),
    \li date (use the Date object instead),
    \li rect (use Qt.rect instead) and
    \li size (use Qt.size instead)
    \endlist

    \c variant still remains a deprecated keyword in Qt 6, though new code is strongly encouraged to
    use \c var properties instead.

    \note If the type of the property is known not to change, use a property of the concrete type,
    instead of a \c var property.

    \note These conversions were also applied to \c QVariant properties of classes registered with
    the engine. As with \c variant properties, code that relied on implicit string conversions need
    to use the corresponding functions of the Qt object.

    \section1 Source Incompatible API Changes

    \section2 Changed API

    \c QQmlListProperty's  \c CountFunction and \c AtFunction have been changed to use \c qsizetype
    instead of \c int to align with the corresponding changes in Qt's containers.

    \oldcode
    int myCountFunction(QQmlListProperty<MyType> *);
    MyType *myAtFunction(QQmlListProperty<MyType> *, int);

    QQmlListProperty<MyType> myReadOnlyList(containingObject, container, &myCountFunction,
                                            &myAtFunction);
    \newcode
    qsizetype myCountFunction(QQmlListProperty<MyType> *);
    MyType *myAtFunction(QQmlListProperty<MyType> *, qsizetype);

    QQmlListProperty<MyType> myReadOnlyList(containingObject, container, &myCountFunction,
                                            &myAtFunction);
    \endcode

    Code which needs to supports both Qt 5 and Qt 6 can either use a typedef which is \c int in Qt 5
    and \c qsizetype in Qt 6, or use \c QList::size_type, which already is such a type alias.

    \section2 Removed API

    Various deprecated functions have been removed.

    \list
    \li The QQmlListProperty constructor taking a reference has been removed.
    \oldcode
    QQmlListProperty<QObject>(owner, owner->objectList);
    \newcode
    QQmlListProperty<QObject>(owner, &owner->objectList);
    \endcode

    \li The functions \c qmlDebug, \c qmlInfo, \c qmlWarning,  \c qmlContext and \c qmlEngine used
    to exist both in the global namespace (or Qt namespace in namespaced builds), and in the \c
    QtQml namespace. These functions now exist only in the global namespace.
    \oldcode
    QQmlEngine *engine = QtQml::qmlEngine(qmlObject);
    \newcode
    QQmlEngine *engine = qmlEngine(qmlObject);
    \endcode

    \li The \c qmlRegisterType overload taking no arguments has been removed. Use
    \c qmlRegisterAnonymousType instead, or switch to declarative type registration with
    \c QML_ANONYMOUS.
    \oldcode
    class AnonymousType : public QObject {
      // ...
    };

    qmlRegisterType<AnonymousType>();
    \newcode
    class AnonymousType : public QObject {
      // ...
    };

    qmlRegisterAnonymousType<AnonymousType>("MyModule", 1);
    \endcode
    Or alternatively
    \code
    class AnonymousType : public QObject {
        QML_ANONYMOUS
        // ...
    };
    \endcode

    \li  The overloads of \c qmlRegisterExtendedType and \c qmlRegisterInterface
    which take no version argument have been removed. Use the overloads providing a
    version, or switch to declarative type registration with QML_EXTENDED
    and QML_INTERFACE.

    \oldcode
    struct GreetInterface
    {
       virtual ~GreetInterface();
       virtual void greet();
    };
    Q_DECLARE_INTERFACE(GreetInterface, "org.hi.GreetInterface")

    qmlRegisterInterface<GreetInterface>("Greeter");
    \newcode
    struct GreetInterface
    {
       virtual ~GreetInterface();
       virtual void greet();
    };
    Q_DECLARE_INTERFACE(GreetInterface, "org.hi.GreetInterface")

    qmlRegisterInterface<GreetInterface>("Greeter", 1);
    \endcode
    Alternatively
    \code
    struct GreetInterface
    {
       QML_INTERFACE(Greeter)
       virtual ~GreetInterface();
       virtual void greet();
    };
    Q_DECLARE_INTERFACE(GreetInterface, "org.hi.GreetInterface")
    \endcode
    \note In new code, declarative type registration should be preferred.

    \li The function \c QJSValue::engine has been removed. If access to the engine is required, a
    reference to it must be stored instead.

    \li \c qmlAttachedPropertiesObjectById and \c qmlAttachedPropertiesObject(int *, const QObject *,
    const QMetaObject *, bool) have been removed.  Use the
    \c qmlAttachedPropertiesObject(QObject *, QQmlAttachedPropertiesFunc, bool) overload of
    \c qmlAttachedPropertiesObject instead.

    \li \c QJSEngine::installTranslatorFunctions has been removed. \c QJSEngine::installExtensions
    is available as a replacement.
    \oldcode
    QJSEngine engine;
    engine.installTranslatorFunctions();
    \newcode
    QJSEngine engine;
    engine.installExtensions(QJSEngine::TranslationExtension);
    \endcode

    \endlist


*/
