summaryrefslogtreecommitdiffstats
path: root/doc/src
diff options
context:
space:
mode:
Diffstat (limited to 'doc/src')
-rw-r--r--doc/src/declarative/animation.qdoc5
-rw-r--r--doc/src/declarative/binding.qdoc14
-rw-r--r--doc/src/declarative/elements.qdoc12
-rw-r--r--doc/src/declarative/qmlintro.qdoc8
-rw-r--r--doc/src/declarative/tutorial3.qdoc6
-rw-r--r--doc/src/examples/qxmlstreambookmarks.qdoc42
-rw-r--r--doc/src/howtos/restoring-geometry.qdoc39
-rw-r--r--doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp19
-rw-r--r--doc/src/snippets/declarative/mouseregion.qml1
9 files changed, 82 insertions, 64 deletions
diff --git a/doc/src/declarative/animation.qdoc b/doc/src/declarative/animation.qdoc
index eea0fc3..28a3c47 100644
--- a/doc/src/declarative/animation.qdoc
+++ b/doc/src/declarative/animation.qdoc
@@ -89,12 +89,9 @@ Item {
states: [
State {
name: "moved"
- SetProperties {
+ PropertyChanges {
target: myrect
x: 50
- }
- SetProperties {
- target: myrect
y: 50
}
}
diff --git a/doc/src/declarative/binding.qdoc b/doc/src/declarative/binding.qdoc
index a649f3f..064f686 100644
--- a/doc/src/declarative/binding.qdoc
+++ b/doc/src/declarative/binding.qdoc
@@ -5,17 +5,17 @@
Data binding provides a declarative way of specifying the data associated with objects, as well as the relationship between data of different objects. For example, you could bind the text of a label to the value of a slider: as the value of the slider changed, the label would be automatically updated with the new value.
-Bindings are created in QML when an expression is assigned to a property. For example, the following produces two rectangles of equal size (\c rect2 is bound to the size of \c rect1):
+Bindings are created in QML when an expression is assigned to a property. For example, the following produces two rectangles of equal size (\c Rect2 is bound to the size of \c Rect1):
\code
-Rectangle { id: rect1; width: 100; height: 100 }
-Rectangle { id: rect2; width: rect1.width; height: rect1.height }
+Rectangle { id: Rect1; width: 100; height: 100 }
+Rectangle { id: Rect2; width: Rect1.width; height: Rect1.height }
\endcode
-There is also a special \l Bind element, which is typically used to bind from the UI to the underlying UI model (see \l {Passing Data Between C++ and QML} for an example of this). The bindings above could be expressed using the \l Bind element as:
+There is also a special \l Binding element, which is typically used to bind from the UI to the underlying UI model (see \l {Passing Data Between C++ and QML} for an example of this). The bindings above could be expressed using the \l Binding element as:
\code
-Bind { target: rect2; property: "width"; value: rect1.width }
-Bind { target: rect2; property: "height"; value: rect1.height }
+Binding { target: Rect2; property: "width"; value: Rect1.width }
+Binding { target: Rect2; property: "height"; value: Rect1.height }
\endcode
In addition to binding directly to a property, you can also bind to the results of expressions involving properties. For example:
@@ -102,7 +102,7 @@ Finally, in QML you can make the appropriate bindings, so in \c "MyUI.qml":
\code
Slider { value: screen.brightness }
-Bind { target: screen; property: "brightness"; value: slider.value }
+Binding { target: screen; property: "brightness"; value: slider.value }
\endcode
The \l QBindableMap class provides a convenient way to make data visible to the bind engine.
diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc
index 2d43fda..6a285ba 100644
--- a/doc/src/declarative/elements.qdoc
+++ b/doc/src/declarative/elements.qdoc
@@ -18,9 +18,10 @@ The following table lists the QML elements provided by the Qt Declarative module
\o
\list
\o \l State
-\o \l SetProperties
+\o \l PropertyChanges
\o \l ParentChange
-\o \l RunScript
+\o \l StateChangeScript
+\o \l AnchorChanges
\endlist
\o
@@ -31,8 +32,9 @@ The following table lists the QML elements provided by the Qt Declarative module
\o \l PauseAnimation
\o \l SequentialAnimation
\o \l ParallelAnimation
-\o \l SetPropertyAction
-\o \l ParentChangeAction
+\o \l PropertyAction
+\o \l ParentAction
+\o \l ScriptAction
\o \l Transition
\o \l Behavior
\o \l Follow
@@ -40,7 +42,7 @@ The following table lists the QML elements provided by the Qt Declarative module
\o
\list
-\o \l Bind
+\o \l Binding
\o \l ListModel
\o \l VisualItemModel
\o \l XmlListModel and XmlRole
diff --git a/doc/src/declarative/qmlintro.qdoc b/doc/src/declarative/qmlintro.qdoc
index fec8f11..41da36e 100644
--- a/doc/src/declarative/qmlintro.qdoc
+++ b/doc/src/declarative/qmlintro.qdoc
@@ -201,8 +201,8 @@ If a list property has been the default property, it means the property tag can
\code
State {
changes: [
- SetProperties {},
- SetProperties {}
+ PropertyChanges {},
+ PropertyChanges {}
]
}
\endcode
@@ -211,8 +211,8 @@ can be simplified to
\code
State {
- SetProperties {}
- SetProperties {}
+ PropertyChanges {}
+ PropertyChanges {}
}
\endcode
diff --git a/doc/src/declarative/tutorial3.qdoc b/doc/src/declarative/tutorial3.qdoc
index 3517f97..d402a66 100644
--- a/doc/src/declarative/tutorial3.qdoc
+++ b/doc/src/declarative/tutorial3.qdoc
@@ -28,8 +28,7 @@ Rectangle {
State {
name: "down"
when: MouseRegion.pressed == true
- SetProperties { target: HelloText; y: 160 }
- SetProperties { target: HelloText color: "red" }
+ PropertyChanges { target: HelloText; y: 160; color: "red" }
}
]
transitions: [
@@ -72,8 +71,7 @@ states: [
State {
name: "down"
when: MouseRegion.pressed == true
- SetProperties { target: HelloText; y: 160 }
- SetProperties { target: HelloText; color: "red" }
+ PropertyChanges { target: HelloText; y: 160; color: "red" }
}
]
\endcode
diff --git a/doc/src/examples/qxmlstreambookmarks.qdoc b/doc/src/examples/qxmlstreambookmarks.qdoc
index 26964c4..904cd6d 100644
--- a/doc/src/examples/qxmlstreambookmarks.qdoc
+++ b/doc/src/examples/qxmlstreambookmarks.qdoc
@@ -51,10 +51,10 @@
\section1 XbelWriter Class Definition
- The \c XbelWriter class is a subclass of QXmlStreamReader, which provides
- an XML parser with a streaming API. \c XbelWriter also contains a private
- instance of QTreeWidget in order to display the bookmarks according to
- hierarchies.
+ The \c XbelWriter class contains a private instance of QXmlStreamWriter,
+ which provides an XML writer with a streaming API. \c XbelWriter also
+ has a reference to the QTreeWidget instance where the bookmark hierarchy
+ is stored.
\snippet examples/xml/streambookmarks/xbelwriter.h 0
@@ -75,7 +75,7 @@
\snippet examples/xml/streambookmarks/xbelwriter.cpp 1
- The \c writeItem() function accepts a QTreeWidget object and writes it
+ The \c writeItem() function accepts a QTreeWidgetItem object and writes it
to the stream, depending on its \c tagName, which can either be a "folder",
"bookmark", or "separator".
@@ -83,9 +83,10 @@
\section1 XbelReader Class Definition
- The \c XbelReader class is a subclass of QXmlStreamReader, the pendent
- class for QXmlStreamWriter. \c XbelReader contains a private instance
- of QTreeWidget to group bookmarks according to their hierarchies.
+ The \c XbelReader contains a private instance of QXmlStreamReader, the
+ companion class to QXmlStreamWriter. \c XbelReader also contains a
+ reference to the QTreeWidget that is used to group the bookmarks according
+ to their hierarchy.
\snippet examples/xml/streambookmarks/xbelreader.h 0
@@ -102,21 +103,26 @@
\snippet examples/xml/streambookmarks/xbelreader.cpp 0
The \c read() function accepts a QIODevice and sets it using
- \l{QXmlStreamReader::setDevice()}{setDevice()}. The actual process
- of reading only takes place if the file is a valid XBEL 1.0 file.
- Note that the XML input needs to be well-formed to be accepted by
- QXmlStreamReader. Otherwise, the \l{QXmlStreamReader::raiseError()}
- {raiseError()} function is used to display an error message. Since the
- XBEL reader is only concerned with reading XML elements, it makes
- extensive use of the \l{QXmlStreamReader::readNextStartElement()}
+ \l{QXmlStreamReader::}{setDevice()}. The actual process of reading only
+ takes place if the file is a valid XBEL 1.0 file. Note that the XML input
+ needs to be well-formed to be accepted by QXmlStreamReader. Otherwise, the
+ \l{QXmlStreamReader::}{raiseError()} function is used to display an error
+ message. Since the XBEL reader is only concerned with reading XML elements,
+ it makes extensive use of the \l{QXmlStreamReader::}{readNextStartElement()}
convenience function.
\snippet examples/xml/streambookmarks/xbelreader.cpp 1
+ The \c errorString() function is used if an error occurred, in order to
+ obtain a description of the error complete with line and column number
+ information.
+
+ \snippet examples/xml/streambookmarks/xbelreader.cpp 2
+
The \c readXBEL() function reads the name of a startElement and calls
the appropriate function to read it, depending on whether if its a
"folder", "bookmark" or "separator". Otherwise, it calls
- \l{QXmlStreamReader::skipCurrentElement()}. The Q_ASSERT() macro is used
+ \l{QXmlStreamReader::}{skipCurrentElement()}. The Q_ASSERT() macro is used
to provide a pre-condition for the function.
\snippet examples/xml/streambookmarks/xbelreader.cpp 3
@@ -126,8 +132,8 @@
\snippet examples/xml/streambookmarks/xbelreader.cpp 4
The \c readSeparator() function creates a separator and sets its flags.
- The text is set to 30 "0xB7", the HEX equivalent for period, and then
- read using \c readElementText().
+ The text is set to 30 "0xB7", the HEX equivalent for period. The element
+ is then skipped using \l{QXmlStreamReader::}{skipCurrentElement()}.
\snippet examples/xml/streambookmarks/xbelreader.cpp 5
diff --git a/doc/src/howtos/restoring-geometry.qdoc b/doc/src/howtos/restoring-geometry.qdoc
index c9e6f4f..cc6f3e1 100644
--- a/doc/src/howtos/restoring-geometry.qdoc
+++ b/doc/src/howtos/restoring-geometry.qdoc
@@ -45,25 +45,28 @@
\ingroup best-practices
- This document describes how to save and restore a window's
- geometry using the geometry properties. On Windows, this is
- basically storing the result of QWidget::geometry() and calling
- QWidget::setGeometry() in the next session before calling
- \l{QWidget::show()}{show()}.
+ This document describes how to save and restore a \l{Window
+ Geometry}{window's geometry} using the geometry properties. On
+ Windows, this is basically storing the result of
+ QWidget::geometry() and calling QWidget::setGeometry() in the next
+ session before calling \l{QWidget::show()}{show()}.
- On X11, this won't work because an invisible window doesn't have
- a frame yet. The window manager will decorate the window later.
- When this happens, the window shifts towards the bottom/right
- corner of the screen depending on the size of the decoration frame.
- Although X provides a way to avoid this shift, most window managers
- fail to implement this feature.
+ On X11, this might not work because an invisible window does not
+ have a frame yet. The window manager will decorate the window
+ later. When this happens, the window shifts towards the
+ bottom/right corner of the screen depending on the size of the
+ decoration frame. Although X provides a way to avoid this shift,
+ some window managers fail to implement this feature.
Since version 4.2, Qt provides functions that saves and restores a
window's geometry and state for you. QWidget::saveGeometry()
saves the window geometry and maximized/fullscreen state, while
QWidget::restoreGeometry() restores it. The restore function also
checks if the restored geometry is outside the available screen
- geometry, and modifies it as appropriate if it is.
+ geometry, and modifies it as appropriate if it is:
+
+ \snippet doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp 0
+ \snippet doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp 1
If those functions are not available or cannot be used, then a
workaround is to call \l{QWidget::setGeometry()}{setGeometry()}
@@ -74,14 +77,6 @@
\l{QWidget::pos()}{pos()} and \l{QWidget::size()}{size()} and to
restore the geometry using \l{QWidget::resize()} and
\l{QWidget::move()}{move()} before calling
- \l{QWidget::show()}{show()}, as demonstrated in the following
- code snippets (from the \l{mainwindows/application}{Application}
- example):
-
- \snippet examples/mainwindows/application/mainwindow.cpp 35
- \codeline
- \snippet examples/mainwindows/application/mainwindow.cpp 38
-
- This method works on Windows, Mac OS X, and most X11 window
- managers.
+ \l{QWidget::show()}{show()}, as demonstrated in the
+ \l{mainwindows/application}{Application} example.
*/
diff --git a/doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp b/doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp
new file mode 100644
index 0000000..0e4040a
--- /dev/null
+++ b/doc/src/snippets/code/src_gui_widgets_qmainwindow.cpp
@@ -0,0 +1,19 @@
+//! [0]
+void MyMainWindow::closeEvent(QCloseEvent *event)
+{
+ QSettings settings("MyCompany", "MyApp");
+ settings.setValue("geometry", saveGeometry());
+ settings.setValue("windowState", saveState());
+ QMainWindow::closeEvent(event);
+}
+//! [0]
+
+
+//! [1]
+void MainWindow::readSettings()
+{
+ QSettings settings("MyCompany", "MyApp");
+ restoreGeometry(settings.value("myWidget/geometry").toByteArray());
+ restoreState(settings.value("myWidget/windowState").toByteArray());
+}
+//! [1]
diff --git a/doc/src/snippets/declarative/mouseregion.qml b/doc/src/snippets/declarative/mouseregion.qml
index 6d8f179..67857f5 100644
--- a/doc/src/snippets/declarative/mouseregion.qml
+++ b/doc/src/snippets/declarative/mouseregion.qml
@@ -12,6 +12,7 @@ Rectangle {
width: 100; height: 100; color: "green"
MouseRegion {
anchors.fill: parent
+ acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: {
if (mouse.button == Qt.RightButton)
parent.color = 'blue';