diff options
Diffstat (limited to 'src/qml/doc')
-rw-r--r-- | src/qml/doc/images/listmodel-nested.png | bin | 7493 -> 0 bytes | |||
-rw-r--r-- | src/qml/doc/images/listmodel.png | bin | 3407 -> 0 bytes | |||
-rw-r--r-- | src/qml/doc/images/objectmodel.png | bin | 347 -> 0 bytes | |||
-rw-r--r-- | src/qml/doc/qtqml.qdocconf | 12 | ||||
-rw-r--r-- | src/qml/doc/snippets/qml/workerscript/script.mjs | 4 | ||||
-rw-r--r-- | src/qml/doc/snippets/qml/workerscript/workerscript.qml | 74 | ||||
-rw-r--r-- | src/qml/doc/src/cppintegration/data.qdoc | 13 | ||||
-rw-r--r-- | src/qml/doc/src/cppintegration/extending-tutorial.qdoc | 19 | ||||
-rw-r--r-- | src/qml/doc/src/qmldiskcache.qdoc | 77 | ||||
-rw-r--r-- | src/qml/doc/src/qmlfunctions.qdoc | 1 | ||||
-rw-r--r-- | src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc | 2 | ||||
-rw-r--r-- | src/qml/doc/src/qmllanguageref/syntax/imports.qdoc | 7 | ||||
-rw-r--r-- | src/qml/doc/src/qtqml.qdoc | 2 |
13 files changed, 112 insertions, 99 deletions
diff --git a/src/qml/doc/images/listmodel-nested.png b/src/qml/doc/images/listmodel-nested.png Binary files differdeleted file mode 100644 index ee7ffba67a..0000000000 --- a/src/qml/doc/images/listmodel-nested.png +++ /dev/null diff --git a/src/qml/doc/images/listmodel.png b/src/qml/doc/images/listmodel.png Binary files differdeleted file mode 100644 index 7ab1771f15..0000000000 --- a/src/qml/doc/images/listmodel.png +++ /dev/null diff --git a/src/qml/doc/images/objectmodel.png b/src/qml/doc/images/objectmodel.png Binary files differdeleted file mode 100644 index 5e6d1325b2..0000000000 --- a/src/qml/doc/images/objectmodel.png +++ /dev/null diff --git a/src/qml/doc/qtqml.qdocconf b/src/qml/doc/qtqml.qdocconf index 74d0a3b27c..07ab974289 100644 --- a/src/qml/doc/qtqml.qdocconf +++ b/src/qml/doc/qtqml.qdocconf @@ -34,20 +34,14 @@ qhp.QtQml.subprojects.qmltypes.sortPages = true tagfile = ../../../doc/qtqml/qtqml.tags -depends += qtcore qtgui qtquick qtdoc qtlinguist qmake qtscript qtwidgets qtxmlpatterns qtquickcontrols +depends += qtcore qtqmlmodels qtqmlworkerscript qtgui qtquick qtdoc qtlinguist qmake qtscript qtwidgets qtxmlpatterns qtquickcontrols headerdirs += .. \ - ../../imports/models \ - ../../qmlmodels \ - ../../qml \ - ../../qmlworkerscript + ../../qml sourcedirs += .. \ - ../../imports/models \ ../../imports/statemachine \ - ../../qmlmodels \ - ../../qml \ - ../../qmlworkerscript + ../../qml exampledirs += ../../../examples/qml \ ../ \ diff --git a/src/qml/doc/snippets/qml/workerscript/script.mjs b/src/qml/doc/snippets/qml/workerscript/script.mjs deleted file mode 100644 index f55dee3507..0000000000 --- a/src/qml/doc/snippets/qml/workerscript/script.mjs +++ /dev/null @@ -1,4 +0,0 @@ -WorkerScript.onMessage = function(message) { - // ... long-running operations and calculations are done here - WorkerScript.sendMessage({ 'reply': 'Mouse is at ' + message.x + ',' + message.y }) -} diff --git a/src/qml/doc/snippets/qml/workerscript/workerscript.qml b/src/qml/doc/snippets/qml/workerscript/workerscript.qml deleted file mode 100644 index cc637d34cf..0000000000 --- a/src/qml/doc/snippets/qml/workerscript/workerscript.qml +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** 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. -** -** BSD License Usage -** Alternatively, 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 The Qt Company Ltd 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$ -** -****************************************************************************/ - -//![0] -import QtQuick 2.0 - -Rectangle { - width: 300; height: 300 - - Text { - id: myText - text: 'Click anywhere' - } - - WorkerScript { - id: myWorker - source: "script.mjs" - - onMessage: myText.text = messageObject.reply - } - - MouseArea { - anchors.fill: parent - onClicked: myWorker.sendMessage({ 'x': mouse.x, 'y': mouse.y }) - } -} -//![0] diff --git a/src/qml/doc/src/cppintegration/data.qdoc b/src/qml/doc/src/cppintegration/data.qdoc index 171b2b6a11..7c2693508c 100644 --- a/src/qml/doc/src/cppintegration/data.qdoc +++ b/src/qml/doc/src/cppintegration/data.qdoc @@ -308,6 +308,11 @@ In both the Q_PROPERTY and return from Q_INVOKABLE cases, the elements of a std::vector are copied. This copying may be an expensive operation, so std::vector should be used judiciously. +You can also create a list-like data structure by constructing a QJSValue using +QJSEngine::newArray(). Such a JavaScript array does not need any conversion +when passing it between QML and C++. See \l{QJSValue#Working With Arrays} for +details on how to manipulate JavaScript arrays from C++. + Other sequence types are not supported transparently, and instead an instance of any other sequence type will be passed between QML and C++ as an opaque QVariantList. @@ -381,6 +386,14 @@ properties: Q_DECLARE_METATYPE(Actor) \endcode +The usual pattern is to use a gadget class as the type of a property, or to +emit a gadget as a signal argument. In such cases, the gadget instance is +passed by value between C++ and QML (because it's a value type). If QML code +changes a property of a gadget property, the entire gadget is re-created and +passed back to the C++ property setter. In Qt 5, gadget types cannot be +instantiated by direct declaration in QML. In contrast, a QObject instance can +be declared; and QObject instances are always passed by pointer from C++ to QML. + \section1 Enumeration Types To use a custom enumeration as a data type, its class must be registered and diff --git a/src/qml/doc/src/cppintegration/extending-tutorial.qdoc b/src/qml/doc/src/cppintegration/extending-tutorial.qdoc index 43987354ae..d587173e5a 100644 --- a/src/qml/doc/src/cppintegration/extending-tutorial.qdoc +++ b/src/qml/doc/src/cppintegration/extending-tutorial.qdoc @@ -133,10 +133,9 @@ Here is the application \c main.cpp: \snippet tutorials/extending-qml/chapter1-basics/main.cpp 0 -This call to qmlRegisterType() registers the \c PieChart type as a type called "PieChart", -in a type namespace called "Charts", with a version of 1.0. - -Lastly, we write a \c .pro project file that includes the files and the \c declarative library: +We write a \c .pro project file that includes the files and the \c qml library, and +defines a type namespace called "Charts" with a version of 1.0 for any types exposed +to QML: \quotefile tutorials/extending-qml/chapter1-basics/chapter1-basics.pro @@ -314,15 +313,13 @@ item when its contents are drawn: \snippet tutorials/extending-qml/chapter4-customPropertyTypes/piechart.cpp 0 -Like the \c PieChart type, the \c PieSlice type has to be registered -using qmlRegisterType() to be used from QML. As with \c PieChart, we'll add the -type to the "Charts" type namespace, version 1.0: +Like the \c PieChart type, the \c PieSlice type has to be exposted to QML +using QML_ELEMENT. As with \c PieChart, we add the "Charts" type namespace, +version 1.0 to the .pro file: -\snippet tutorials/extending-qml/chapter4-customPropertyTypes/main.cpp 0 -\dots -\snippet tutorials/extending-qml/chapter4-customPropertyTypes/main.cpp 1 +\snippet tutorials/extending-qml/chapter4-customPropertyTypes/pieslice.h 0 \dots -\snippet tutorials/extending-qml/chapter4-customPropertyTypes/main.cpp 2 +\quotefile tutorials/extending-qml/chapter1-basics/chapter4-customPropertyTypes.pro The source code from the following files are referred to in this chapter: \generatelist examplefiles .*chapter4.* diff --git a/src/qml/doc/src/qmldiskcache.qdoc b/src/qml/doc/src/qmldiskcache.qdoc new file mode 100644 index 0000000000..100334296c --- /dev/null +++ b/src/qml/doc/src/qmldiskcache.qdoc @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2019 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 qmldiskcache.html +\title The QML Disk Cache +\brief QML caches compiled documents on disk to improve load time. + +When your application loads a QML or JavaScript file for the first time, +the QML engine compiles the file into a byte code representation on the +fly and runs it. The compiling process can be time consuming, and subsequent +loads of the same document yield the same result. To optimize this step, the +QML engine can cache the result. It stores the byte code in a cache file and +later loads the cache file instead of re-compiling when the same file is +requested again. Usually the files are stored in a subdirectory \c{qmlcache} +of the system's cache directory, as denoted by QStandardPaths::CacheLocation. +Checks are in place to make sure that the cache files are only loaded if all +of the following conditions are met: +\list + \li The Qt version has not changed + \li The source code in the original file has not changed + \li The QML debugger is not running +\endlist + +The disk caching behavior can be fine tuned using the following environment +variables: + +\table + \header + \li Environment Variable + \li Description + \row + \li \c{QML_DISABLE_DISK_CACHE} + \li Disables the disk cache and forces re-compilation from source for + all QML and JavaScript files. + \row + \li \c{QML_FORCE_DISK_CACHE} + \li Enables the disk cache even when debugging QML. You cannot use the + JavaScript debugger this way. It may fail to stop at breakpoints, + for example. You can still use the QML inspector to explore the + object hierarchy, though. \c{QML_FORCE_DISK_CACHE} overrides + \c{QML_DISABLE_DISK_CACHE}. + \row + \li \c{QML_DISK_CACHE_PATH} + \li Specifies a custom location where the cache files shall be stored + instead of using the default location. +\endtable + +You can also specify \c{CONFIG += qtquickcompiler} in your \c{.pro} file +to perform the compilation ahead of time and integrate the resulting byte code +directly into your executable. For more information, see \l{Qt Quick Compiler}. + +*/ diff --git a/src/qml/doc/src/qmlfunctions.qdoc b/src/qml/doc/src/qmlfunctions.qdoc index b2d322465d..67c0f6bb25 100644 --- a/src/qml/doc/src/qmlfunctions.qdoc +++ b/src/qml/doc/src/qmlfunctions.qdoc @@ -275,6 +275,7 @@ /*! \fn int qmlRegisterAnonymousType(const char *uri, int versionMajor) + \relates QQmlEngine This template function registers the C++ type in the QML system as an anonymous type. The resulting QML type does not have a name. Therefore, instances of this type cannot be created from diff --git a/src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc b/src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc index 01e81e7c19..05447db627 100644 --- a/src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc +++ b/src/qml/doc/src/qmllanguageref/modules/qqmlextensionplugin.qdocinc @@ -29,7 +29,7 @@ Suppose there is a new \c TimeModel C++ class that should be made available as a new QML type. It provides the current time through \c hour and \c minute properties. -\snippet qmlextensionplugins/plugin.cpp 0 +\snippet qmlextensionplugins/timemodel.h 0 \dots To make this type available, we create a plugin class named \c QExampleQmlPlugin diff --git a/src/qml/doc/src/qmllanguageref/syntax/imports.qdoc b/src/qml/doc/src/qmllanguageref/syntax/imports.qdoc index 57e0ba1a14..32106d5bb8 100644 --- a/src/qml/doc/src/qmllanguageref/syntax/imports.qdoc +++ b/src/qml/doc/src/qmllanguageref/syntax/imports.qdoc @@ -299,6 +299,13 @@ Additional import paths can be added through QQmlEngine::addImportPath() or the \l{Prototyping with qmlscene}{qmlscene} tool, you can also use the \c -I option to add an import path. +You can specify multiple import paths in the \c QML2_IMPORT_PATH environment +variable by joining them using the path separator. On Windows the path separator +is a semicolon (;), on other platforms it is a colon (:). This means that you +cannot specify resource paths or URLs in QML2_IMPORT_PATH, as they contain +colons themselves. However, you can add resource paths and URLs by calling +QQmlEngine::addImportPath() programatically. + \section1 Debugging diff --git a/src/qml/doc/src/qtqml.qdoc b/src/qml/doc/src/qtqml.qdoc index 68d2b66950..205cbc147d 100644 --- a/src/qml/doc/src/qtqml.qdoc +++ b/src/qml/doc/src/qtqml.qdoc @@ -155,6 +155,8 @@ Further information for writing QML applications: - essential information for application development with QML and Qt Quick \li \l{Qt Quick} - a module which provides a set of QML types and C++ classes for building user interfaces and applications with QML +\li \l{The QML Disk Cache} + - how to fine tune if and where the QML engine caches compilation results. \endlist \section2 Reference |