diff options
-rw-r--r-- | src/declarative/extra/qmlnumberformatter.cpp | 4 | ||||
-rw-r--r-- | src/declarative/extra/qmlxmllistmodel.cpp | 13 | ||||
-rw-r--r-- | src/declarative/util/qbindablemap.cpp | 4 | ||||
-rw-r--r-- | src/declarative/util/qmlbind.cpp | 4 | ||||
-rw-r--r-- | src/declarative/util/qmldatetimeformatter.cpp | 28 | ||||
-rw-r--r-- | src/declarative/util/qmlscript.cpp | 6 |
6 files changed, 31 insertions, 28 deletions
diff --git a/src/declarative/extra/qmlnumberformatter.cpp b/src/declarative/extra/qmlnumberformatter.cpp index 8772305..1549525 100644 --- a/src/declarative/extra/qmlnumberformatter.cpp +++ b/src/declarative/extra/qmlnumberformatter.cpp @@ -72,8 +72,8 @@ public: In the following example, the text element will display the text "1,234.57". \code - <NumberFormatter id="Formatter" number="1234.5678" format="##,##0.##"/> - <Text text="{Formatter.text}"/> + NumberFormatter { id: Formatter; number: 1234.5678; format: "##,##0.##" } + Text { text: Formatter.text } \endcode */ diff --git a/src/declarative/extra/qmlxmllistmodel.cpp b/src/declarative/extra/qmlxmllistmodel.cpp index 91c8139..6b8f285 100644 --- a/src/declarative/extra/qmlxmllistmodel.cpp +++ b/src/declarative/extra/qmlxmllistmodel.cpp @@ -74,11 +74,14 @@ QML_DEFINE_TYPE(QmlXmlListModel, XmlListModel); The following is an example of a model containing news from a Yahoo RSS feed: \qml - <XmlListModel id="FeedModel" src="http://rss.news.yahoo.com/rss/oceania" query="doc($src)/rss/channel/item"> - <Role name="title" query="title/string()"/> - <Role name="link" query="link/string()"/> - <Role name="description" query="description/string()" isCData="true"/> - </XmlListModel> + XmlListModel { + id: FeedModel + source: "http://rss.news.yahoo.com/rss/oceania" + query: "doc($src)/rss/channel/item" + Role { name: "title"; query: "title/string()" } + Role { name: "link"; query: "link/string()" } + Role { name: "description"; query: "description/string()"; isCData: true } + } \endqml \note The model is currently static, so the above is really just a snapshot of an RSS feed. */ diff --git a/src/declarative/util/qbindablemap.cpp b/src/declarative/util/qbindablemap.cpp index 341dd31..c8c8ced 100644 --- a/src/declarative/util/qbindablemap.cpp +++ b/src/declarative/util/qbindablemap.cpp @@ -87,8 +87,8 @@ private: Then, in QML: \code - <Text text="{owner.name}"/> - <Text text="{owner.phone}"/> + Text { text: owner.name } + Text { text: owner.phone } \endcode The binding is dynamic - whenever a key's value is updated, anything bound to that diff --git a/src/declarative/util/qmlbind.cpp b/src/declarative/util/qmlbind.cpp index 3b51c6a..59bfd75 100644 --- a/src/declarative/util/qmlbind.cpp +++ b/src/declarative/util/qmlbind.cpp @@ -77,8 +77,8 @@ QML_DEFINE_TYPE(QmlBind,Bind); property into QML. You could use Bind to update the enteredText property like this. \code - <TextEdit id="myTextField" text="Please type here..." /> - <Bind target="{app}" property="enteredText" value="{myTextField.text}" /> + TextEdit { id: myTextField; text: "Please type here..." } + Bind { target: app; property: "enteredText"; value: myTextField.text /> \endcode Whenever the text in the TextEdit is updated, the C++ property will be updated also. diff --git a/src/declarative/util/qmldatetimeformatter.cpp b/src/declarative/util/qmldatetimeformatter.cpp index efddd81..94b87ee 100644 --- a/src/declarative/util/qmldatetimeformatter.cpp +++ b/src/declarative/util/qmldatetimeformatter.cpp @@ -74,8 +74,8 @@ public: \brief The DateTimeFormatter allows you to control the format of a date string. \code - <DateTimeFormatter id="Formatter" date="{System.date}"/> - <Text text="{Formatter.dateText}"/> + DateTimeFormatter { id: Formatter; date: System.date } + Text { text: Formatter.dateText } \endcode By default, the text properties (dateText, timeText, and dateTimeText) will return the @@ -110,18 +110,18 @@ QmlDateTimeFormatter::~QmlDateTimeFormatter() will use the system locale's default 'short' setting. \code - <!-- specify source date (assuming today is February 19, 2009) --> - <DateTimeFormatter id="formatter" dateTime="{Today.date}"/> + // specify source date (assuming today is February 19, 2009) + DateTimeFormatter { id: formatter; dateTime: Today.date } - <!-- display the full date and time --> - <Text text="{formatter.dateText}"/> + // display the full date and time + Text { text: formatter.dateText } \endcode Would be equivalent to the following for a US English locale: \code - <!-- display the date --> - <Text text="2/19/09"/> + // display the date + Text { text: "2/19/09" } \endcode */ QString QmlDateTimeFormatter::dateTimeText() const @@ -150,14 +150,14 @@ QString QmlDateTimeFormatter::timeText() const The source date and time to be used by the formatter. \code - <!-- setting the date and time --> - <DateTimeFormatter date="{System.date}" time="{System.time}"/> + // setting the date and time + DateTimeFormatter { date: System.date; time: System.time } \endcode For convienience it is possible to set the datetime property to set both the date and the time. \code - <!-- setting the datetime --> - <DateTimeFormatter dateTime="{System.dateTime}"/> + // setting the datetime + DateTimeFormatter { dateTime: System.dateTime } \endcode There can only be one instance of date and time per formatter; if date, time, and dateTime are all @@ -208,8 +208,8 @@ QDateTime QmlDateTimeFormatter::dateTime() const Syntax for the format is based on the QDateTime::toString() formatting options. \code - <!-- Format the date such that the dateText is: '1997-12-12'> - <DateFormatter id="formatter" dateTime="{Today.dateTime}" formatDate="yyyy-MM-d"/> + // Format the date such that the dateText is: '1997-12-12' + DateTimeFormatter { id: formatter; dateTime: Today.dateTime; formatDate: "yyyy-MM-d" } \endcode Assigning an empty string to a particular format will reset it. diff --git a/src/declarative/util/qmlscript.cpp b/src/declarative/util/qmlscript.cpp index 757ae09..7e33502 100644 --- a/src/declarative/util/qmlscript.cpp +++ b/src/declarative/util/qmlscript.cpp @@ -85,13 +85,13 @@ public: within a QmlScript, it is best to limit yourself to defining functions. \qml - <Script> + Script { function debugMyComponent() { print(text.text); print(otherinterestingitem.property); } - </Script> - <MouseRegion onClicked="debugMyComponent()" /> + } + MouseRegion { onClicked: debugMyComponent() } \endqml \note QmlScript executes JavaScript as soon as it is specified. |