summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/qml')
-rw-r--r--src/declarative/qml/qdeclarativecomponent.cpp14
-rw-r--r--src/declarative/qml/qdeclarativecontext.cpp2
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp11
-rw-r--r--src/declarative/qml/qdeclarativevaluetype.cpp12
-rw-r--r--src/declarative/qml/qdeclarativevaluetype_p.h2
-rw-r--r--src/declarative/qml/qdeclarativeworkerscript.cpp5
6 files changed, 33 insertions, 13 deletions
diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp
index 9847079f7a..55ee783f3b 100644
--- a/src/declarative/qml/qdeclarativecomponent.cpp
+++ b/src/declarative/qml/qdeclarativecomponent.cpp
@@ -78,7 +78,7 @@ class QByteArray;
\since 4.7
\brief The Component element encapsulates a QML component description.
- Components are reusable, encapsulated Qml element with a well-defined interface.
+ Components are reusable, encapsulated QML elements with well-defined interfaces.
They are often defined in \l {qdeclarativedocuments.html}{Component Files}.
The \e Component element allows defining components within a QML file.
@@ -547,16 +547,18 @@ QDeclarativeComponent::QDeclarativeComponent(QDeclarativeComponentPrivate &dd, Q
/*!
\qmlmethod object Component::createObject(parent)
- Returns an object instance from this component, or null if object creation fails.
+
+ Creates and returns an object instance of this component that will have the given
+ \a parent. Returns null if object creation fails.
The object will be created in the same context as the one in which the component
was created. This function will always return null when called on components
which were not created in QML.
- Note that if the returned object is to be displayed, its \c parent must be set to
- an existing item in a scene, or else the object will not be visible. The parent
- argument is required to help you avoid this, you must explicitly pass in null if
- you wish to create an object without setting a parent.
+ If you wish to create an object without setting a parent, specify \c null for
+ the \a parent value. Note that if the returned object is to be displayed, you
+ must provide a valid \a parent value or set the returned object's \l{Item::parent}{parent}
+ property, or else the object will not be visible.
*/
/*!
diff --git a/src/declarative/qml/qdeclarativecontext.cpp b/src/declarative/qml/qdeclarativecontext.cpp
index 6a13f15a24..2221d78fb1 100644
--- a/src/declarative/qml/qdeclarativecontext.cpp
+++ b/src/declarative/qml/qdeclarativecontext.cpp
@@ -116,7 +116,7 @@ QDeclarativeContextPrivate::QDeclarativeContextPrivate()
All properties added explicitly by QDeclarativeContext::setContextProperty() take
precedence over the context object's properties.
- Contexts form a hierarchy. The root of this heirarchy is the QDeclarativeEngine's
+ Contexts form a hierarchy. The root of this hierarchy is the QDeclarativeEngine's
\l {QDeclarativeEngine::rootContext()}{root context}. A component instance can
access the data in its own context, as well as all its ancestor contexts. Data
can be made available to all instances by modifying the
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index 39b0802383..0715624e44 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -191,7 +191,7 @@ when the property has one of the following types:
\o \c vector3d - use \l{Qt::vector3d()}{Qt.vector3d()}
\endlist
-There are also string based constructors for these types, see \l{qdeclarativebasictypes.html}{QML Basic Types}.
+There are also string based constructors for these types. See \l{qdeclarativebasictypes.html}{QML Basic Types} for more information.
\section1 Date/Time Formatters
@@ -1054,8 +1054,9 @@ or \c null if there was an error in creating the component.
Call \l {Component::createObject()}{Component.createObject()} on the returned
component to create an object instance of the component.
-Here is an example. Remember that QML files that might be loaded
-over the network cannot be expected to be ready immediately.
+Here is an example. Notice it checks whether the component \l{Component::status}{status} is
+\c Component.Ready before calling \l {Component::createObject()}{createObject()}
+in case the QML file is loaded over a network and thus is not ready immediately.
\snippet doc/src/snippets/declarative/componentCreation.js 0
\codeline
@@ -1095,12 +1096,12 @@ QScriptValue QDeclarativeEnginePrivate::createComponent(QScriptContext *ctxt, QS
/*!
\qmlmethod object Qt::createQmlObject(string qml, object parent, string filepath)
-Returns a new object created from the given \a string of QML with the specified \a parent,
+Returns a new object created from the given \a string of QML which will have the specified \a parent,
or \c null if there was an error in creating the object.
If \a filepath is specified, it will be used for error reporting for the created object.
-Example (where \c targetItem is the id of an existing QML item):
+Example (where \c parentItem is the id of an existing QML item):
\snippet doc/src/snippets/declarative/createQmlObject.qml 0
diff --git a/src/declarative/qml/qdeclarativevaluetype.cpp b/src/declarative/qml/qdeclarativevaluetype.cpp
index dbc25bb8c2..c17ec950cc 100644
--- a/src/declarative/qml/qdeclarativevaluetype.cpp
+++ b/src/declarative/qml/qdeclarativevaluetype.cpp
@@ -47,6 +47,8 @@
QT_BEGIN_NAMESPACE
+Q_DECL_IMPORT extern int qt_defaultDpi();
+
template<typename T>
int qmlRegisterValueTypeEnums(const char *qmlName)
{
@@ -909,6 +911,11 @@ void QDeclarativeFontValueType::setStrikeout(bool b)
qreal QDeclarativeFontValueType::pointSize() const
{
+ if (font.pointSizeF() == -1) {
+ if (dpi.isNull)
+ dpi = qt_defaultDpi();
+ return font.pixelSize() * qreal(72.) / qreal(dpi);
+ }
return font.pointSizeF();
}
@@ -929,6 +936,11 @@ void QDeclarativeFontValueType::setPointSize(qreal size)
int QDeclarativeFontValueType::pixelSize() const
{
+ if (font.pixelSize() == -1) {
+ if (dpi.isNull)
+ dpi = qt_defaultDpi();
+ return (font.pointSizeF() * dpi) / qreal(72.);
+ }
return font.pixelSize();
}
diff --git a/src/declarative/qml/qdeclarativevaluetype_p.h b/src/declarative/qml/qdeclarativevaluetype_p.h
index 3eaecc1c37..4b1bbd621b 100644
--- a/src/declarative/qml/qdeclarativevaluetype_p.h
+++ b/src/declarative/qml/qdeclarativevaluetype_p.h
@@ -55,6 +55,7 @@
#include "qdeclarativeproperty.h"
#include "private/qdeclarativeproperty_p.h"
+#include "private/qdeclarativenullablevalue_p_p.h"
#include <QtCore/qobject.h>
#include <QtCore/qrect.h>
@@ -547,6 +548,7 @@ private:
QFont font;
bool pixelSizeSet;
bool pointSizeSet;
+ mutable QDeclarativeNullableValue<int> dpi;
};
QT_END_NAMESPACE
diff --git a/src/declarative/qml/qdeclarativeworkerscript.cpp b/src/declarative/qml/qdeclarativeworkerscript.cpp
index e0ee84f84b..aec84a64ac 100644
--- a/src/declarative/qml/qdeclarativeworkerscript.cpp
+++ b/src/declarative/qml/qdeclarativeworkerscript.cpp
@@ -523,7 +523,7 @@ void QDeclarativeWorkerScriptEngine::run()
Messages can be passed between the new thread and the parent thread
using \l sendMessage() and the \l {WorkerScript::onMessage}{onMessage()} handler.
- Here is an example:
+ An example:
\snippet doc/src/snippets/declarative/workerscript.qml 0
@@ -541,6 +541,9 @@ void QDeclarativeWorkerScriptEngine::run()
called, triggering the \tt WorkerScript.onMessage() handler in
\tt script.js. This in turn sends a reply message that is then received
by the \tt onMessage() handler of \tt myWorker.
+
+ \sa {declarative/threading/workerscript}{WorkerScript example},
+ {declarative/threading/threadedlistmodel}{Threaded ListModel example}
*/
QDeclarativeWorkerScript::QDeclarativeWorkerScript(QObject *parent)
: QObject(parent), m_engine(0), m_scriptId(-1), m_componentComplete(true)