diff options
-rw-r--r-- | src/qml/doc/snippets/qml/imports/merged-named-imports.qml | 4 | ||||
-rw-r--r-- | src/qml/doc/src/qmllanguageref/syntax/imports.qdoc | 35 |
2 files changed, 24 insertions, 15 deletions
diff --git a/src/qml/doc/snippets/qml/imports/merged-named-imports.qml b/src/qml/doc/snippets/qml/imports/merged-named-imports.qml index 8fab0436bd..533b22cb93 100644 --- a/src/qml/doc/snippets/qml/imports/merged-named-imports.qml +++ b/src/qml/doc/snippets/qml/imports/merged-named-imports.qml @@ -49,8 +49,8 @@ ****************************************************************************/ //! [imports] -import QtQuick 2.0 as Project -import QtMultimedia 5.0 as Project +import QtQuick as Project +import QtMultimedia as Project Project.Rectangle { width: 100; height: 50 diff --git a/src/qml/doc/src/qmllanguageref/syntax/imports.qdoc b/src/qml/doc/src/qmllanguageref/syntax/imports.qdoc index fdba452271..7fe678b434 100644 --- a/src/qml/doc/src/qmllanguageref/syntax/imports.qdoc +++ b/src/qml/doc/src/qmllanguageref/syntax/imports.qdoc @@ -49,7 +49,7 @@ types and JavaScript resources into a given namespace. The generic form of a module import is as follows: \code -import <ModuleIdentifier> <Version.Number> [as <Qualifier>] +import <ModuleIdentifier> [<Version.Number>] [as <Qualifier>] \endcode \list @@ -59,7 +59,9 @@ import <ModuleIdentifier> <Version.Number> [as <Qualifier>] \li The \c <Version.Number> is a version of the form \c {MajorVersion.MinorVersion} which specifies which definitions of various object types and JavaScript resources will be made available due - to the import. + to the import. It can be omitted, in which case the latest version of the + module is imported. It is also possible to only omit the minor version. + Then the latest minor version of the given major version is imported. \li The \c <Qualifier> is an optional local namespace identifier into which the object types and JavaScript resources provided by the module will be installed, if given. If omitted, the object types and JavaScript @@ -69,7 +71,7 @@ import <ModuleIdentifier> <Version.Number> [as <Qualifier>] An example of an unqualified module import is as follows: \code -import QtQuick 2.0 +import QtQuick \endcode This import allows the use of all of the types provided by the \c QtQuick @@ -77,7 +79,7 @@ module without needing to specify a qualifier. For example, the client code to create a rectangle is as follows: \qml -import QtQuick 2.0 +import QtQuick Rectangle { width: 200 @@ -86,9 +88,16 @@ Rectangle { } \endqml +An example of an unqualified import with version would be +\code +import QtQuick 2.10 +\endcode +In that case, any types defined in QtQuick 2.11 and higher or in any higher major +version, like 6.0, would not be available to the file. + An example of a qualified module import is as follows: \code -import QtQuick 2.0 as Quick +import QtQuick as Quick \endcode This import allows multiple modules which provide conflicting type names to be @@ -100,7 +109,7 @@ An example of client code which creates a rectangle after using a qualified module import is as follows: \qml -import QtQuick 2.0 as Quick +import QtQuick as Quick Quick.Rectangle { width: 200 @@ -149,7 +158,7 @@ references to types from the \c QtQuick module must be prefixed with the \c CoreItems name: \qml -import QtQuick 2.0 as CoreItems +import QtQuick as CoreItems CoreItems.Rectangle { width: 100; height: 100 @@ -171,7 +180,7 @@ two modules can be imported into different namespaces to ensure the code is referring to the correct type: \qml -import QtQuick 2.0 as CoreItems +import QtQuick as CoreItems import "../textwidgets" as MyModule CoreItems.Rectangle { @@ -244,8 +253,8 @@ module by importing the module and using the identifier associated with a declared resource: \qml -import QtQuick 2.0 -import projects.MyQMLProject.MyFunctions 1.0 +import QtQuick +import projects.MyQMLProject.MyFunctions Item { Component.onCompleted: { SystemFunctions.cleanUp(); } @@ -257,9 +266,9 @@ resource identifiers must be prefixed with the namespace qualifier in order to be used: \qml -import QtQuick 2.0 -import projects.MyQMLProject.MyFunctions 1.0 as MyFuncs -import org.example.Functions 1.0 as TheirFuncs +import QtQuick +import projects.MyQMLProject.MyFunctions as MyFuncs +import org.example.Functions as TheirFuncs Item { Component.onCompleted: { |