Rename "Basic Types" to "Value Types"

Internally they've been called "value types" all along. Now that we are
adding the ability to define your own value types the "basic" name is
not really fitting anymore. Value types can be quite complex.

Change-Id: I5fb4abec1dd2f0bbf7fb7f08b02db0882490e983
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
Ulf Hermann 2022-01-12 11:54:57 +01:00
parent 2ead10bf55
commit 712b637b58
29 changed files with 660 additions and 626 deletions

View File

@ -189,7 +189,7 @@ int main()
}
// ### DomKind
// any DomItem belongs to 5 basic types
// any DomItem belongs to one of 5 fundamental types
// 1. Object (a C++ object)
Q_ASSERT(qmlFile.domKind() == DomKind::Object);

View File

@ -81,7 +81,7 @@ QT_BEGIN_NAMESPACE
to save and restore such application settings with the minimum of effort.
Individual setting values are specified by declaring properties within a
Settings element. All \l {QML Basic Types}{basic type} properties are
Settings element. All \l {QML Value Types}{value type} properties are
supported. The recommended approach is to use property aliases in order
to get automatic property updates both ways. The following example shows
how to use Settings to store and restore the geometry of a window.

View File

@ -59,13 +59,13 @@ has a parent.
\section1 Basic Qt Data Types
By default, QML recognizes the following Qt data types, which are
automatically converted to a corresponding \l {QML Basic Types}{QML basic type}
automatically converted to a corresponding \l {QML Value Types}{QML value type}
when passed from C++ to QML and vice-versa:
\table
\row
\li Qt Type
\li QML Basic Type
\li QML Value Type
\row
\li bool
\li \l bool
@ -133,7 +133,7 @@ Item {
}
\endqml
See documentation for each individual type under \l {QML Basic Types} for more
See documentation for each individual type under \l {QML Value Types} for more
information.

View File

@ -132,7 +132,7 @@ using a standard QML \l Text item:
Notice that although the color is specified as a string in QML, it is automatically
converted to a QColor object for the PieChart \c color property. Automatic conversions are
provided for various other \l {QML Basic Types}{basic types}; for example, a string
provided for various other \l {QML Value Types}{value types}; for example, a string
like "640x480" can be automatically converted to a QSize value.
We'll also create a C++ application that uses a QQuickView to run and

View File

@ -268,7 +268,7 @@ QMetaObject::invokeMethod():
\endtable
Notice the parameter and return type specified after the colon. You can use \l
{QML Basic Types}{basic types} and \l {QML Object Types}{object types} as type
{QML Value Types}{value types} and \l {QML Object Types}{object types} as type
names.
If the type is omitted in QML, then you must specify QVariant as type with

View File

@ -310,14 +310,14 @@ signal just before being destroyed.
resources in Qt 5.0.0, so mark this section as internal for now.
It should eventually become public API
There is another section about scarce resources in basictypes.qdoc. It should
There is another section about scarce resources in valuetypes.qdoc. It should
be enabled at the same time.
\section1 Scarce Resources in JavaScript
As described in the documentation for \l{QML Basic Types}, a \c var type
As described in the documentation for \l{QML Value Types}, a \c var type
property may hold a \e{scarce resource} (image or pixmap). There are several
important semantics of scarce resources which should be noted:

View File

@ -64,7 +64,7 @@ objects such as \c Date and \c Math).
The functions defined in an imported JavaScript file are available to objects
defined in the importing QML document, via the
\c{"Qualifier.functionName(params)"} syntax. Functions in JavaScript resources
may take parameters whose type can be any of the supported QML basic types or
may take parameters whose type can be any of the supported QML value types or
object types, as well as normal JavaScript types. The normal
\l{qtqml-cppintegration-data.html}{data type conversion rules} will apply to
parameters and return values when calling such functions from QML.

View File

@ -77,7 +77,7 @@ modules.
\li \l{qtqml-typesystem-topic.html}{The QML Type System}
\list
\li \l{qtqml-typesystem-basictypes.html}{Basic Types}
\li \l{qtqml-typesystem-valuetypes.html}{QML Value Types}
\li \l{qtqml-typesystem-topic.html#javascript-types}{JavaScript Types}
\li \l{qtqml-typesystem-objecttypes.html}{QML Object Types}
\list

View File

@ -150,7 +150,7 @@ Rectangle {
\section4 Valid Types in Custom Property Definitions
Any of the \l {QML Basic Types} aside from the \l enumeration type can be used
Any of the \l {QML Value Types} aside from the \l enumeration type can be used
as custom property types. For example, these are all valid property declarations:
\qml
@ -164,11 +164,11 @@ Item {
(Enumeration values are simply whole number values and can be referred to with
the \l int type instead.)
Some basic types are provided by the \c QtQuick module and thus cannot be used
as property types unless the module is imported. See the \l {QML Basic Types}
Some value types are provided by the \c QtQuick module and thus cannot be used
as property types unless the module is imported. See the \l {QML Value Types}
documentation for more details.
Note the \l var basic type is a generic placeholder type that can hold any
Note the \l var value type is a generic placeholder type that can hold any
type of value, including lists and objects:
\code
@ -329,7 +329,7 @@ even though properties of the \c color type store colors and not strings,
you are able to assign the string \c "red" to a color property, without an
error being reported.
See \l {QML Basic Types} for a list of the types of properties that are
See \l {QML Value Types} for a list of the types of properties that are
supported by default. Additionally, any available \l {QML Object Types}
{QML object type} may also be used as a property type.
@ -430,10 +430,10 @@ Text {
}
\endcode
Grouped property types are basic types which have subproperties. Some of these
basic types are provided by the QML language, while others may only be used if
Grouped property types are value types which have subproperties. Some of these
value types are provided by the QML language, while others may only be used if
the Qt Quick module is imported. See the documentation about
\l{QML Basic Types} for more information.
\l{QML Value Types} for more information.
\section3 Property Aliases
@ -1132,7 +1132,7 @@ Text {
}
\endqml
More information on enumeration usage in QML can be found in the \l {QML Basic Types} \l enumeration documentation.
More information on enumeration usage in QML can be found in the \l {QML Value Types} \l enumeration documentation.
The ability to declare enumerations in QML was introduced in Qt 5.10.

View File

@ -1,6 +1,6 @@
/****************************************************************************
**
** Copyright (C) 2017 The Qt Company Ltd.
** Copyright (C) 2022 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
@ -27,523 +27,8 @@
/*!
\page qtqml-typesystem-basictypes.html
\title QML Basic Types
\brief Description of basic types provided by the Qt QML module
QML supports a number of basic types.
A \e{basic type} is one that refers to a simple value, such as an \c int
or a \c string. This contrasts with a \l{qtqml-typesystem-topic.html#qml-object-types}{QML Object Types},
which refers to an object with properties, signals, methods and so on. Unlike an object type,
a basic type cannot be used to declare QML objects: it is not possible, for example, to declare an
\c int{} object or a \c size{} object.
Basic types can be used to refer to:
\list
\li A single value (e.g. \l int refers to a single number, \l var can refer to a single list of items)
\li A value that contains a simple set of property-value pairs (e.g. \l size refers to a value with \c width and \c height attributes)
\endlist
When a variable or property holds a basic type and it is assigned to another
variable or property, then a copy of the value is made. In JavaScript, this
value is called a primitive value.
\sa {qtqml-typesystem-topic.html}{The QML Type System}
\section1 Supported Basic Types
Some basic types are supported by the engine by default and do not require an
\l {Import Statements}{import statement} to be used, while others do require
the client to import the module which provides them.
All of the basic types listed below may be used as a \c property type in a QML
document, with the following exceptions:
\list
\li \c list must be used in conjunction with a QML object type
\li \c enumeration cannot be used directly as the enumeration must be defined by a registered QML object type
\endlist
\section2 Basic Types Provided By The QML Language
The basic types supported natively in the QML language are listed below:
\annotatedlist qmlbasictypes
\section2 Basic Types Provided By QML Modules
QML modules may extend the QML language with more basic types.
For example, the basic types provided by the \c QtQuick module are listed below:
\annotatedlist qtquickbasictypes
The \l{QtQml::Qt}{Qt} global object provides useful functions for manipulating values of basic types.
Currently only QML modules which are provided by Qt may provide their
own basic types, however this may change in future releases of Qt QML.
In order to use types provided by a particular QML module, clients
must import that module in their QML documents.
\section1 Property Change Behavior for Basic Types
Some basic types have properties: for example, the \l font type has
\c pixelSize, \c family and \c bold properties. Unlike properties of
\l{qtqml-typesystem-topic.html#qml-object-types}{object types}, properties of
basic types do not provide their own property change signals. It is only possible
to create a property change signal handler for the basic type property itself:
\code
Text {
// invalid!
onFont.pixelSizeChanged: doSomething()
// also invalid!
font {
onPixelSizeChanged: doSomething()
}
// but this is ok
onFontChanged: doSomething()
}
\endcode
Be aware, however, that a property change signal for a basic type is emitted
whenever \e any of its attributes have changed, as well as when the property itself
changes. Take the following code, for example:
\qml
Text {
onFontChanged: console.log("font changed")
Text { id: otherText }
focus: true
// changing any of the font attributes, or reassigning the property
// to a different font value, will invoke the onFontChanged handler
Keys.onDigit1Pressed: font.pixelSize += 1
Keys.onDigit2Pressed: font.b = !font.b
Keys.onDigit3Pressed: font = otherText.font
}
\endqml
In contrast, properties of an \l{qtqml-typesystem-topic.html#qml-object-types}{object type}
emit their own property change signals, and a property change signal handler for an object-type
property is only invoked when the property is reassigned to a different object value.
\keyword QML Basic Types
\brief QML Value Types used to be called "Basic Types"
*/
/*!
\qmlbasictype int
\ingroup qmlbasictypes
\brief a whole number, e.g. 0, 10, or -20.
The \c int type refers to a whole number, e.g. 0, 10, or -20.
The possible \c int values range from -2147483648 to 2147483647,
although most types will only accept a reduced range (which they
mention in their documentation).
Example:
\qml
NumberAnimation { loops: 5 }
\endqml
This basic type is provided by the QML language.
\sa {QML Basic Types}
*/
/*!
\qmlbasictype bool
\ingroup qmlbasictypes
\brief a binary true/false value.
The \c bool type refers to a binary true/false value.
Example:
\qml
Item {
focus: true
clip: false
}
\endqml
This basic type is provided by the QML language.
\sa {QML Basic Types}
*/
/*!
\qmlbasictype real
\ingroup qmlbasictypes
\brief a number with a decimal point.
The \c real type refers to a number with decimal point, e.g. 1.2 or -29.8.
Example:
\qml
Item { width: 100.45; height: 150.82 }
\endqml
\b{Note:} In QML all reals are stored in double precision, \l
{http://en.wikipedia.org/wiki/IEEE_754} {IEEE floating point}
format.
This basic type is provided by the QML language.
\sa {QML Basic Types}
*/
/*!
\qmlbasictype double
\ingroup qmlbasictypes
\brief a number with a decimal point, stored in double precision.
The \c double type refers to a number with a decimal point and is stored in double precision, \l
{http://en.wikipedia.org/wiki/IEEE_754} {IEEE floating point} format.
Example:
\qml
Item {
property double number: 32155.2355
}
\endqml
This basic type is provided by the QML language.
\sa {QML Basic Types}
*/
/*!
\qmlbasictype string
\ingroup qmlbasictypes
\brief a free form text string.
The \c string type refers to a free form text string in quotes, e.g. "Hello world!".
Example:
\qml
Text { text: "Hello world!" }
\endqml
Strings have a \c length attribute that holds the number of
characters in the string.
QML extends the JavaScript String type with a \l {String::arg}{arg()} function
to support value substitution.
When integrating with C++, note that any QString value
\l{qtqml-cppintegration-data.html}{passed into QML from C++} is automatically
converted into a \c string value, and vice-versa.
This basic type is provided by the QML language.
\sa {QML Basic Types}
*/
/*!
\qmlbasictype url
\ingroup qmlbasictypes
\brief a resource locator.
The \c url type refers to a resource locator (like a file name, for example). It can be either
absolute, e.g. "http://qt-project.org", or relative, e.g. "pics/logo.png". A relative URL is
resolved relative to the URL of the containing component.
For example, the following assigns a valid URL to the \l {Image::source}
property, which is of type \c url:
\qml
Image { source: "pics/logo.png" }
\endqml
When integrating with C++, note that any QUrl value
\l{qtqml-cppintegration-data.html}{passed into QML from C++} is automatically
converted into a \c url value, and vice-versa.
Alternatively you may convert your \c url to a \l{https://developer.mozilla.org/en-US/docs/Web/API/URL}{URL} object
in order to access and modify its components:
\qml
var urlObject = new URL(url);
\endqml
\note In Qt 5, URLs were automatically resolved based on the current context
when assigning them to any \c url property. This made it impossible to
work with relative URLs and it created inconsistent behavior when reading
back a URL previously written to a property. Therefore, the behavior was
changed in Qt 6.
\note When referring to files stored with the \l{resources.html}{Qt Resource System}
from within QML, you should use "qrc:///" instead of ":/" as QML requires URL paths.
Relative URLs resolved from within that file will use the same protocol.
Additionally, URLs may contain encoded characters using the 'percent-encoding' scheme
specified by \l {https://datatracker.ietf.org/doc/html/rfc3986}{RFC 3986}. These characters
will be preserved within properties of type \c url, to allow QML code to
construct precise URL values.
For example, a local file containing a '#' character, which would normally be
interpreted as the beginning of the URL 'fragment' element, can be accessed by
encoding the characters of the file name:
\qml
Image { source: encodeURIComponent("/tmp/test#1.png") }
\endqml
This basic type is provided by the QML language.
\sa {QML Basic Types}
*/
/*!
\qmlbasictype list
\ingroup qmlbasictypes
\brief a list of QML objects.
The \c list type refers to a list of QML objects.
A list value can be accessed in a similar way to a JavaScript array:
\list
\li Values are assigned using the \c[] square bracket syntax with comma-separated values
\li The \c length property provides the number of items in the list
\li Values in the list are accessed using the \c [index] syntax
\endlist
Values can be dynamically added to the list by using the \c push method,
as if it were a JavaScript Array
A \c list can only store QML objects, and cannot contain any
\l {QML Basic Types}{basic type} values. (To store basic types within a
list, use the \l var type instead.)
When integrating with C++, note that any QQmlListProperty value
\l{qtqml-cppintegration-data.html}{passed into QML from C++} is automatically
converted into a \c list value, and vice-versa.
\section1 Using the list Type
For example, the \l Item type has a \l {Item::}{states} list-type property that
can be assigned to and used as follows:
\qml
import QtQuick 2.0
Item {
width: 100; height: 100
states: [
State { name: "activated" },
State { name: "deactivated" }
]
Component.onCompleted: {
console.log("Name of first state:", states[0].name)
for (var i = 0; i < states.length; i++)
console.log("state", i, states[i].name)
}
}
\endqml
The defined \l State objects will be added to the \c states list
in the order in which they are defined.
If the list only contains one object, the square brackets may be omitted:
\qml
import QtQuick 2.0
Item {
width: 100; height: 100
states: State { name: "activated" }
}
\endqml
Objects in a list can be replaced with the \c{[]} operator, just like
entries of JavaScript arrays. You can also use \c{push()} to append entries,
or you can set the \c length property of the list to truncate or extend it.
You can not automatically extend the list by assigning to an index currently
out of range, though. Furthermore, if you insert \c null values into the
list, those are converted to \c nullptr entries in the underlying
QQmlListProperty.
This basic type is provided by the QML language.
\sa {QML Basic Types}
*/
/*!
\qmlbasictype var
\ingroup qmlbasictypes
\brief a generic property type.
The \c var type is a generic property type that can refer to any data type.
It is equivalent to a regular JavaScript variable.
For example, var properties can store numbers, strings, objects,
arrays and functions:
\qml
Item {
property var aNumber: 100
property var aBool: false
property var aString: "Hello world!"
property var anotherString: String("#FF008800")
property var aColor: Qt.rgba(0.2, 0.3, 0.4, 0.5)
property var aRect: Qt.rect(10, 10, 10, 10)
property var aPoint: Qt.point(10, 10)
property var aSize: Qt.size(10, 10)
property var aVector3d: Qt.vector3d(100, 100, 100)
property var anArray: [1, 2, 3, "four", "five", (function() { return "six"; })]
property var anObject: { "foo": 10, "bar": 20 }
property var aFunction: (function() { return "one"; })
}
\endqml
\section1 Change Notification Semantics
It is important to note that changes in regular properties of JavaScript
objects assigned to a var property will \b{not} trigger updates of bindings
that access them. The example below will display "The car has 4 wheels" as
the change to the wheels property will not cause the reevaluation of the
binding assigned to the "text" property:
\qml
Item {
property var car: new Object({wheels: 4})
Text {
text: "The car has " + car.wheels + " wheels";
}
Component.onCompleted: {
car.wheels = 6;
}
}
\endqml
If the onCompleted handler instead had \tt{"car = new Object({wheels: 6})"}
then the text would be updated to say "The car has 6 wheels", since the
car property itself would be changed, which causes a change notification
to be emitted.
\section1 Property Value Initialization Semantics
The QML syntax defines that curly braces on the right-hand-side of a
property value initialization assignment denote a binding assignment.
This can be confusing when initializing a \c var property, as empty curly
braces in JavaScript can denote either an expression block or an empty
object declaration. If you wish to initialize a \c var property to an
empty object value, you should wrap the curly braces in parentheses.
For example:
\qml
Item {
property var first: {} // nothing = undefined
property var second: {{}} // empty expression block = undefined
property var third: ({}) // empty object
}
\endqml
In the previous example, the \c first property is bound to an empty
expression, whose result is undefined. The \c second property is bound to
an expression which contains a single, empty expression block ("{}"), which
similarly has an undefined result. The \c third property is bound to an
expression which is evaluated as an empty object declaration, and thus the
property will be initialized with that empty object value.
Similarly, a colon in JavaScript can be either an object property value
assignment, or a code label. Thus, initializing a var property with an
object declaration can also require parentheses:
\qml
Item {
property var first: { example: 'true' } // example is interpreted as a label
property var second: ({ example: 'true' }) // example is interpreted as a property
property var third: { 'example': 'true' } // example is interpreted as a property
Component.onCompleted: {
console.log(first.example) // prints 'undefined', as "first" was assigned a string
console.log(second.example) // prints 'true'
console.log(third.example) // prints 'true'
}
}
\endqml
\sa {QML Basic Types}
*/
/*
TODO Qt 5.1: see explanation in expressions.qdoc
\section1 Using Scarce Resources with the var Type
A \c var type property can also hold an image or pixmap.
A \c var which contains a QPixmap or QImage is known as a
"scarce resource" and the declarative engine will attempt to
automatically release such resources after evaluation of any JavaScript
expression which requires one to be copied has completed.
Clients may explicitly release such a scarce resource by calling the
"destroy" method on the \c var property from within JavaScript. They
may also explicitly preserve the scarce resource by calling the
"preserve" method on the \c var property from within JavaScript.
This basic type is provided by the QML language.
*/
/*!
\qmlbasictype enumeration
\ingroup qmlbasictypes
\brief a named enumeration value.
The \c enumeration type refers to a named enumeration value.
Each named value can be referred to as \c {<Type>.<value>}. For
example, the \l Text type has an \c AlignRight enumeration value:
\qml
Text { horizontalAlignment: Text.AlignRight }
\endqml
(For backwards compatibility, the enumeration value may also be
specified as a string, e.g. "AlignRight". This form is not
recommended for new code.)
When integrating with C++, note that any \c enum value
\l{qtqml-cppintegration-data.html}{passed into QML from C++} is automatically
converted into an \c enumeration value, and vice-versa.
This basic type is provided by the QML language. Some enumeration values
are provided by the QtQuick import.
\section1 Using the enumeration Type in QML
The \c enumeration type is a representation of a C++ \c enum type. It is
not possible to refer to the \c enumeration type in QML itself; instead, the
\l int or \l var types can be used when referring to \c enumeration values
from QML code.
For example:
\qml
import QtQuick 2.0
Item {
// refer to Text.AlignRight using an int type
property int enumValue: textItem.horizontalAlignment
signal valueEmitted(int someValue)
Text {
id: textItem
horizontalAlignment: Text.AlignRight
}
// emit valueEmitted() signal, which expects an int, with Text.AlignRight
Component.onCompleted: valueEmitted(Text.AlignRight)
}
\endqml
\sa {QML Basic Types}
\sa {qtqml-syntax-objectattributes.html#enumeration-attributes}{Enumeration Attributes}
See \l{qtqml-typesystem-valuetypes.html} for the documentation of QML value types.
*/

View File

@ -34,7 +34,7 @@ A QML object type is a type from which a QML object can be instantiated.
In syntactic terms, a QML object type is one which can be used to declare an
object by specifying the \e{type name} followed by a set of curly braces that
encompasses the attributes of that object. This differs from \e {basic types},
encompasses the attributes of that object. This differs from \e {value types},
which cannot be used in the same way. For example, \l Rectangle is a QML object
type: it can be used to create \c Rectangle type objects. This cannot be done
with primitive types such as \c int and \c bool, which are used to hold simple

View File

@ -46,15 +46,15 @@ Wherever the type definitions come from, the engine will enforce type-safety
for properties and instances of those types.
\section1 Basic Types
\section1 Value Types
The QML language has built-in support for various primitive types including
integers, double-precision floating point numbers, strings, and boolean values.
Objects may have properties of these types, and values of these types may be
passed as arguments to methods of objects.
See the \l{qtqml-typesystem-basictypes.html}{QML Basic Types} documentation for
more information about basic types.
See the \l{qtqml-typesystem-valuetypes.html}{QML Value Types} documentation for
more information about value types.
\section1 JavaScript Types

View File

@ -0,0 +1,549 @@
/****************************************************************************
**
** Copyright (C) 2022 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 qtqml-typesystem-valuetypes.html
\title QML Value Types
\brief Description of value types provided by the Qt QML module
QML supports a number of value types.
A \e{value type} is one that refers to a simple value, such as an \c int
or a \c string. This contrasts with a \l{qtqml-typesystem-topic.html#qml-object-types}{QML Object Types},
which refers to an object with properties, signals, methods and so on. Unlike an object type,
a value type cannot be used to declare QML objects: it is not possible, for example, to declare an
\c int{} object or a \c size{} object.
Value types can be used to refer to:
\list
\li A single value (e.g. \l int refers to a single number, \l var can refer to a single list of items)
\li A value that contains a simple set of property-value pairs (e.g. \l size refers to a value with \c width and \c height attributes)
\endlist
When a variable or property holds a value type and it is assigned to another
variable or property, then a copy of the value is made. In JavaScript, this
value is called a primitive value.
\sa {qtqml-typesystem-topic.html}{The QML Type System}
\section1 Supported Value Types
Some value types are supported by the engine by default and do not require an
\l {Import Statements}{import statement} to be used, while others do require
the client to import the module which provides them.
All of the value types listed below may be used as a \c property type in a QML
document, with the following exceptions:
\list
\li \c list must be used in conjunction with a QML object type
\li \c enumeration cannot be used directly as the enumeration must be defined by a registered QML object type
\endlist
\section2 Value Types Provided By The QML Language
The value types supported natively in the QML language are listed below:
\annotatedlist qmlvaluetypes
\section2 Value Types Provided By QML Modules
QML modules may extend the QML language with more value types.
For example, the value types provided by the \c QtQuick module are listed below:
\annotatedlist qtquickvaluetypes
The \l{QtQml::Qt}{Qt} global object provides useful functions for manipulating values of value types.
Currently only QML modules which are provided by Qt may provide their
own value types, however this may change in future releases of Qt QML.
In order to use types provided by a particular QML module, clients
must import that module in their QML documents.
\section1 Property Change Behavior for Value Types
Some value types have properties: for example, the \l font type has
\c pixelSize, \c family and \c bold properties. Unlike properties of
\l{qtqml-typesystem-topic.html#qml-object-types}{object types}, properties of
value types do not provide their own property change signals. It is only possible
to create a property change signal handler for the value type property itself:
\code
Text {
// invalid!
onFont.pixelSizeChanged: doSomething()
// also invalid!
font {
onPixelSizeChanged: doSomething()
}
// but this is ok
onFontChanged: doSomething()
}
\endcode
Be aware, however, that a property change signal for a value type is emitted
whenever \e any of its attributes have changed, as well as when the property itself
changes. Take the following code, for example:
\qml
Text {
onFontChanged: console.log("font changed")
Text { id: otherText }
focus: true
// changing any of the font attributes, or reassigning the property
// to a different font value, will invoke the onFontChanged handler
Keys.onDigit1Pressed: font.pixelSize += 1
Keys.onDigit2Pressed: font.b = !font.b
Keys.onDigit3Pressed: font = otherText.font
}
\endqml
In contrast, properties of an \l{qtqml-typesystem-topic.html#qml-object-types}{object type}
emit their own property change signals, and a property change signal handler for an object-type
property is only invoked when the property is reassigned to a different object value.
*/
/*!
\qmlbasictype int
\ingroup qmlvaluetypes
\brief a whole number, e.g. 0, 10, or -20.
The \c int type refers to a whole number, e.g. 0, 10, or -20.
The possible \c int values range from -2147483648 to 2147483647,
although most types will only accept a reduced range (which they
mention in their documentation).
Example:
\qml
NumberAnimation { loops: 5 }
\endqml
This value type is provided by the QML language.
\sa {QML Value Types}
*/
/*!
\qmlbasictype bool
\ingroup qmlvaluetypes
\brief a binary true/false value.
The \c bool type refers to a binary true/false value.
Example:
\qml
Item {
focus: true
clip: false
}
\endqml
This value type is provided by the QML language.
\sa {QML Value Types}
*/
/*!
\qmlbasictype real
\ingroup qmlvaluetypes
\brief a number with a decimal point.
The \c real type refers to a number with decimal point, e.g. 1.2 or -29.8.
Example:
\qml
Item { width: 100.45; height: 150.82 }
\endqml
\b{Note:} In QML all reals are stored in double precision, \l
{http://en.wikipedia.org/wiki/IEEE_754} {IEEE floating point}
format.
This value type is provided by the QML language.
\sa {QML Value Types}
*/
/*!
\qmlbasictype double
\ingroup qmlvaluetypes
\brief a number with a decimal point, stored in double precision.
The \c double type refers to a number with a decimal point and is stored in double precision, \l
{http://en.wikipedia.org/wiki/IEEE_754} {IEEE floating point} format.
Example:
\qml
Item {
property double number: 32155.2355
}
\endqml
This value type is provided by the QML language.
\sa {QML Value Types}
*/
/*!
\qmlbasictype string
\ingroup qmlvaluetypes
\brief a free form text string.
The \c string type refers to a free form text string in quotes, e.g. "Hello world!".
Example:
\qml
Text { text: "Hello world!" }
\endqml
Strings have a \c length attribute that holds the number of
characters in the string.
QML extends the JavaScript String type with a \l {String::arg}{arg()} function
to support value substitution.
When integrating with C++, note that any QString value
\l{qtqml-cppintegration-data.html}{passed into QML from C++} is automatically
converted into a \c string value, and vice-versa.
This value type is provided by the QML language.
\sa {QML Value Types}
*/
/*!
\qmlbasictype url
\ingroup qmlvaluetypes
\brief a resource locator.
The \c url type refers to a resource locator (like a file name, for example). It can be either
absolute, e.g. "http://qt-project.org", or relative, e.g. "pics/logo.png". A relative URL is
resolved relative to the URL of the containing component.
For example, the following assigns a valid URL to the \l {Image::source}
property, which is of type \c url:
\qml
Image { source: "pics/logo.png" }
\endqml
When integrating with C++, note that any QUrl value
\l{qtqml-cppintegration-data.html}{passed into QML from C++} is automatically
converted into a \c url value, and vice-versa.
Alternatively you may convert your \c url to a \l{https://developer.mozilla.org/en-US/docs/Web/API/URL}{URL} object
in order to access and modify its components:
\qml
var urlObject = new URL(url);
\endqml
\note In Qt 5, URLs were automatically resolved based on the current context
when assigning them to any \c url property. This made it impossible to
work with relative URLs and it created inconsistent behavior when reading
back a URL previously written to a property. Therefore, the behavior was
changed in Qt 6.
\note When referring to files stored with the \l{resources.html}{Qt Resource System}
from within QML, you should use "qrc:///" instead of ":/" as QML requires URL paths.
Relative URLs resolved from within that file will use the same protocol.
Additionally, URLs may contain encoded characters using the 'percent-encoding' scheme
specified by \l {https://datatracker.ietf.org/doc/html/rfc3986}{RFC 3986}. These characters
will be preserved within properties of type \c url, to allow QML code to
construct precise URL values.
For example, a local file containing a '#' character, which would normally be
interpreted as the beginning of the URL 'fragment' element, can be accessed by
encoding the characters of the file name:
\qml
Image { source: encodeURIComponent("/tmp/test#1.png") }
\endqml
This value type is provided by the QML language.
\sa {QML Value Types}
*/
/*!
\qmlbasictype list
\ingroup qmlvaluetypes
\brief a list of QML objects.
The \c list type refers to a list of QML objects.
A list value can be accessed in a similar way to a JavaScript array:
\list
\li Values are assigned using the \c[] square bracket syntax with comma-separated values
\li The \c length property provides the number of items in the list
\li Values in the list are accessed using the \c [index] syntax
\endlist
Values can be dynamically added to the list by using the \c push method,
as if it were a JavaScript Array
A \c list can only store QML objects, and cannot contain any
\l {QML Value Types}{value type} values. (To store value types within a
list, use the \l var type instead.)
When integrating with C++, note that any QQmlListProperty value
\l{qtqml-cppintegration-data.html}{passed into QML from C++} is automatically
converted into a \c list value, and vice-versa.
\section1 Using the list Type
For example, the \l Item type has a \l {Item::}{states} list-type property that
can be assigned to and used as follows:
\qml
import QtQuick 2.0
Item {
width: 100; height: 100
states: [
State { name: "activated" },
State { name: "deactivated" }
]
Component.onCompleted: {
console.log("Name of first state:", states[0].name)
for (var i = 0; i < states.length; i++)
console.log("state", i, states[i].name)
}
}
\endqml
The defined \l State objects will be added to the \c states list
in the order in which they are defined.
If the list only contains one object, the square brackets may be omitted:
\qml
import QtQuick 2.0
Item {
width: 100; height: 100
states: State { name: "activated" }
}
\endqml
Objects in a list can be replaced with the \c{[]} operator, just like
entries of JavaScript arrays. You can also use \c{push()} to append entries,
or you can set the \c length property of the list to truncate or extend it.
You can not automatically extend the list by assigning to an index currently
out of range, though. Furthermore, if you insert \c null values into the
list, those are converted to \c nullptr entries in the underlying
QQmlListProperty.
This value type is provided by the QML language.
\sa {QML Value Types}
*/
/*!
\qmlbasictype var
\ingroup qmlvaluetypes
\brief a generic property type.
The \c var type is a generic property type that can refer to any data type.
It is equivalent to a regular JavaScript variable.
For example, var properties can store numbers, strings, objects,
arrays and functions:
\qml
Item {
property var aNumber: 100
property var aBool: false
property var aString: "Hello world!"
property var anotherString: String("#FF008800")
property var aColor: Qt.rgba(0.2, 0.3, 0.4, 0.5)
property var aRect: Qt.rect(10, 10, 10, 10)
property var aPoint: Qt.point(10, 10)
property var aSize: Qt.size(10, 10)
property var aVector3d: Qt.vector3d(100, 100, 100)
property var anArray: [1, 2, 3, "four", "five", (function() { return "six"; })]
property var anObject: { "foo": 10, "bar": 20 }
property var aFunction: (function() { return "one"; })
}
\endqml
\section1 Change Notification Semantics
It is important to note that changes in regular properties of JavaScript
objects assigned to a var property will \b{not} trigger updates of bindings
that access them. The example below will display "The car has 4 wheels" as
the change to the wheels property will not cause the reevaluation of the
binding assigned to the "text" property:
\qml
Item {
property var car: new Object({wheels: 4})
Text {
text: "The car has " + car.wheels + " wheels";
}
Component.onCompleted: {
car.wheels = 6;
}
}
\endqml
If the onCompleted handler instead had \tt{"car = new Object({wheels: 6})"}
then the text would be updated to say "The car has 6 wheels", since the
car property itself would be changed, which causes a change notification
to be emitted.
\section1 Property Value Initialization Semantics
The QML syntax defines that curly braces on the right-hand-side of a
property value initialization assignment denote a binding assignment.
This can be confusing when initializing a \c var property, as empty curly
braces in JavaScript can denote either an expression block or an empty
object declaration. If you wish to initialize a \c var property to an
empty object value, you should wrap the curly braces in parentheses.
For example:
\qml
Item {
property var first: {} // nothing = undefined
property var second: {{}} // empty expression block = undefined
property var third: ({}) // empty object
}
\endqml
In the previous example, the \c first property is bound to an empty
expression, whose result is undefined. The \c second property is bound to
an expression which contains a single, empty expression block ("{}"), which
similarly has an undefined result. The \c third property is bound to an
expression which is evaluated as an empty object declaration, and thus the
property will be initialized with that empty object value.
Similarly, a colon in JavaScript can be either an object property value
assignment, or a code label. Thus, initializing a var property with an
object declaration can also require parentheses:
\qml
Item {
property var first: { example: 'true' } // example is interpreted as a label
property var second: ({ example: 'true' }) // example is interpreted as a property
property var third: { 'example': 'true' } // example is interpreted as a property
Component.onCompleted: {
console.log(first.example) // prints 'undefined', as "first" was assigned a string
console.log(second.example) // prints 'true'
console.log(third.example) // prints 'true'
}
}
\endqml
\sa {QML Value Types}
*/
/*
TODO Qt 5.1: see explanation in expressions.qdoc
\section1 Using Scarce Resources with the var Type
A \c var type property can also hold an image or pixmap.
A \c var which contains a QPixmap or QImage is known as a
"scarce resource" and the declarative engine will attempt to
automatically release such resources after evaluation of any JavaScript
expression which requires one to be copied has completed.
Clients may explicitly release such a scarce resource by calling the
"destroy" method on the \c var property from within JavaScript. They
may also explicitly preserve the scarce resource by calling the
"preserve" method on the \c var property from within JavaScript.
This value type is provided by the QML language.
*/
/*!
\qmlbasictype enumeration
\ingroup qmlvaluetypes
\brief a named enumeration value.
The \c enumeration type refers to a named enumeration value.
Each named value can be referred to as \c {<Type>.<value>}. For
example, the \l Text type has an \c AlignRight enumeration value:
\qml
Text { horizontalAlignment: Text.AlignRight }
\endqml
(For backwards compatibility, the enumeration value may also be
specified as a string, e.g. "AlignRight". This form is not
recommended for new code.)
When integrating with C++, note that any \c enum value
\l{qtqml-cppintegration-data.html}{passed into QML from C++} is automatically
converted into an \c enumeration value, and vice-versa.
This value type is provided by the QML language. Some enumeration values
are provided by the QtQuick import.
\section1 Using the enumeration Type in QML
The \c enumeration type is a representation of a C++ \c enum type. It is
not possible to refer to the \c enumeration type in QML itself; instead, the
\l int or \l var types can be used when referring to \c enumeration values
from QML code.
For example:
\qml
import QtQuick 2.0
Item {
// refer to Text.AlignRight using an int type
property int enumValue: textItem.horizontalAlignment
signal valueEmitted(int someValue)
Text {
id: textItem
horizontalAlignment: Text.AlignRight
}
// emit valueEmitted() signal, which expects an int, with Text.AlignRight
Component.onCompleted: valueEmitted(Text.AlignRight)
}
\endqml
\sa {QML Value Types}
\sa {qtqml-syntax-objectattributes.html#enumeration-attributes}{Enumeration Attributes}
*/

View File

@ -68,12 +68,12 @@ Types}{Qt QML Models} page has more information.
The documentation for the types below applies equally to the types of the same
name provided by the \l{Qt Quick} module, as they are in fact identical.
\section1 Basic Types
\section1 Value Types
The following \l{qtqml-typesystem-basictypes.html}{QML basic types} are
The following \l{qtqml-typesystem-valuetypes.html}{QML Value Types} are
provided:
\annotatedlist qtqmlbasictypes
\annotatedlist qtqmlvaluetypes
\section1 Object Types
@ -84,8 +84,8 @@ provided:
/*!
\qmlbasictype date
\ingroup qtqmlbasictypes
\ingroup qtquickbasictypes
\ingroup qtqmlvaluetypes
\ingroup qtquickvaluetypes
\brief a date value.
The \c date type refers to a date value, including the time of the day.
@ -116,16 +116,16 @@ or a relevant time-zone and selecting a time of day (such as noon)
that reliably exists (daylight-savings transitions skip an hour, near
one end or the other of a day).
This basic type is provided by the QML language. It can be implicitly converted
This value type is provided by the QML language. It can be implicitly converted
to a \l{QtQml::Date}{Date} object.
\sa {QtQml::Date}{QML Date object}, {QML Basic Types}
\sa {QtQml::Date}{QML Date object}, {QML Value Types}
*/
/*!
\qmlbasictype point
\ingroup qtqmlbasictypes
\ingroup qtquickbasictypes
\ingroup qtqmlvaluetypes
\ingroup qtquickvaluetypes
\brief a value with x and y attributes.
The \c point type refers to a value with \c x and \c y attributes.
@ -147,13 +147,13 @@ When integrating with C++, note that any QPoint or QPointF value
converted into a \c point value. When a \c point value is passed to C++, it
is automatically converted into a QPointF value.
\sa{QML Basic Types}
\sa{QML Value Types}
*/
/*!
\qmlbasictype size
\ingroup qtqmlbasictypes
\ingroup qtquickbasictypes
\ingroup qtqmlvaluetypes
\ingroup qtquickvaluetypes
\brief a value with width and height attributes
The \c size type refers to a value with has \c width and \c height attributes.
@ -185,13 +185,13 @@ When integrating with C++, note that any QSize or QSizeF value
converted into a \c size value, and vice-versa. When a \c size value is passed to C++, it
is automatically converted into a QSizeF value.
\sa{QML Basic Types}
\sa{QML Value Types}
*/
/*!
\qmlbasictype rect
\ingroup qtqmlbasictypes
\ingroup qtquickbasictypes
\ingroup qtqmlvaluetypes
\ingroup qtquickvaluetypes
\brief a value with x, y, width and height attributes.
The \c rect type refers to a value with \c x, \c y, \c width and \c height attributes.
@ -228,5 +228,5 @@ When integrating with C++, note that any QRect or QRectF value
converted into a \c rect value, and vice-versa. When a \c rect value is passed to C++, it
is automatically converted into a QRectF value.
\sa{QML Basic Types}
\sa{QML Value Types}
*/

View File

@ -84,7 +84,7 @@ QT += qml
The Qt QML module contains the QML framework and important QML types used in
applications. The constructs of QML are described in the \l{The QML Reference}.
In addition to the \l{QML Basic Types}, the module comes with
In addition to the \l{QML Value Types}, the module comes with
the following QML object types:
\list
\li \l Component

View File

@ -143,7 +143,7 @@ creating objects of specific data types are also available for clients to use:
\li \c matrix4x4 - use \l{Qt::matrix4x4()}{Qt.matrix4x4()}
\endlist
There are also string based constructors for these types. See \l{qtqml-typesystem-basictypes.html}{QML Basic Types} for more information.
There are also string based constructors for these types. See \l{qtqml-typesystem-valuetypes.html}{QML Value Types} for more information.
\section1 Date/Time Formatters
@ -435,7 +435,7 @@ QVariant QtObject::hsva(double h, double s, double v, double a) const
Returns \c true if both \a lhs and \a rhs yield equal color values. Both
arguments may be either color values or string values. If a string value
is supplied it must be convertible to a color, as described for the
\l{colorbasictypedocs}{color} basic type.
\l{colorvaluetypedocs}{color} value type.
*/
bool QtObject::colorEqual(const QVariant &lhs, const QVariant &rhs) const
{
@ -503,7 +503,7 @@ QSizeF QtObject::size(double w, double h) const
Returns a font with the properties specified in the \a fontSpecifier object
or the nearest matching font. The \a fontSpecifier object should contain
key-value pairs where valid keys are the \l{fontbasictypedocs}{font} type's
key-value pairs where valid keys are the \l{fontvaluetypedocs}{font} type's
subproperty names, and the values are valid values for each subproperty.
Invalid keys will be ignored.
*/

View File

@ -513,7 +513,7 @@ void QQmlBind::setObject(QObject *obj)
The property to be updated.
This can be a group property if the expression results in accessing a
property of a \l {QML Basic Types}{value type}. For example:
property of a \l {QML Value Types}{value type}. For example:
\qml
Item {

View File

@ -59,15 +59,15 @@ information about the concepts which are central to \c QtQuick.
\li \l{Qt Quick Test QML Types}{Tests} - types for testing QML applications.
\endlist
\target basic-types
\section1 Basic Types
\target value-types
\section1 Value Types
There are a number of basic types that are
\l{qtqml-typesystem-basictypes.html#basic-types-provided-by-the-qml-language}
There are a number of value types that are
\l{qtqml-typesystem-valuetypes.html#value-types-provided-by-the-qml-language}
{supported by default in the QML language}.
In addition, the \c QtQuick import provides the following basic types:
\annotatedlist qtquickbasictypes
In addition, the \c QtQuick import provides the following value types:
\annotatedlist qtquickvaluetypes
\section1 Object Types
@ -81,9 +81,9 @@ available when you import \c QtQuick.
/*!
\qmlbasictype color
\ingroup qtquickbasictypes
\ingroup qtquickvaluetypes
\brief an ARGB color value.
\target colorbasictypedocs
\target colorvaluetypedocs
The \c color type refers to an ARGB color value. It can be specified in a number of ways:
@ -127,7 +127,7 @@ available when you import \c QtQuick.
\l{qtqml-cppintegration-data.html}{passed into QML from C++} is automatically
converted into a \c color value, and vice-versa.
This basic type is provided by the QtQuick import.
This value type is provided by the QtQuick import.
\section1 SVG Color Reference
@ -136,14 +136,14 @@ available when you import \c QtQuick.
\include svg-colors.qdocinc
\sa {QML Basic Types}
\sa {QML Value Types}
*/
/*!
\qmlbasictype font
\ingroup qtquickbasictypes
\ingroup qtquickvaluetypes
\brief a font value with the properties of QFont.
\target fontbasictypedocs
\target fontvaluetypedocs
The \c font type refers to a font value with the properties of QFont.
@ -184,7 +184,7 @@ available when you import \c QtQuick.
\l{qtqml-cppintegration-data.html}{passed into QML from C++} is automatically
converted into a \c font value, and vice-versa.
This basic type is provided by the QtQuick import.
This value type is provided by the QtQuick import.
Font weighting is classified on a scale from 0 to 99, where a weight of 0 is ultralight,
and 99 is extremely black. The following values are supported:
@ -252,12 +252,12 @@ available when you import \c QtQuick.
vertical directions.
\endlist
\sa {QML Basic Types}
\sa {QML Value Types}
*/
/*!
\qmlbasictype vector2d
\ingroup qtquickbasictypes
\ingroup qtquickvaluetypes
\brief A vector2d type has x and y attributes.
@ -378,14 +378,14 @@ console.log(c + " " + d); // false true
\endcode
\endtable
This basic type is provided by the QtQuick import.
This value type is provided by the QtQuick import.
\sa {QML Basic Types}
\sa {QML Value Types}
*/
/*!
\qmlbasictype vector3d
\ingroup qtquickbasictypes
\ingroup qtquickvaluetypes
\brief a value with x, y, and z attributes.
The \c vector3d type refers to a value with \c x, \c y, and \c z attributes.
@ -549,14 +549,14 @@ console.log(c + " " + d); // false true
\endcode
\endtable
This basic type is provided by the QtQuick import.
This value type is provided by the QtQuick import.
\sa {QML Basic Types}
\sa {QML Value Types}
*/
/*!
\qmlbasictype vector4d
\ingroup qtquickbasictypes
\ingroup qtquickvaluetypes
\brief A vector4d type has x, y, z and w attributes.
@ -690,14 +690,14 @@ console.log(c + " " + d); // false true
\endcode
\endtable
This basic type is provided by the QtQuick import.
This value type is provided by the QtQuick import.
\sa {QML Basic Types}
\sa {QML Value Types}
*/
/*!
\qmlbasictype quaternion
\ingroup qtquickbasictypes
\ingroup qtquickvaluetypes
\brief A quaternion type has scalar, x, y, and z attributes.
@ -850,14 +850,14 @@ console.log(c + " " + d); // false true
\endcode
\endtable
This basic type is provided by the QtQuick import.
This value type is provided by the QtQuick import.
\sa {QML Basic Types}
\sa {QML Value Types}
*/
/*!
\qmlbasictype matrix4x4
\ingroup qtquickbasictypes
\ingroup qtquickvaluetypes
\brief A matrix4x4 type is a 4-row and 4-column matrix
@ -1098,7 +1098,7 @@ console.log(c + " " + d); // false true
\endcode
\endtable
This basic type is provided by the QtQuick import.
This value type is provided by the QtQuick import.
\sa {QML Basic Types}
\sa {QML Value Types}
*/

View File

@ -29,12 +29,12 @@
\page qml-tutorial.html
\title QML Tutorial
\brief An introduction to the basic concepts and features of QML.
\nextpage QML Tutorial 1 - Basic Types
\nextpage QML Tutorial 1 - Value Types
This tutorial gives an introduction to QML, the language for Qt Quick UIs. It doesn't cover everything;
the emphasis is on teaching the key principles, and features are introduced as needed.
Through the different steps of this tutorial we will learn about QML basic types, we will create our own QML component
Through the different steps of this tutorial we will learn about QML value types, we will create our own QML component
with properties and signals, and we will create a simple animation with the help of states and transitions.
Chapter one starts with a minimal "Hello world" program and the following chapters introduce new concepts.
@ -44,7 +44,7 @@ The tutorial's source code is located in the \c{examples/quick/tutorials/hellowo
Tutorial chapters:
\list 1
\li \l {QML Tutorial 1 - Basic Types}{Basic Types}
\li \l {QML Tutorial 1 - Value Types}{Value Types}
\li \l {QML Tutorial 2 - QML Components}{QML Components}
\li \l {QML Tutorial 3 - States and Transitions}{States and Transitions}
\endlist
@ -53,7 +53,7 @@ Tutorial chapters:
/*!
\page qml-tutorial1.html
\title QML Tutorial 1 - Basic Types
\title QML Tutorial 1 - Value Types
\previouspage QML Tutorial
\nextpage QML Tutorial 2 - QML Components
@ -113,7 +113,7 @@ qml tutorials/helloworld/tutorial1.qml
/*!
\page qml-tutorial2.html
\title QML Tutorial 2 - QML Components
\previouspage QML Tutorial 1 - Basic Types
\previouspage QML Tutorial 1 - Value Types
\nextpage QML Tutorial 3 - States and Transitions
This chapter adds a color picker to change the color of the text.

View File

@ -18,22 +18,22 @@
\row
\li \c Accent
\li Specifies the default \l {material-accent-attached-prop}{Material accent color}.
The value can be any \l {colorbasictypedocs}{color}, but it is recommended to use
The value can be any \l {colorvaluetypedocs}{color}, but it is recommended to use
one of the \l {pre-defined Material colors}, for example \c "Teal".
\row
\li \c Primary
\li Specifies the default \l {material-primary-attached-prop}{Material primary color}.
The value can be any \l {colorbasictypedocs}{color}, but it is recommended to use
The value can be any \l {colorvaluetypedocs}{color}, but it is recommended to use
one of the \l {pre-defined Material colors}, for example \c "BlueGrey".
\row
\li \c Foreground
\li Specifies the default \l {material-foreground-attached-prop}{Material foreground color}.
The value can be any \l {colorbasictypedocs}{color}, or one of the \l {pre-defined Material colors},
The value can be any \l {colorvaluetypedocs}{color}, or one of the \l {pre-defined Material colors},
for example \c "Brown".
\row
\li \c Background
\li Specifies the default \l {material-background-attached-prop}{Material background color}.
The value can be any \l {colorbasictypedocs}{color}, or one of the \l {pre-defined Material colors},
The value can be any \l {colorvaluetypedocs}{color}, or one of the \l {pre-defined Material colors},
for example \c "Grey".
\endtable
//! [conf]
@ -58,22 +58,22 @@
\row
\li \c QT_QUICK_CONTROLS_MATERIAL_ACCENT
\li Specifies the default \l {material-accent-attached-prop}{Material accent color}.
The value can be any \l {colorbasictypedocs}{color}, but it is recommended to use
The value can be any \l {colorvaluetypedocs}{color}, but it is recommended to use
one of the \l {pre-defined Material colors}, for example \c "Teal".
\row
\li \c QT_QUICK_CONTROLS_MATERIAL_PRIMARY
\li Specifies the default \l {material-primary-attached-prop}{Material primary color}.
The value can be any \l {colorbasictypedocs}{color}, but it is recommended to use
The value can be any \l {colorvaluetypedocs}{color}, but it is recommended to use
one of the \l {pre-defined Material colors}, for example \c "BlueGrey".
\row
\li \c QT_QUICK_CONTROLS_MATERIAL_FOREGROUND
\li Specifies the default \l {material-foreground-attached-prop}{Material foreground color}.
The value can be any \l {colorbasictypedocs}{color}, or one of the \l {pre-defined Material colors},
The value can be any \l {colorvaluetypedocs}{color}, or one of the \l {pre-defined Material colors},
for example \c "Brown".
\row
\li \c QT_QUICK_CONTROLS_MATERIAL_BACKGROUND
\li Specifies the default \l {material-background-attached-prop}{Material background color}.
The value can be any \l {colorbasictypedocs}{color}, or one of the \l {pre-defined Material colors},
The value can be any \l {colorvaluetypedocs}{color}, or one of the \l {pre-defined Material colors},
for example \c "Grey".
\endtable
//! [env]

View File

@ -10,17 +10,17 @@
\row
\li \c Accent
\li Specifies the default \l {universal-accent-attached-prop}{Universal accent color}.
The value can be any \l {colorbasictypedocs}{color}, but it is recommended to use
The value can be any \l {colorvaluetypedocs}{color}, but it is recommended to use
one of the \l {pre-defined Universal colors}, for example \c "Violet".
\row
\li \c Foreground
\li Specifies the default \l {universal-foreground-attached-prop}{Universal foreground color}.
The value can be any \l {colorbasictypedocs}{color}, or one of the \l {pre-defined Universal colors},
The value can be any \l {colorvaluetypedocs}{color}, or one of the \l {pre-defined Universal colors},
for example \c "Brown".
\row
\li \c Background
\li Specifies the default \l {universal-background-attached-prop}{Universal background color}.
The value can be any \l {colorbasictypedocs}{color}, or one of the \l {pre-defined Universal colors},
The value can be any \l {colorvaluetypedocs}{color}, or one of the \l {pre-defined Universal colors},
for example \c "Steel".
\endtable
//! [conf]
@ -37,17 +37,17 @@
\row
\li \c QT_QUICK_CONTROLS_UNIVERSAL_ACCENT
\li Specifies the default \l {universal-accent-attached-prop}{Universal accent color}.
The value can be any \l {colorbasictypedocs}{color}, but it is recommended to use
The value can be any \l {colorvaluetypedocs}{color}, but it is recommended to use
one of the \l {pre-defined Universal colors}, for example \c "Violet".
\row
\li \c QT_QUICK_CONTROLS_UNIVERSAL_FOREGROUND
\li Specifies the default \l {universal-foreground-attached-prop}{Universal foreground color}.
The value can be any \l {colorbasictypedocs}{color}, or one of the \l {pre-defined Universal colors},
The value can be any \l {colorvaluetypedocs}{color}, or one of the \l {pre-defined Universal colors},
for example \c "Brown".
\row
\li \c QT_QUICK_CONTROLS_UNIVERSAL_BACKGROUND
\li Specifies the default \l {universal-background-attached-prop}{Universal background color}.
The value can be any \l {colorbasictypedocs}{color}, or one of the \l {pre-defined Universal colors},
The value can be any \l {colorvaluetypedocs}{color}, or one of the \l {pre-defined Universal colors},
for example \c "Steel".
\endtable
//! [env]

View File

@ -151,7 +151,7 @@
\section2 Pre-defined Material Colors
Even though primary and accent can be any \l {colorbasictypedocs}{color}, it
Even though primary and accent can be any \l {colorvaluetypedocs}{color}, it
is recommended to use one of the pre-defined colors that have been designed
to work well with the rest of the Material style palette:
@ -269,7 +269,7 @@
\image qtquickcontrols2-material-accent.png
\endtable
\note Even though the accent can be any \l {colorbasictypedocs}{color}, it is
\note Even though the accent can be any \l {colorvaluetypedocs}{color}, it is
recommended to use one of the \l {pre-defined Material colors} that have been
designed to work well with the rest of the Material style palette.
@ -346,7 +346,7 @@
The default value is \c Material.Indigo.
\note Even though the primary can be any \l {colorbasictypedocs}{color}, it is
\note Even though the primary can be any \l {colorvaluetypedocs}{color}, it is
recommended to use one of the \l {pre-defined Material colors} that have been
designed to work well with the rest of the Material style palette.

View File

@ -194,7 +194,7 @@
\image qtquickcontrols2-universal-accent.png
\endtable
\note Even though the accent can be any \l {colorbasictypedocs}{color}, it is
\note Even though the accent can be any \l {colorvaluetypedocs}{color}, it is
recommended to use one of the \l {pre-defined Universal colors} that have been
designed to work well with the rest of the Universal style palette.

View File

@ -971,7 +971,7 @@ void QQuickControl::itemChange(QQuickItem::ItemChange change, const QQuickItem::
\endcode
For the full list of available font properties, see the
\l [QtQuick]{font}{font QML Basic Type} documentation.
\l [QtQuick]{font}{font QML Value Type} documentation.
*/
QFont QQuickControl::font() const
{

View File

@ -78,7 +78,7 @@ public:
private slots:
void initTestCase() override;
void arrayIncludesValueType();
void assignBasicTypes();
void assignValueTypes();
void assignDate_data();
void assignDate();
void assignFunctionThroughAliasToVarProperty();
@ -495,11 +495,11 @@ void tst_qqmlecmascript::arrayIncludesValueType()
QVERIFY(success.toBool());
}
void tst_qqmlecmascript::assignBasicTypes()
void tst_qqmlecmascript::assignValueTypes()
{
QQmlEngine engine;
{
QQmlComponent component(&engine, testFileUrl("assignBasicTypes.qml"));
QQmlComponent component(&engine, testFileUrl("assignValueTypes.qml"));
QScopedPointer<QObject> obj(component.create());
QVERIFY2(obj, qPrintable(component.errorString()));
MyTypeObject *object = qobject_cast<MyTypeObject *>(obj.data());
@ -529,7 +529,7 @@ void tst_qqmlecmascript::assignBasicTypes()
QCOMPARE(object->urlProperty(), QUrl("main.qml"));
}
{
QQmlComponent component(&engine, testFileUrl("assignBasicTypes.2.qml"));
QQmlComponent component(&engine, testFileUrl("assignValueTypes.2.qml"));
QScopedPointer<QObject> obj(component.create());
QVERIFY2(obj, qPrintable(component.errorString()));
MyTypeObject *object = qobject_cast<MyTypeObject *>(obj.data());

View File

@ -108,7 +108,7 @@ private slots:
void assignObjectToVariant();
void assignLiteralSignalProperty();
void assignQmlComponent();
void assignBasicTypes();
void assignValueTypes();
void assignTypeExtremes();
void assignCompositeToType();
void assignLiteralToVar();
@ -837,10 +837,10 @@ void tst_qqmllanguage::assignQmlComponent()
QCOMPARE(child->property("y"), QVariant(11));
}
// Test literal assignment to all the basic types
void tst_qqmllanguage::assignBasicTypes()
// Test literal assignment to all the value types
void tst_qqmllanguage::assignValueTypes()
{
QQmlComponent component(&engine, testFileUrl("assignBasicTypes.qml"));
QQmlComponent component(&engine, testFileUrl("assignValueTypes.qml"));
VERIFY_ERRORS(0);
QScopedPointer<MyTypeObject> object(qobject_cast<MyTypeObject *>(component.create()));
QVERIFY(object != nullptr);
@ -5244,7 +5244,7 @@ void tst_qqmllanguage::instanceof_data()
// operands are indeed an instanceof each other, or a string for the
// expected error message.
// assert that basic types don't convert to QObject
// assert that value types don't convert to QObject
QTest::newRow("1 instanceof QtObject")
<< testFileUrl("instanceof_qtqml.qml")
<< QVariant(false);