summaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/src/declarative/animation.qdoc13
-rw-r--r--doc/src/declarative/basictypes.qdoc284
-rw-r--r--doc/src/declarative/binding.qdoc18
-rw-r--r--doc/src/declarative/elements.qdoc14
-rw-r--r--doc/src/declarative/qmlintro.qdoc10
-rw-r--r--doc/src/declarative/qtdeclarative.qdoc2
-rw-r--r--doc/src/declarative/tutorial3.qdoc16
-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/comments.qml2
-rw-r--r--doc/src/snippets/declarative/mouseregion.qml1
-rw-r--r--doc/src/snippets/declarative/pathview/pathattributes.qml2
-rw-r--r--doc/src/snippets/declarative/pathview/pathview.qml2
14 files changed, 196 insertions, 268 deletions
diff --git a/doc/src/declarative/animation.qdoc b/doc/src/declarative/animation.qdoc
index eea0fc3..9554ad5 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
}
}
@@ -124,8 +121,8 @@ QML transitions can use selectors to determine which state changes a transition
\code
Transition {
- fromState: "*"
- toState: "Details"
+ from: "*"
+ to: "Details"
...
}
\endcode
@@ -134,8 +131,8 @@ Transitions can happen in parallel, in sequence, or in any combination of the tw
\code
Transition {
- fromState: "*"
- toState: "MyState"
+ from: "*"
+ to: "MyState"
reversible: true
SequentialAnimation {
ColorAnimation {
diff --git a/doc/src/declarative/basictypes.qdoc b/doc/src/declarative/basictypes.qdoc
index 092501f..ae942fc 100644
--- a/doc/src/declarative/basictypes.qdoc
+++ b/doc/src/declarative/basictypes.qdoc
@@ -7,279 +7,189 @@
exactly what you would expect.
\target basicqmlint
- \raw HTML
- <table>
- <tr><td><div class="qmltype">int</div></td></tr>
- </table>
- \endraw
+ \section1 int
- ints are whole numbers - things like 0, 10 and -20. The possible int
+ An integer or \c int is a whole numbers like 0, 10 or -20. The possible \c int
values range from around -2000000000 to around 2000000000, although most
elements will only accept a reduced range (which they mention in their
documentation).
- int's must be specified using the plain old syntax you learned at school -
- none of that scientific notation nonsense is supported.
-
- Setting ints looks like this:
- \code
- Item { width: 100; height:200 }
- \endcode
+ Example:
+ \qml
+ Item { width: 100; height: 200 }
+ \endqml
\target basicqmlbool
- \raw HTML
- <br>
- <table>
- <tr><td><div class="qmltype">bool</div></td></tr>
- </table>
- \endraw
+ \section1 bool
- bools are a binary true/false value, represented by the strings
- "true" and "false" in QML.
+ A boolean or \c bool is a binary true/false value.
- Setting bools looks like this:
- \code
+ Example:
+ \qml
Item { focus: true; clip: false }
- \endcode
-
- \note Technically bool treats an empty string, "false" and "0" as false and
- everything else as true. Seriously, though, use "true" and "false".
+ \endqml
\target basicqmlreal
- \raw HTML
- <br>
- <table>
- <tr><td><div class="qmltype">real</div></td></tr>
- </table>
- \endraw
+ \section1 real
- reals are numbers - either whole numbers like ints, or fractional numbers
- like 1.2 and -29.8.
+ A \c real is a number - either a whole number like an \c int, or a fractional number
+ like 1.2 or -29.8.
- Setting reals looks like this:
- \code
- Item { x: -10; y: 100.8 }
- \endcode
+ Example:
+ \qml
+ Item { width: 100.45; height: 150.82 }
+ \endqml
\note In QML all reals are stored in single precision, \l {http://en.wikipedia.org/wiki/IEEE_754}{IEEE floating point} format.
\target basicqmlstring
- \raw HTML
- <br>
- <table>
- <tr><td><div class="qmltype">string</div></td></tr>
- </table>
- \endraw
+ \section1 string
- strings are free form text, like "hello world", "QML is cool" and
- anything else you can think of.
+ A string is a free form text, like "Hello world!".
- Setting a string looks like this:
- \code
+ Example:
+ \qml
Text { text: "Hello world!" }
- \endcode
-
- \raw HTML
- \endraw
+ \endqml
\target basicqmlurl
- \raw HTML
- <br>
- <table>
- <tr><td><div class="qmltype">url</div></td></tr>
- </table>
- \endraw
+ \section1 url
- URLs are resource locators, such as file names. They can be either absolute, like "http://qtsoftware.com",
- or relative, like "pics/logo.png". Relative URLs are resolved relative to the URL of the component where
+ A URL is a resource locator, like a file name. It can be either absolute, like "http://qtsoftware.com",
+ or relative, like "pics/logo.png". A relative URL is resolved relative to the URL of the component where
the URL is converted from a JavaScript string expression to a url property value.
- Setting a url looks like this:
- \code
+ Example:
+ \qml
Image { source: "pics/logo.png" }
- \endcode
+ \endqml
\raw HTML
\endraw
\target basicqmlcolor
- \raw HTML
- <br>
- <table>
- <tr><td><div class="qmltype">color</div></td></tr>
- </table>
- \endraw
+ \section1 color
- Colors are most commonly specified as an \l {http://www.w3.org/TR/SVG/types.html#ColorKeywords}{SVG color name}. These names include colors like
+ A \c color is most commonly specified as an \l {http://www.w3.org/TR/SVG/types.html#ColorKeywords}{SVG color name}. These names include colors like
"red", "green" and "lightsteelblue".
If the color you want isn't part of this list, colors can also be specified
- in hexidecimal triplets or quads that take the form \c "#RRGGBB" and
+ in hexidecimal triplets or quads that take the form \c "#RRGGBB" and
\c "#AARRGGBB" respectively. For example, the color red corresponds to a
- triplet of \c "#FF0000" and a slightly transparent blue to a quad of
+ triplet of \c "#FF0000" and a slightly transparent blue to a quad of
\c "#800000FF".
- Setting a color looks like this:
- \code
+ Example:
+ \qml
Rectangle { color: "steelblue" }
Rectangle { color: "#FF0000" }
Rectangle { color: "#800000FF" }
- \endcode
+ \endqml
\target basicqmlpoint
- \raw HTML
- <br>
- <table>
- <tr><td><div class="qmltype">point</div></td></tr>
- </table>
- \endraw
+ \section1 point
- Points are specified in \c "x,y" format.
+ A \c point is specified in \c "x,y" format.
- Setting a point looks like this:
- \code
- Widget { pos: "50,50" }
- \endcode
+ Example:
+ \qml
+ Widget { pos: "0,20" }
+ \endqml
\target basicqmlsize
- \raw HTML
- <br>
- <table>
- <tr><td><div class="qmltype">size</div></td></tr>
- </table>
- \endraw
+ \section1 size
- Sizes are specified in \c "widthxheight" format.
+ A \c size is specified in \c "widthxheight" format.
- Setting a size looks like this:
- \code
- Widget { size: "50x50" }
- \endcode
+ Example:
+ \qml
+ Widget { size: "150x50" }
+ \endqml
\target basicqmlrectangle
- \raw HTML
- <br>
- <table>
- <tr><td><div class="qmltype">rectangle</div></td></tr>
- </table>
- \endraw
+ \section1 rect
- Rectangles are specified in \c "x,y,widthxheight" format.
+ A \c rect is specified in \c "x,y,widthxheight" format.
- Setting a rectangle looks like this:
- \code
+ Example:
+ \qml
Widget { geometry: "50,50,100x100" }
- \endcode
+ \endqml
\target basicqmldate
- \raw HTML
- <br>
- <table>
- <tr><td><div class="qmltype">date</div></td></tr>
- </table>
- \endraw
+ \section1 date
- Dates are specified in \c "YYYY-MM-DD" format.
+ A \c date is specified in \c "YYYY-MM-DD" format.
- Setting a date looks like this:
- \code
+ Example:
+ \qml
DatePicker { minDate: "2000-01-01"; maxDate: "2020-12-31" }
- \endcode
+ \endqml
\target basicqmltime
- \raw HTML
- <br>
- <table>
- <tr><td><div class="qmltype">time</div></td></tr>
- </table>
- \endraw
+ \section1 time
- Times are specified in \c "hh:mm:ss" format.
+ A \c time is specified in \c "hh:mm:ss" format.
- Setting a time looks like this:
- \code
+ Example:
+ \qml
TimePicker { time: "14:22:15" }
- \endcode
+ \endqml
\target basicqmlfont
- \raw HTML
- <br>
- <table>
- <tr><td><div class="qmltype">font</div></td></tr>
- </table>
- \endraw
-
- The font type has components:
+ \section1 font
+
+ The \c font type has the following properties of a QFont:
\list
- \o string font.family
- \o bool font.bold
- \o bool font.italic
- \o real font.pointSize
+ \o \c string font.family
+ \o \c bool font.bold
+ \o \c bool font.italic
+ \o \c bool font.underline
+ \o \c real font.pointSize
+ \o \c int font.pixelSize
\endlist
- Setting a font looks like this:
- \code
+ Example:
+ \qml
Text { font.family: "Helvetica"; font.pointSize: 13; font.bold: true }
- \endcode
+ \endqml
\target basicqmlaction
- \raw HTML
- <br>
- <table>
- <tr><td><div class="qmltype">action</div></td></tr>
- </table>
- \endraw
-
+ \section1 action
+
The action type has all the properties of QAction, in particular:
\list
- \o slot action.trigger - invoke the action
- \o bool action.enabled - true if the action is enabled
- \o string action.text - the text associated with the action
+ \o \c slot action.trigger - invoke the action
+ \o \c bool action.enabled - true if the action is enabled
+ \o \c string action.text - the text associated with the action
\endlist
Actions are used like this:
- \code
- MouseRegion { onClicked: someitem.someaction.trigger() }
- State { name: "enabled"; when: someitem.someaction.enabled=='true' }
- Text { text: someitem.someaction.text }
- \endcode
-
- \target basicqmlany
- \raw HTML
- <br>
- <table>
- <tr><td><div class="qmltype">any</div></td></tr>
- </table>
- \endraw
-
- The any type can accept any basic type, object or list. Generally this
- is only used in very special cases. The documentation for elements that
- use the any type will explain the constraints in that particular case.
+ \qml
+ MouseRegion { onClicked: MyItem.myaction.trigger() }
+ State { name: "enabled"; when: MyItem.myaction.enabled == true }
+ Text { text: MyItem.someaction.text }
+ \endqml
\target basicqmllist
- \raw HTML
- <br>
- <table>
- <tr><td><div class="qmltype">Lists</div></td></tr>
- </table>
- \endraw
-
+ \section1 list
+
While not technically a basic type, QML also supports lists of object
- types. When used from QML, the engine automatically appends each value to the
- list.
-
+ types. When used from QML, the engine automatically appends each value to the
+ list.
+
For example, the \l Item class has a children list property
that can be used like this:
- \code
+ \qml
Item {
- children [
- Item { id: child1 },
- Rectangle { id: child2 },
- Text { id: child3 }
+ children: [
+ Item { id: Child1 },
+ Rectangle { id: Child2 },
+ Text { id: Child3 }
]
}
- \endcode
- \c child1, \c child2 and \c child3 will all be added to the children list
+ \endqml
+ \c Child1, \c Child2 and \c Child3 will all be added to the children list
in the order in which they appear.
*/
diff --git a/doc/src/declarative/binding.qdoc b/doc/src/declarative/binding.qdoc
index 6168462..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:
@@ -26,13 +26,13 @@ Image { source: if (contact.gender == "female") {"pics/female.png"} else {"pics/
Relevant items can also be bound to the contents of a model - see \l ListView for an example of this.
-Data can be bound to C++ objects - see \l {C++ Data Binding}.
+Data can be bound to C++ objects - see \l {QML/C++ Data Binding}.
*/
/*!
\page qtbinding.html
\target qtbinding
-\title C++ Data Binding
+\title QML/C++ Data Binding
The QML mechanisms of \l {Data Binding} can also be used to bind Qt C++ objects.
@@ -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 fff1352..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
@@ -97,7 +99,7 @@ The following table lists the QML elements provided by the Qt Declarative module
\list
\o \l Loader
\o \l Repeater
-\o \l Palette
+\o \l SystemPalette
\o \l ComponentInstance
\o \l GraphicsObjectContainer
\endlist
diff --git a/doc/src/declarative/qmlintro.qdoc b/doc/src/declarative/qmlintro.qdoc
index ced2d68..41da36e 100644
--- a/doc/src/declarative/qmlintro.qdoc
+++ b/doc/src/declarative/qmlintro.qdoc
@@ -200,9 +200,9 @@ If a list property has been the default property, it means the property tag can
\code
State {
- operations: [
- SetProperties {},
- SetProperties {}
+ changes: [
+ PropertyChanges {},
+ PropertyChanges {}
]
}
\endcode
@@ -211,8 +211,8 @@ can be simplified to
\code
State {
- SetProperties {}
- SetProperties {}
+ PropertyChanges {}
+ PropertyChanges {}
}
\endcode
diff --git a/doc/src/declarative/qtdeclarative.qdoc b/doc/src/declarative/qtdeclarative.qdoc
index 6abcd92..1b7644c 100644
--- a/doc/src/declarative/qtdeclarative.qdoc
+++ b/doc/src/declarative/qtdeclarative.qdoc
@@ -87,7 +87,7 @@
C++ Reference:
\list
\o \l {Extending QML}
- \o \l {qtbinding}{C++ Data Binding}
+ \o \l {qtbinding}{QML/C++ Data Binding}
\o \l {cppitem}{C++ Components}
\endlist
*/
diff --git a/doc/src/declarative/tutorial3.qdoc b/doc/src/declarative/tutorial3.qdoc
index 3517f97..1330c43 100644
--- a/doc/src/declarative/tutorial3.qdoc
+++ b/doc/src/declarative/tutorial3.qdoc
@@ -28,14 +28,13 @@ 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: [
Transition {
- fromState: "*"
- toState: "down"
+ from: "*"
+ to: "down"
reversible: true
ParallelAnimation {
NumberAnimation {
@@ -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
@@ -84,15 +82,15 @@ The \e down state includes a set of property changes from our implicit \e {defau
\code
Transition {
- fromState: "*"
- toState: "down"
+ from: "*"
+ to: "down"
reversible: true
}
\endcode
Because we don't want the text to appear at the bottom instantly but rather move smoothly, we add a transition between our two states.
-\c fromState and \c toState define the states between which the transition will run. In this case, we want a transition from any state to our \e down state.
+\c from and \c to define the states between which the transition will run. In this case, we want a transition from any state to our \e down state.
Because we want the same transition to be run in reverse when changing back from the \e down state to the default state, we set \c reversible to \c true. This is equivalent to writing the two transitions separately.
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/comments.qml b/doc/src/snippets/declarative/comments.qml
index 4f8a442..806be29 100644
--- a/doc/src/snippets/declarative/comments.qml
+++ b/doc/src/snippets/declarative/comments.qml
@@ -7,5 +7,5 @@ Text {
we give it a large size and different font.
*/
font.family: "Helvetica"
- font.size: 24
+ font.pointSize: 24
}
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';
diff --git a/doc/src/snippets/declarative/pathview/pathattributes.qml b/doc/src/snippets/declarative/pathview/pathattributes.qml
index 3c2b204..92d6966 100644
--- a/doc/src/snippets/declarative/pathview/pathattributes.qml
+++ b/doc/src/snippets/declarative/pathview/pathattributes.qml
@@ -13,7 +13,7 @@ Rectangle {
opacity: PathView.opacity
VerticalLayout {
Image { anchors.horizontalCenter: Name.horizontalCenter; width: 64; height: 64; source: icon }
- Text { id: Name; text: name; font.size: 16}
+ Text { id: Name; text: name; font.pointSize: 16}
}
}
}
diff --git a/doc/src/snippets/declarative/pathview/pathview.qml b/doc/src/snippets/declarative/pathview/pathview.qml
index f5db242..004a1d2 100644
--- a/doc/src/snippets/declarative/pathview/pathview.qml
+++ b/doc/src/snippets/declarative/pathview/pathview.qml
@@ -11,7 +11,7 @@ Rectangle {
width: 80; height: 80
VerticalLayout {
Image { anchors.horizontalCenter: Name.horizontalCenter; width: 64; height: 64; source: icon }
- Text { id: Name; text: name; font.size: 16}
+ Text { id: Name; text: name; font.pointSize: 16}
}
}
}