aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/doc/src/qt6-changes.qdoc
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/doc/src/qt6-changes.qdoc')
-rw-r--r--src/qml/doc/src/qt6-changes.qdoc125
1 files changed, 80 insertions, 45 deletions
diff --git a/src/qml/doc/src/qt6-changes.qdoc b/src/qml/doc/src/qt6-changes.qdoc
index 70c61849e7..4f95103a4f 100644
--- a/src/qml/doc/src/qt6-changes.qdoc
+++ b/src/qml/doc/src/qt6-changes.qdoc
@@ -1,29 +1,5 @@
-/****************************************************************************
-**
-** 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$
-**
-****************************************************************************/
+// Copyright (C) 2020 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\page qml-changes-qt6.html
@@ -56,11 +32,19 @@
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
+
+ For example, if you have code like
+
+ \code
property url imageFolder: "./images"
- \newcode
+ \endcode
+
+ you can rewrite it as
+
+ \code
property url imageFolder: Qt.resolvedUrl("./images")
\endcode
+
Qt.resolvedUrl can be used in both Qt 5 and 6.
\section2 Variant Properties
@@ -69,15 +53,22 @@
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
+
+ For example, if you have code like
+
+ \code
property variant myColor: "red"
- \newcode
+ \endcode
+
+ you can rewrite it as
+
+ \code
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 color (use Qt.color instead),
\li date (use the Date object instead),
\li rect (use Qt.rect instead) and
\li size (use Qt.size instead)
@@ -100,13 +91,19 @@
\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
+ For example, if you have code like
+
+ \code
int myCountFunction(QQmlListProperty<MyType> *);
MyType *myAtFunction(QQmlListProperty<MyType> *, int);
QQmlListProperty<MyType> myReadOnlyList(containingObject, container, &myCountFunction,
&myAtFunction);
- \newcode
+ \endcode
+
+ you can rewrite it as
+
+ \code
qsizetype myCountFunction(QQmlListProperty<MyType> *);
MyType *myAtFunction(QQmlListProperty<MyType> *, qsizetype);
@@ -123,37 +120,59 @@
\list
\li The QQmlListProperty constructor taking a reference has been removed.
- \oldcode
+
+ For example, if you have code like
+
+ \code
QQmlListProperty<QObject>(owner, owner->objectList);
- \newcode
+ \endcode
+
+ you can rewrite it as
+
+ \code
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
+
+ For example, if you have code like
+
+ \code
QQmlEngine *engine = QtQml::qmlEngine(qmlObject);
- \newcode
+ \endcode
+
+ you can rewrite it as
+
+ \code
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
+
+ For example, if you have code like
+
+ \code
class AnonymousType : public QObject {
// ...
};
qmlRegisterType<AnonymousType>();
- \newcode
+ \endcode
+
+ you can rewrite it as
+
+ \code
class AnonymousType : public QObject {
// ...
};
qmlRegisterAnonymousType<AnonymousType>("MyModule", 1);
\endcode
+
Or alternatively
\code
class AnonymousType : public QObject {
@@ -167,7 +186,9 @@
version, or switch to declarative type registration with QML_EXTENDED
and QML_INTERFACE.
- \oldcode
+ For example, if you have code like
+
+ \code
struct GreetInterface
{
virtual ~GreetInterface();
@@ -176,7 +197,11 @@
Q_DECLARE_INTERFACE(GreetInterface, "org.hi.GreetInterface")
qmlRegisterInterface<GreetInterface>("Greeter");
- \newcode
+ \endcode
+
+ you can rewrite it as
+
+ \code
struct GreetInterface
{
virtual ~GreetInterface();
@@ -186,7 +211,9 @@
qmlRegisterInterface<GreetInterface>("Greeter", 1);
\endcode
+
Alternatively
+
\code
struct GreetInterface
{
@@ -196,6 +223,7 @@
};
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
@@ -208,13 +236,20 @@
\li \c QJSEngine::installTranslatorFunctions has been removed. \c QJSEngine::installExtensions
is available as a replacement.
- \oldcode
+
+ For example, if you have code like
+
+ \code
QJSEngine engine;
engine.installTranslatorFunctions();
- \newcode
+ \endcode
+
+ you can rewrite it as
+
+ \code
QJSEngine engine;
- engine.installExtensions(QJSEngine::TranslationExtension
- \endcode;
+ engine.installExtensions(QJSEngine::TranslationExtension);
+ \endcode
\endlist