diff options
author | Morten Johan Sørvig <morten.sorvig@nokia.com> | 2010-05-12 07:42:52 (GMT) |
---|---|---|
committer | Morten Johan Sørvig <morten.sorvig@nokia.com> | 2010-05-12 07:42:52 (GMT) |
commit | 731a2f16578ead0f75f2752e757b138376b2f872 (patch) | |
tree | 2b6f9746771992f97cbdb5cf5af8f35ac6928b26 /doc/src/declarative/globalobject.qdoc | |
parent | 37475bcc4aef3f08c5917f22c7f0f427e4214b91 (diff) | |
parent | b4c589868f278aa9a58ab9afa727dbf0a9442e22 (diff) | |
download | Qt-731a2f16578ead0f75f2752e757b138376b2f872.zip Qt-731a2f16578ead0f75f2752e757b138376b2f872.tar.gz Qt-731a2f16578ead0f75f2752e757b138376b2f872.tar.bz2 |
Merge remote branch 'mainline/4.7' into 4.7
Conflicts:
src/declarative/qml/qdeclarativeengine.cpp
tools/qdoc3/htmlgenerator.cpp
Diffstat (limited to 'doc/src/declarative/globalobject.qdoc')
-rw-r--r-- | doc/src/declarative/globalobject.qdoc | 170 |
1 files changed, 85 insertions, 85 deletions
diff --git a/doc/src/declarative/globalobject.qdoc b/doc/src/declarative/globalobject.qdoc index 57eaae7..bc9830a 100644 --- a/doc/src/declarative/globalobject.qdoc +++ b/doc/src/declarative/globalobject.qdoc @@ -166,10 +166,33 @@ If no format is specified the locale's short format is used. Alternatively, you \section2 Functions The Qt object also contains the following miscellaneous functions which expose Qt functionality for use in QML. -\section3 Qt.lighter(color baseColor) -This function returns a color 50% lighter than \c baseColor. See QColor::lighter() for further details. -\section3 Qt.darker(color baseColor) -This function returns a color 50% darker than \c baseColor. See QColor::darker() for further details. +\section3 Qt.lighter(color baseColor, real factor) +This function returns a color lighter than \c baseColor by the \c factor provided. + +If the factor is greater than 1.0, this functions returns a lighter color. +Setting factor to 1.5 returns a color that is 50% brighter. If the factor is less than 1.0, +the return color is darker, but we recommend using the Qt.darker() function for this purpose. +If the factor is 0 or negative, the return value is unspecified. + +The function converts the current RGB color to HSV, multiplies the value (V) component +by factor and converts the color back to RGB. + +If \c factor is not supplied, returns a color 50% lighter than \c baseColor (factor 1.5). + +\section3 Qt.darker(color baseColor, real factor) +This function returns a color darker than \c baseColor by the \c factor provided. + +If the factor is greater than 1.0, this function returns a darker color. +Setting factor to 3.0 returns a color that has one-third the brightness. +If the factor is less than 1.0, the return color is lighter, but we recommend using +the Qt.lighter() function for this purpose. If the factor is 0 or negative, the return +value is unspecified. + +The function converts the current RGB color to HSV, divides the value (V) component +by factor and converts the color back to RGB. + +If \c factor is not supplied, returns a color 50% darker than \c baseColor (factor 2.0). + \section3 Qt.tint(color baseColor, color tintColor) This function allows tinting one color with another. @@ -203,6 +226,9 @@ This function causes the QML engine to emit the quit signal, which in This function returns \c url resolved relative to the URL of the caller. +\section3 Qt.fontFamilies() +This function returns a list of the font families available to the application. + \section3 Qt.isQtObject(object) Returns true if \c object is a valid reference to a Qt or QML object, otherwise false. @@ -211,87 +237,61 @@ The following functions on the global object allow you to dynamically create QML items from files or strings. See \l{Dynamic Object Management} for an overview of their use. -\section2 createComponent(url file) - This function takes the URL of a QML file as its only argument. It returns - a component object which can be used to create and load that QML file. - - Example QML script is below. Remember that QML files that might be loaded - over the network cannot be expected to be ready immediately. - \code - var component; - var sprite; - function finishCreation(){ - if(component.isReady()){ - sprite = component.createObject(); - if(sprite == null){ - // Error Handling - }else{ - sprite.parent = page; - sprite.x = 200; - //... - } - }else if(component.isError()){ - // Error Handling - } - } - - component = createComponent("Sprite.qml"); - if(component.isReady()){ - finishCreation(); - }else{ - component.statusChanged.connect(finishCreation); - } - \endcode - - If you are certain the files will be local, you could simplify to - - \code - component = createComponent("Sprite.qml"); - sprite = component.createObject(); - if(sprite == null){ - // Error Handling - console.log(component.errorsString()); - }else{ - sprite.parent = page; - sprite.x = 200; - //... - } - \endcode - - The methods and properties of the Component element are defined in its own - page, but when using it dynamically only two methods are usually used. - Component.createObject() returns the created object or null if there is an error. - If there is an error, Component.errorsString() describes what the error was. - - If you want to just create an arbitrary string of QML, instead of - loading a QML file, consider the createQmlObject() function. - -\section2 createQmlObject(string qml, object parent, string filepath) - Creates a new object from the specified string of QML. It requires a - second argument, which is the id of an existing QML object to use as - the new object's parent. If a third argument is provided, this is used - for error reporting as the filepath that the QML came from. - - Example (where targetItem is the id of an existing QML item): - \code - newObject = createQmlObject('import Qt 4.7; Rectangle {color: "red"; width: 20; height: 20}', - targetItem, "dynamicSnippet1"); - \endcode - - This function is intended for use inside QML only. It is intended to behave - similarly to eval, but for creating QML elements. - - Returns the created object, or null if there is an error. In the case of an - error, a QtScript Error object is thrown. This object has the additional property, - qmlErrors, which is an array of all the errors encountered when trying to execute the - QML. Each object in the array has the members: lineNumber, columnNumber, fileName and message. - - Note that this function returns immediately, and therefore may not work if - the QML loads new components. If you are trying to load a new component, - for example from a QML file, consider the createComponent() function - instead. 'New components' refers to external QML files that have not yet - been loaded, and so it is safe to use createQmlObject to load built-in - components. + +\section2 Qt.createComponent(url file) + +This function takes the URL of a QML file as its only argument. It returns +a component object which can be used to create and load that QML file. + +Here is an example. Remember that QML files that might be loaded +over the network cannot be expected to be ready immediately. + +\snippet doc/src/snippets/declarative/componentCreation.js 0 +\codeline +\snippet doc/src/snippets/declarative/componentCreation.js 1 + +If you are certain the files will be local, you could simplify to: + +\snippet doc/src/snippets/declarative/componentCreation.js 2 + +The methods and properties of the Component element are defined in its own +page, but when using it dynamically only two methods are usually used. +\c Component.createObject() returns the created object or \c null if there is an error. +If there is an error, \l {Component::errorsString()}{Component.errorsString()} describes +the error that occurred. Note that createObject() takes exactly one argument, which is set +to the parent of the created object. Graphical objects without a parent will not appear +on the scene, but if you do not wish to parent the item at this point you can safely pass +in null. + +If you want to just create an arbitrary string of QML, instead of +loading a QML file, consider the \l{Qt.createQmlObject(string qml, object parent, string filepath)}{Qt.createQmlObject()} function. + + +\section2 Qt.createQmlObject(string qml, object parent, string filepath) + +Creates a new object from the specified string of QML. It requires a +second argument, which is the id of an existing QML object to use as +the new object's parent. If a third argument is provided, this is used +for error reporting as the filepath that the QML came from. + +Example (where \c targetItem is the id of an existing QML item): + +\snippet doc/src/snippets/declarative/createQmlObject.qml 0 + +This function is intended for use inside QML only. It is intended to behave +similarly to eval, but for creating QML elements. + +Returns the created object, \c or null if there is an error. In the case of an +error, a QtScript Error object is thrown. This object has the additional property, +qmlErrors, which is an array of all the errors encountered when trying to execute the +QML. Each object in the array has the members \c lineNumber, \c columnNumber, \c fileName and \c message. + +Note that this function returns immediately, and therefore may not work if +the QML loads new components. If you are trying to load a new component, +for example from a QML file, consider the \l{Qt.createComponent(url file)}{Qt.createComponent()} function +instead. 'New components' refers to external QML files that have not yet +been loaded, and so it is safe to use \c Qt.createQmlObject() to load built-in +components. \section1 XMLHttpRequest |