diff options
Diffstat (limited to 'doc')
32 files changed, 916 insertions, 298 deletions
diff --git a/doc/src/declarative/codingconventions.qdoc b/doc/src/declarative/codingconventions.qdoc index ba789e0..3f92d46 100644 --- a/doc/src/declarative/codingconventions.qdoc +++ b/doc/src/declarative/codingconventions.qdoc @@ -35,7 +35,7 @@ This page assumes that you are already familiar with the QML language. If you need an introduction to the language, please read \l {Introduction to the QML language}{the QML introduction} first. -\section1 QML objects +\section1 QML Objects Through our documentation and examples, QML objects are always structured in the following order: @@ -58,7 +58,7 @@ For example, a hypothetical \e photo QML object would look like this: \snippet doc/src/snippets/declarative/codingconventions/photo.qml 0 -\section1 Grouped properties +\section1 Grouped Properties If using multiple properties from a group of properties, we use the \e {group notation} rather than the \e {dot notation} to improve readability. @@ -72,6 +72,18 @@ can be written like this: \snippet doc/src/snippets/declarative/codingconventions/dotproperties.qml 1 +\section1 Private Properties + +QML and JavaScript do not enforce private properties like C++. There is a need +to hide these private properties, for example, when the properties are part of +the implementation. As a convention, private properties begin with two +\e underscore characters. For example, \c __area, is a property that is +accessible but is not meant for public use. Note that QML and JavaScript will +grant the user access to these properties. + +\snippet doc/src/snippets/declarative/codingconventions/private.qml 0 + + \section1 Lists If a list contains only one element, we generally omit the square brackets. @@ -87,7 +99,7 @@ we will write this: \snippet doc/src/snippets/declarative/codingconventions/lists.qml 1 -\section1 JavaScript code +\section1 JavaScript Code If the script is a single expression, we recommend writing it inline: diff --git a/doc/src/declarative/declarativeui.qdoc b/doc/src/declarative/declarativeui.qdoc index 5d9eaaf..41b9952 100644 --- a/doc/src/declarative/declarativeui.qdoc +++ b/doc/src/declarative/declarativeui.qdoc @@ -108,6 +108,7 @@ Module. \section1 Handling Data \list +\o \l{QML Basic Types}{QML Basic Data Types} \o \l{Using QML Positioner and Repeater Items} \o \l{QML Data Models} \o \l{Presenting Data with QML} @@ -136,6 +137,7 @@ Module. \list \o \l{QML Elements} +\o \l{QML Basic Types} \o \l{QML Global Object} \o \l{QML Internationalization} \o \l{QML Security} diff --git a/doc/src/declarative/focus.qdoc b/doc/src/declarative/focus.qdoc index 2e74fe0..ae72c3c 100644 --- a/doc/src/declarative/focus.qdoc +++ b/doc/src/declarative/focus.qdoc @@ -31,7 +31,7 @@ \title Keyboard Focus in QML When a key is pressed or released, a key event is generated and delivered to the -focused QML \l Item. To facilitate the construction of reusable components +focused QML \l Item. To facilitate the construction of reusable components and to address some of the cases unique to fluid user interfaces, the QML items add a \e scope based extension to Qt's traditional keyboard focus model. @@ -42,27 +42,21 @@ and to address some of the cases unique to fluid user interfaces, the QML items When the user presses or releases a key, the following occurs: \list 1 \o Qt receives the key action and generates a key event. -\o If the Qt widget containing the \l QDeclarativeView has focus, the key event is delivered to it. Otherwise, regular Qt key handling continues. -\o The key event is delivered by the scene to the QML \l Item with \e {active focus}. If no \l Item has \e {active focus}, the key event is \l {QEvent::ignore()}{ignored} and regular Qt key handling continues. -\o If the QML \l Item with \e {active focus} accepts the key event, propagation stops. Otherwise the event is "bubbled up", by recursively passing it to each \l Item's parent until either the event is accepted, or the root \l Item is reached. - -If the \c {Rectangle} element in the following example has active focus and the \e A key is pressed, -it will bubble up to its parent. However, pressing the \e B key will bubble up to the root -item and thus subsequently be \l {QEvent::ignore()}{ignored}. - -\code -Item { - Item { - Keys.onPressed: { - if (event.key == Qt.Key_A) { - console.log('Key A was pressed'); - event.accepted = true; - } - } - Rectangle {} - } -} -\endcode +\o If the Qt widget containing the \l QDeclarativeView has focus, the key event +is delivered to it. Otherwise, regular Qt key handling continues. +\o The key event is delivered by the scene to the QML \l Item with +\e {active focus}. If no Item has active focus, the key event is +\l {QEvent::ignore()}{ignored} and regular Qt key handling continues. +\o If the QML Item with active focus accepts the key event, propagation +stops. Otherwise the event is "bubbled up", by recursively passing it to each +Item's parent until either the event is accepted, or the root Item is reached. + +If the \c {Rectangle} element in the following example has active focus and the \c A key is pressed, +it will bubble up to its parent. However, pressing the \c B key will bubble up to the root +item and thus subsequently be ignored. + +\snippet doc/src/snippets/declarative/focus/rectangle.qml simple key event +\snippet doc/src/snippets/declarative/focus/rectangle.qml simple key event end \o If the root \l Item is reached, the key event is \l {QEvent::ignore()}{ignored} and regular Qt key handling continues. @@ -72,232 +66,139 @@ See also the \l {Keys}{Keys attached property} and \l {KeyNavigation}{KeyNavigat \section1 Querying the Active Focus Item -Whether or not an \l Item has \e {active focus} can be queried through the -property \c {Item::activeFocus}. For example, here we have a \l Text -element whose text is determined by whether or not it has \e {active focus}. +Whether or not an \l Item has active focus can be queried through the +property \c {Item::activeFocus} property. For example, here we have a \l Text +element whose text is determined by whether or not it has active focus. -\code -Text { - text: activeFocus ? "I have active focus!" : "I do not have active focus" -} -\endcode +\snippet doc/src/snippets/declarative/focus/rectangle.qml active focus \section1 Acquiring Focus and Focus Scopes -An \l Item requests focus by setting the \c {Item::focus} property to true. - -For very simple cases simply setting the \c {Item::focus} property is sometimes -sufficient. If we run the following example with the \l {QML Viewer}, we see that -the \c {keyHandler} element has \e {active focus} and pressing the 'A', 'B' -or 'C' keys modifies the text appropriately. - -\table -\row -\o \code - Rectangle { - color: "lightsteelblue"; width: 240; height: 25 - Text { id: myText } - Item { - id: keyHandler - focus: true - Keys.onPressed: { - if (event.key == Qt.Key_A) - myText.text = 'Key A was pressed' - else if (event.key == Qt.Key_B) - myText.text = 'Key B was pressed' - else if (event.key == Qt.Key_C) - myText.text = 'Key C was pressed' - } - } - } -\endcode -\o \image declarative-qmlfocus1.png -\endtable - -However, were the above example to be used as a self-contained component, this -simple use of the \c {Item::focus} property is no longer sufficient. The left -hand side of the following table shows what we would like to be able to write. -Here we create two instances of our previously defined component, and set the -second one to have focus. The intention is that when the \e A, \e B, or \e C -keys are pressed, the second of the two components receives the event and +An \l Item requests focus by setting the \c focus property to \c true. + +For very simple cases simply setting the \c focus property is sometimes +sufficient. If we run the following example with the \l {QML Viewer}, we see that +the \c {keyHandler} element has active focus and pressing the \c A, \c B, +or \c C keys modifies the text appropriately. + +\snippet doc/src/snippets/declarative/focus/basicwidget.qml focus true + +\image declarative-qmlfocus1.png + +However, were the above example to be used as a reusable or imported component, +this simple use of the \c focus property is no longer sufficient. + +To demonstrate, we create two instances of our previously defined component and +set the first one to have focus. The intention is that when the \c A, \c B, or +\c C keys are pressed, the first of the two components receives the event and responds accordingly. -\table -\row -\o \code -Rectangle { - color: "red"; width: 240; height: 55 - MyWidget {} - MyWidget { y: 30; focus: true } -} -\endcode -\o \code -Rectangle { - color: "red"; width: 240; height: 55 - Rectangle { - color: "lightsteelblue"; width: 240; height: 25 - Text { id: myText } - Item { - id: keyHandler - focus: true - Keys.onPressed: { - if (event.key == Qt.Key_A) - myText.text = 'Key A was pressed' - else if (event.key == Qt.Key_B) - myText.text = 'Key B was pressed' - else if (event.key == Qt.Key_C) - myText.text = 'Key C was pressed' - } - } - } - Rectangle { - y: 30; focus: true - color: "lightsteelblue"; width: 240; height: 25 - Text { id: myText } - Item { - id: keyHandler - focus: true - Keys.onPressed: { - if (event.key == Qt.Key_A) - myText.text = 'Key A was pressed' - else if (event.key == Qt.Key_B) - myText.text = 'Key B was pressed' - else if (event.key == Qt.Key_C) - myText.text = 'Key C was pressed' - } - } - } -} -\endcode -\endtable - -The right hand side of the example shows the expanded code - the equivalent QML -without the use of the component \c {MyWidget}. From this, the problem is -evident - there are no less than three elements that have the \c {Item::focus} -property set to true. Ultimately only one element can have keyboard focus, and the -system has to decide which on. In this case the first appearance of the -\c {Item::focus} property being set to true on line 4 is selected, and the value -of \c {Item::focus} in the other two instances is reverted back to false. This -is exactly the opposite of what was wanted! - -This problem is fundamentally one of visibility. The \c {MyWidget} -components each set their \c {keyHandler} Items as focused as that is all they can -do - they don't know how they are going to be used, but they do know that when -they're in use their \c {keyHandler} element is what needs focus. Likewise -the code that uses the two \c {MyWidgets} sets the second \c {MyWidget} as -focused. While it doesn't know exactly how the \c {MyWidget} is -implemented, it knows that it wants the second one to be focused. This allows us -to achieve encapsulation, allowing each widget to focus on it's appropriate behaviour -itself. - -To solve this problem - allowing components to care about what they know about -and ignore everything else - the QML items introduce a concept known as a -\e {focus scope}. For existing Qt users, a \e {focus scope} is like an -automatic focus proxy. A \e {focus scope} is created using the \l FocusScope -element. - -In the next example, a \l FocusScope is added to the component, and the visual -result shown. - -\table -\row -\o \code -FocusScope { - width: 240; height: 25 - Rectangle { - color: "lightsteelblue"; width: 240; height: 25 - Text { id: myText } - Item { - id: keyHandler - focus: true - Keys.onPressed: { - if (event.key == Qt.Key_A) - myText.text = 'Key A was pressed' - else if (event.key == Qt.Key_B) - myText.text = 'Key B was pressed' - else if (event.key == Qt.Key_C) - myText.text = 'Key C was pressed' - } - } - } -} -\endcode -\o \image declarative-qmlfocus2.png -\endtable +The code that imports and creates two MyWidget instances: +\snippet doc/src/snippets/declarative/focus/widget.qml window + +The MyWidget code: +\snippet doc/src/snippets/declarative/focus/mywidget.qml mywidget + +We would like to have the first MyWidget object to have the focus by setting its +\c focus property to \c true. However, by running the code, we can confirm that +the second widget receives the focus. + +\image declarative-qmlfocus2.png + +Looking at both \c MyWidget and \c window code, the problem is evident - there +are three elements that set the \c focus property set to \c true. The two +MyWidget sets the \c focus to \c true and the \c window component also sets the +focus. Ultimately, only one element can have keyboard focus, and the system has +to decide which element receives the focus. When the second MyWidget is created, +it receives the focus because it is the last element to set its \c focus +property to \c true. + +This problem is due to visibility. The \c MyWidget component would like to have +the focus, but it cannot control the focus when it is imported or reused. +Likewise, the \c window component does not have the ability to know if its +imported components are requesting the focus. + +To solve this problem, the QML introduces a concept known as a \e {focus scope}. +For existing Qt users, a focus scope is like an automatic focus proxy. +A focus scope is created by declaring the \l FocusScope element. + +In the next example, a \l FocusScope element is added to the component, and the +visual result shown. + +\snippet doc/src/snippets/declarative/focus/myfocusscopewidget.qml widget in focusscope + +\image declarative-qmlfocus3.png + Conceptually \e {focus scopes} are quite simple. \list -\o Within each \e {focus scope} one element may have \c {Item::focus} set to true. -If more than one \l Item has the \c {Item::focus} property set, the first is selected -and the others are unset, just like when there are no \e {focus scopes}. -\o When a \e {focus scope} receives \e {active focus}, the contained element with -\c {Item::focus} set (if any) also gets \e {active focus}. If this element is -also a \l FocusScope, the proxying behaviour continues. Both the -\e {focus scope} and the sub-focused item will have \c {Item::activeFocus} set. +\o Within each focus scope one element may have \c {Item::focus} set to +\c true. If more than one \l Item has the \c focus property set, the +last element to set the \c focus will have the focus and the others are unset, +similar to when there are no focus scopes. +\o When a focus scope receives active focus, the contained element with +\c focus set (if any) also gets the active focus. If this element is +also a \l FocusScope, the proxying behavior continues. Both the +focus scope and the sub-focused item will have \c activeFocus property set. \endlist -So far the example has the second component statically selected. It is trivial +Note that, since the FocusScope element is not a visual element, the properties +of its children need to be exposed to the parent item of the FocusScope. Layouts +and positioning elements will use these visual and styling properties to create +the layout. In our example, the \c Column element cannot display the two widgets +properly because the FocusScope lacks visual properties of its own. The MyWidget +component directly binds to the \c rectangle properties to allow the \c Column +element to create the layout containing the children of the FocusScope. + +So far, the example has the second component statically selected. It is trivial now to extend this component to make it clickable, and add it to the original -application. We still set a one of the widgets as focused by default, but from -then on clicking the either one gives it focus. - -\table -\row -\o \code -Rectangle { - color: "red"; width: 240; height: 55 - MyClickableWidget {} - MyClickableWidget { y: 30; focus: true } -} -\endcode -\o \code -FocusScope { - id: page; width: 240; height: 25 - MyWidget { focus: true } - MouseArea { anchors.fill: parent; onClicked: { page.focus = true } } -} -\endcode -\endtable +application. We still set one of the widgets as focused by default. +Now, clicking either MyClickableWidget gives it focus and the other widget +loses the focus. -\image declarative-qmlfocus3.png +The code that imports and creates two MyClickableWidget instances: +\snippet doc/src/snippets/declarative/focus/clickablewidget.qml clickable window + +The MyClickableWidget code: +\snippet doc/src/snippets/declarative/focus/myclickablewidget.qml clickable in focusscope -When a QML item explicitly relinquishes focus (by setting its -\c {Item::focus} property to false while it has \e {active focus}), the system -does not automatically select another element to receive focus. That is, it -is possible for there to be no currently \e {active focus}. +\image declarative-qmlfocus4.png -See the \l{declarative/keyinteraction/focus}{Keyboard Focus example} for a +When a QML \l Item explicitly relinquishes focus (by setting its +\c focus property to \c false while it has active focus), the +system does not automatically select another element to receive focus. That is, +it is possible for there to be no currently active focus. + +See the \l{declarative/keyinteraction/focus}{Keyboard Focus example} for a demonstration of moving keyboard focus between multiple areas using FocusScope elements. \section1 Advanced uses of Focus Scopes -Focus scopes allow focus to allocation to be easily partitioned. Several +Focus scopes allow focus to allocation to be easily partitioned. Several QML items use it to this effect. -\l ListView, for example, is itself a focus scope. Generally this isn't +\l ListView, for example, is itself a focus scope. Generally this isn't noticeable as \l ListView doesn't usually have manually added visual children. By being a focus scope, \l ListView can focus the current list item without -worrying about how that will effect the rest of the application. This allows -the current item delegate to react to key presses. +worrying about how that will effect the rest of the application. This allows the +current item delegate to react to key presses. -This contrived example shows how this works. Pressing the \c Return key will +This contrived example shows how this works. Pressing the \c Return key will print the name of the current list item. -\table -\row -\o \snippet doc/src/snippets/declarative/focusscopes.qml 0 -\o \image declarative-qmlfocus4.png -\endtable +\snippet doc/src/snippets/declarative/focus/advancedFocus.qml FocusScope delegate + +\image declarative-qmlfocus5.png -While the example is simple, there's a lot going on behind the scenes. Whenever +While the example is simple, there are a lot going on behind the scenes. Whenever the current item changes, the \l ListView sets the delegate's \c {Item::focus} -property. As the \l ListView is a \e {focus scope}, this doesn't effect the -rest of the application. However, if the \l ListView itself has -\e {active focus} this causes the delegate itself to receive \e {active focus}. -In this example, the root element of the delegate is also a \e {focus scope}, -which in turn gives \e {active focus} to the \c {Text} element that -actually performs the work of handling the \e {Return} key. +property. As the \l ListView is a focus scope, this doesn't affect the +rest of the application. However, if the \l ListView itself has +active focus this causes the delegate itself to receive active focus. +In this example, the root element of the delegate is also a focus scope, +which in turn gives active focus to the \c {Text} element that actually performs +the work of handling the \c {Return} key. All of the QML view classes, such as \l PathView and \l GridView, behave in a similar manner to allow key handling in their respective delegates. diff --git a/doc/src/declarative/modules.qdoc b/doc/src/declarative/modules.qdoc index 011eb63..2a2e4ff 100644 --- a/doc/src/declarative/modules.qdoc +++ b/doc/src/declarative/modules.qdoc @@ -31,14 +31,14 @@ \section1 QML Modules -A module is a set of QML content files that can be imported as a unit into a QML +A module is a set of QML content files that can be imported as a unit into a QML application. Modules can be used to organize QML content into independent units, -and they can use a versioning mechanism that allows for independent +and they can use a versioning mechanism that allows for independent upgradability of the modules. While QML component files within the same directory are automatically accessible -within the global namespace, components defined elsewhere must be imported -explicitly using the \c import statement to import them as modules. For +within the global namespace, components defined elsewhere must be imported +explicitly using the \c import statement to import them as modules. For example, an \c import statement is required to use: \list @@ -54,13 +54,13 @@ This can be seen in the snippet commonly found at the top of QML files: \qml import QtQuick 1.0 \endqml - -This imports version 4.7 of the "Qt" module into the global namespace. (The QML + +This imports version 1.0 of the "QtQuick" module into the global namespace. (The QML library itself must be imported to use any of the \l {QML Elements}, as they are not included in the global namespace by default.) -The \c Qt module is an \e installed module; it is found in the -\l{The QML import path}{import path}. There are two types of QML modules: +The \c Qt module is an \e installed module; it is found in the +\l{The QML import path}{import path}. There are two types of QML modules: location modules (defined by a URL) and installed modules (defined by a URI). @@ -87,8 +87,8 @@ directory using a relative or absolute path, like this: MyQMLProject |- MyComponents |- Slider.qml - |- CheckBox.qml - |- Main + |- CheckBox.qml + |- Main |- application.qml \endcode @@ -112,7 +112,7 @@ be imported like this: Remote location modules must have a \l{Writing a qmldir file}{qmldir file} in the same directory to specify which QML files should be made available. See the -\l {#qmldirexample}{example} below. The qmldir file is optional for modules on +\l {#qmldirexample}{example} below. The qmldir file is optional for modules on the local filesystem. @@ -121,8 +121,8 @@ the local filesystem. Installed modules are modules that are installed on the -local filesystem within the QML import path, or modules defined in C++ -application code. When importing an installed module, an un-quoted URI is +local filesystem within the QML import path, or modules defined in C++ +application code. When importing an installed module, an un-quoted URI is used, with a mandatory version number: \code @@ -131,7 +131,7 @@ used, with a mandatory version number: \endcode Installed modules that are installed into the import path or created -as a \l{QDeclarativeExtensionPlugin}{QML C++ plugin} must define a +as a \l{QDeclarativeExtensionPlugin}{QML C++ plugin} must define a \l{Writing a qmldir file}{qmldir file}. @@ -142,7 +142,7 @@ The default import path includes: \list \o The directory of the current file -\o The location specified by QLibraryInfo::ImportsPath +\o The location specified by QLibraryInfo::ImportsPath \o Paths specified by the \c QML_IMPORT_PATH environment variable \endlist @@ -153,10 +153,10 @@ When running the \l {QML Viewer}, use the \c -I option to add paths to the impor \section2 Creating installed modules in C++ -C++ applications can dynamically define installed modules using -qmlRegisterType(). +C++ applications can dynamically define installed modules using +qmlRegisterType(). -For \l{QDeclarativeExtensionPlugin}{QML C++ plugins}, the +For \l{QDeclarativeExtensionPlugin}{QML C++ plugins}, the module URI is automatically passed to QDeclarativeExtensionPlugin::registerTypes(). The QDeclarativeExtensionPlugin documentation shows how to use this URI to call qmlRegisterType() to enable the plugin library to be built as @@ -167,7 +167,7 @@ in QML, like this: import com.nokia.TimeExample 1.0 \endcode -A \l{QDeclarativeExtensionPlugin}{QML C++ plugin} also requires a +A \l{QDeclarativeExtensionPlugin}{QML C++ plugin} also requires a \l{Writing a qmldir file}{qmldir file} to make it available to the QML engine. @@ -190,9 +190,9 @@ Types from these modules can then only be used when qualified by the namespace: \qml QtLibrary.Rectangle { ... } - + MyComponents.Slider { ... } - + MyModule.SomeComponent { ... } \endqml @@ -209,7 +209,7 @@ JavaScript files must always be imported with a named import: \qml import "somescript.js" as MyScript - + Item { //... Component.onCompleted: MyScript.doSomething() @@ -220,8 +220,8 @@ JavaScript files must always be imported with a named import: \section1 Writing a qmldir file -A \c qmldir file is a metadata file for a module that maps all type names in -the module to versioned QML files. It is required for installed modules, and +A \c qmldir file is a metadata file for a module that maps all type names in +the module to versioned QML files. It is required for installed modules, and location modules that are loaded from a network source. It is defined by a plain text file named "qmldir" that contains one or more lines of the form: @@ -237,7 +237,7 @@ plugin <Name> [<Path>] \bold {<TypeName> [<InitialVersion>] <File>} lines are used to add QML files as types. <TypeName> is the type being made available, the optional <InitialVersion> is a version -number, and <File> is the (relative) file name of the QML file defining the type. +number, and <File> is the (relative) file name of the QML file defining the type. Installed files do not need to import the module of which they are a part, as they can refer to the other QML files in the module as relative (local) files, but @@ -264,10 +264,10 @@ provide those identifiers. \bold {plugin <Name> [<Path>]} lines are used to add \l{QDeclarativeExtensionPlugin}{QML C++ plugins} to the module. <Name> is the name of the library. It is usually not the same as the file name of the plugin binary, which is platform dependent; e.g. the library \c MyAppTypes would produce -\c libMyAppTypes.so on Linux and \c MyAppTypes.dll on Windows. +\c libMyAppTypes.so on Linux and \c MyAppTypes.dll on Windows. <Path> is an optional argument specifying either an absolute path to the directory containing the -plugin file, or a relative path from the directory containing the \c qmldir file to the directory +plugin file, or a relative path from the directory containing the \c qmldir file to the directory containing the plugin file. By default the engine searches for the plugin library in the directory that contains the \c qmldir file. The plugin search path can be queried with QDeclarativeEngine::pluginPathList() and modified using QDeclarativeEngine::addPluginPath(). When running the \l {QML Viewer}, use the \c -P option to add paths to the plugin search path. @@ -275,7 +275,7 @@ file. The plugin search path can be queried with QDeclarativeEngine::pluginPathL \target qmldirexample \section2 Example -If the components in the \c MyComponents directory from the +If the components in the \c MyComponents directory from the \l{Location Modules}{earlier example} were to be made available as a network resource, the directory would need to contain a \c qmldir file similar to this: @@ -284,7 +284,7 @@ ComponentA 1.0 ComponentA.qml ComponentB 1.0 ComponentB.qml \endcode -The \c MyComponents directory could then be imported as a module using: +The \c MyComponents directory could then be imported as a module using: \code import "http://the-server-name.com/MyComponents" @@ -298,15 +298,15 @@ a later version is used, as the \c qmldir file specifies that these elements are only available in the 1.0 version. -For examples of \c qmldir files for plugins, see the -\l {declarative/cppextensions/plugins}{Plugins} example and +For examples of \c qmldir files for plugins, see the +\l {declarative/cppextensions/plugins}{Plugins} example and \l {Tutorial: Writing QML extensions with C++}. \section1 Debugging The \c QML_IMPORT_TRACE environment variable can be useful for debugging -when there are problems with finding and loading modules. See +when there are problems with finding and loading modules. See \l{Debugging module imports} for more information. diff --git a/doc/src/development/qtestlib.qdoc b/doc/src/development/qtestlib.qdoc index e53957f..08fdfc6 100644 --- a/doc/src/development/qtestlib.qdoc +++ b/doc/src/development/qtestlib.qdoc @@ -245,10 +245,10 @@ \endtable In short, walltime is always available but requires many repetitions to - get a useful result. - Tick counters are usually available and can provide - results with fewer repetitions, but can be susceptible to CPU frequency - scaling issues. + get a useful result. + Tick counters are usually available and can provide + results with fewer repetitions, but can be susceptible to CPU frequency + scaling issues. Valgrind provides exact results, but does not take I/O waits into account, and is only available on a limited number of platforms. @@ -264,7 +264,7 @@ See the chapter 5 in the \l{QTestLib Tutorial} for more benchmarking examples. \section1 Using QTestLib remotely on Windows CE - \c cetest is a convenience application which helps the user to launch an + \c cetest is a convenience application which helps the user to launch an application remotely on a Windows CE device or emulator. It needs to be executed after the unit test has been successfully compiled. @@ -717,15 +717,15 @@ \section1 Writing a Benchmark To create a benchmark we extend a test function with a QBENCHMARK macro. - A benchmark test function will then typically consist of setup code and + A benchmark test function will then typically consist of setup code and a QBENCHMARK macro that contains the code to be measured. This test function benchmarks QString::localeAwareCompare(). \snippet examples/qtestlib/tutorial5/benchmarking.cpp 0 - Setup can be done at the beginning of the function, the clock is not + Setup can be done at the beginning of the function, the clock is not running at this point. The code inside the QBENCHMARK macro will be - measured, and possibly repeated several times in order to get an + measured, and possibly repeated several times in order to get an accurate measurement. Several \l {testlib-benchmarking-measurement}{back-ends} are available @@ -733,7 +733,7 @@ \section1 Data Functions - Data functions are useful for creating benchmarks that compare + Data functions are useful for creating benchmarks that compare multiple data inputs, for example locale aware compare against standard compare. @@ -743,20 +743,19 @@ \snippet examples/qtestlib/tutorial5/benchmarking.cpp 2 - The "if(useLocaleCompare)" switch is placed outside the QBENCHMARK + The "if(useLocaleCompare)" switch is placed outside the QBENCHMARK macro to avoid measuring its overhead. Each benchmark test function - can have one active QBENCHMARK macro. + can have one active QBENCHMARK macro. \section1 External Tools Tools for handling and visualizing test data are available as part of - the qtestlib-tools project on the - \l{http://labs.qt.nokia.com/}{http://labs.qt.nokia.com/}Qt Labs Web site. + the \l {qtestlib-tools} project in the \l{Qt Labs} web site. These include a tool for comparing performance data obtained from test runs and a utility to generate Web-based graphs of performance data. - See the \l{qtestlib-tools Announcement} for more information on these - tools and a simple graphing example. + See the \l{qtestlib-tools Announcement}{qtestlib-tools announcement} + for more information on these tools and a simple graphing example. */ diff --git a/doc/src/examples/diagramscene.qdoc b/doc/src/examples/diagramscene.qdoc index 98bc983..d5cc4e3 100644 --- a/doc/src/examples/diagramscene.qdoc +++ b/doc/src/examples/diagramscene.qdoc @@ -195,7 +195,7 @@ This function returns a QWidget containing a QToolButton with an image of one of the \c DiagramItems, i.e., flowchart shapes. The image is created by the \c DiagramItem through the \c image() - function. The QButtonGroup class lets us attach a QVariant with + function. The QButtonGroup class lets us attach an id (int) with each button; we store the diagram's type, i.e., the DiagramItem::DiagramType enum. We use the stored diagram type when we create new diagram items for the scene. The widgets created diff --git a/doc/src/external-resources.qdoc b/doc/src/external-resources.qdoc index 8eeaeb1..9bc3b1c 100644 --- a/doc/src/external-resources.qdoc +++ b/doc/src/external-resources.qdoc @@ -448,3 +448,8 @@ \externalpage https://developer.mozilla.org/en/JavaScript/About_JavaScript \title About JavaScript */ + +/*! + \externalpage http://www.libusb.org/ + \title libusb +*/ diff --git a/doc/src/frameworks-technologies/threads.qdoc b/doc/src/frameworks-technologies/threads.qdoc index 001b29d..2a0cc1a 100644 --- a/doc/src/frameworks-technologies/threads.qdoc +++ b/doc/src/frameworks-technologies/threads.qdoc @@ -213,10 +213,10 @@ /*! \page threads-reentrancy.html \title Reentrancy and Thread-Safety - + \keyword reentrant \keyword thread-safe - + \previouspage Synchronizing Threads \contentspage Thread Support in Qt \nextpage Threads and QObjects @@ -243,6 +243,15 @@ from multiple threads, even if all the threads use the \e{same} instance of the class. + \note Qt classes are only documented as \e{thread-safe} if they + are intended to be used by multiple threads. If a function is not + marked as thread-safe or reentrant, it should not be used from + different threads. If a class is not marked as thread-safe or + reentrant then a specific instance of that class should not be + accessed from different threads. + + \section1 Reentrancy + C++ classes are often reentrant, simply because they only access their own member data. Any thread can call a member function on an instance of a reentrant class, as long as no other thread can call @@ -268,6 +277,8 @@ end up overwriting each other, and the variable is incremented only once! + \section1 Thread-Safety + Clearly, the access must be serialized: Thread A must perform steps 1, 2, 3 without interruption (atomically) before thread B can perform the same steps; or vice versa. An easy way to make @@ -284,6 +295,8 @@ declared with the \c mutable qualifier because we need to lock and unlock the mutex in \c value(), which is a const function. + \section1 Notes on Qt Classes + Many Qt classes are \e{reentrant}, but they are not made \e{thread-safe}, because making them thread-safe would incur the extra overhead of repeatedly locking and unlocking a QMutex. For @@ -297,9 +310,6 @@ the thread-related classes (e.g. QMutex) and fundamental functions (e.g. QCoreApplication::postEvent()). - \note Qt Classes are only documented as \e{thread-safe} if they - are intended to be used by multiple threads. - \note Terminology in the multithreading domain isn't entirely standardized. POSIX uses definitions of reentrant and thread-safe that are somewhat different for its C APIs. When using other diff --git a/doc/src/getting-started/gettingstartedqml.qdoc b/doc/src/getting-started/gettingstartedqml.qdoc index b767587..e3977bb 100644 --- a/doc/src/getting-started/gettingstartedqml.qdoc +++ b/doc/src/getting-started/gettingstartedqml.qdoc @@ -148,7 +148,7 @@ \code Rectangle { - id:Button + id: button ... property color buttonColor: "lightblue" diff --git a/doc/src/getting-started/installation.qdoc b/doc/src/getting-started/installation.qdoc index a68310c..aa10aaf 100644 --- a/doc/src/getting-started/installation.qdoc +++ b/doc/src/getting-started/installation.qdoc @@ -684,7 +684,7 @@ Binary Package} document. We hope you will enjoy using Qt. */ -/*! \page install-Symbian-linux.html +/*! \page install-symbian-linux.html \title Installing Qt for the Symbian platform using Linux (experimental) \ingroup installation \ingroup qtsymbian diff --git a/doc/src/images/declarative-qmlfocus1.png b/doc/src/images/declarative-qmlfocus1.png Binary files differnew file mode 100644 index 0000000..317b34b --- /dev/null +++ b/doc/src/images/declarative-qmlfocus1.png diff --git a/doc/src/images/declarative-qmlfocus2.png b/doc/src/images/declarative-qmlfocus2.png Binary files differnew file mode 100644 index 0000000..e3f9643 --- /dev/null +++ b/doc/src/images/declarative-qmlfocus2.png diff --git a/doc/src/images/declarative-qmlfocus3.png b/doc/src/images/declarative-qmlfocus3.png Binary files differnew file mode 100644 index 0000000..a5897ce --- /dev/null +++ b/doc/src/images/declarative-qmlfocus3.png diff --git a/doc/src/images/declarative-qmlfocus4.png b/doc/src/images/declarative-qmlfocus4.png Binary files differnew file mode 100644 index 0000000..f2e64cd --- /dev/null +++ b/doc/src/images/declarative-qmlfocus4.png diff --git a/doc/src/images/declarative-qmlfocus5.png b/doc/src/images/declarative-qmlfocus5.png Binary files differnew file mode 100644 index 0000000..ec7307b --- /dev/null +++ b/doc/src/images/declarative-qmlfocus5.png diff --git a/doc/src/network-programming/bearermanagement.qdoc b/doc/src/network-programming/bearermanagement.qdoc index 98de5bf..12da55b 100644 --- a/doc/src/network-programming/bearermanagement.qdoc +++ b/doc/src/network-programming/bearermanagement.qdoc @@ -26,11 +26,11 @@ ****************************************************************************/ /*! - \page bearer-management.html +\page bearer-management.html - \title Bearer Management - \ingroup qt-network - \brief An API to control the system's connectivity state. +\title Bearer Management +\ingroup qt-network +\brief An API to control the system's connectivity state. Bearer Management controls the connectivity state of the system so that the user can start or stop interfaces or roam transparently between diff --git a/doc/src/platforms/platform-notes.qdoc b/doc/src/platforms/platform-notes.qdoc index 177d3f6..b745867 100644 --- a/doc/src/platforms/platform-notes.qdoc +++ b/doc/src/platforms/platform-notes.qdoc @@ -81,14 +81,11 @@ \header \o \o Concurrent \o XmlPatterns \o WebKit(*) \o CLucene \o Phonon \row \o g++ 3.3 \o \o \bold{X} \o \o \bold{X} \o \bold{X} \row \o g++ 3.4 and up \o \bold{X} \o \bold{X} \o \bold{X} \o \bold{X} \o \bold{X} - \row \row \o SunCC 5.5 \o \o \o \o \bold{X} \o \bold{X} - \row \row \o aCC series 3 \o \o \o \o \bold{X} \o \bold{X} \row \o aCC series 6 \o \bold{X} \o \bold{X} \o \bold{X} \o \bold{X} \o \bold{X} \row \o xlC 6 \o \o \o \o \bold{X} \o \bold{X} \row \o Intel CC 10 \o \bold{X} \o \bold{X} \o \bold{X} \o \bold{X} \o \bold{X} - \row \row \o MSVC 2003 \o \bold{X} \o \bold{X} \o \o \bold{X} \o \bold{X} \row \o MSVC 2005 and up \o \bold{X} \o \bold{X} \o \bold{X} \o \bold{X} \o \bold{X} \endtable diff --git a/doc/src/qt-webpages.qdoc b/doc/src/qt-webpages.qdoc index 05817df..0a03157 100644 --- a/doc/src/qt-webpages.qdoc +++ b/doc/src/qt-webpages.qdoc @@ -201,11 +201,6 @@ */ /*! - \externalpage http://labs.qt.nokia.com/gitweb?p=qtestlib-tools;a=summary - \title qtestlib-tools -*/ - -/*! \externalpage http://qt.nokia.com/products/library/modular-class-library#info_scripting \title Qt Script for Applications (QSA) */ @@ -239,3 +234,13 @@ \externalpage http://get.qt.nokia.com/nokiasmartinstaller/ \title Smart Installer */ + +/*! + \externalpage http://qt.gitorious.org/qt-labs/qtestlib-tools + \title qtestlib-tools +*/ + +/*! + \externalpage http://labs.qt.nokia.com + \title Qt Labs +*/ diff --git a/doc/src/qt4-intro.qdoc b/doc/src/qt4-intro.qdoc index 62decbb..7325e27 100644 --- a/doc/src/qt4-intro.qdoc +++ b/doc/src/qt4-intro.qdoc @@ -60,7 +60,53 @@ \section1 Recent Additions to Qt 4 - The following features have been added to Qt since the first release of Qt 4: + The following features have been added to Qt since the first release of Qt 4. + + In Qt 4.7: + \list + \o Declarative UI Development with \l{Qt Quick}, technologies for creating + fluid, dynamic user interfaces. + \o Support for \l{Bearer Management}{network bearer management}, enabling + features such as control over network interfaces and support for roaming + between networks. + \o Feature and performance improvements in QtWebKit, including a new tiled + backing store, control over scroll bars used in frames and framesets, + accelerated compositing and \l{The QtWebKit Bridge}{support for hybrid + development}. + \o General performance improvements, including the use of "alien widgets" + on Mac OS X, the QStaticText class for optimized text rendering, a new + \l{QPainter::drawPixmapFragments()}{API for rendering pixmap fragments} + and an updated version of the JavaScriptCore engine for the QtScript + module with improved performance. + \endlist + + In Qt 4.6: + \list + \o Support for \l{The Symbian platform - Introduction to Qt}{the Symbian Platform} + as a mainstream Qt platform, with integration into the S60 framework. + \o The \l{The Animation Framework}{animation framework} allows animations to be + created using both widgets and graphics items. + \o The \l{The State Machine Framework}{state machine framework} provides a robust + state chart implementation based on Harel statecharts and SCXML. + \o Support for \l{QTouchEvent}{touch input} and \l{Gestures Programming}{gestures} + enable developers to create intuitive user interfaces for touch-based devices. + \o A \l{QWebElement}{DOM access API} for QtWebKit provides a cleaner and safer way + to access elements and structures of Web pages without the use of JavaScript. + \o A collection of performance improvements, covering QGraphicsView, QPixmapCache, + QNetworkAccessManager, QContiguousCache class, hardware-accelerated rendering + support through \l{OpenVG Rendering in Qt}{OpenVG}, and the removal of Win9x + support. + \o A collection of \l{QGraphicsEffect}{graphics effects} make it easy to apply + and simple effects to graphics items and combine them to produce more complex + effects. + \o Support for XML schema validation in the QtXmlPatterns module covering + large parts of version 1.0 of the specification. + \o Qt3D enablers, including math primitives for \l{QMatrix4x4}{matrix multiplication}, + \l{QVector3D}{vectors}, \l{QQuaternion}{quaternions} (client-side), and an API + for \l{QGLShader}{vertex and fragment shaders}, GLSL/ES. + \o \l{QtMultimedia Module}{Multimedia services} providing low-level access to the + system's audio system. + \endlist In Qt 4.5: \list @@ -209,7 +255,7 @@ \row \o \l{Qt3Support} \o Qt 3 support classes \row \o \l{QAxContainer} \o ActiveQt client extension \row \o \l{QAxServer} \o ActiveQt server extension - \row \o \l{QtHelp} \o Classes for integrating online documentation + \row \o \l{QtHelp} \o Classes for integrating online documentation \row \o \l{QtDesigner} \o Classes for extending and embedding Qt Designer \row \o \l{QtUiTools} \o Classes for dynamic GUI generation \row \o \l{QtTest} \o Tool classes for unit testing @@ -451,7 +497,7 @@ A list of other Qt 4 features can be found on the \bold{\l{What's New in Qt 4}} page. - \section1 Declarative UI development with Qt Quick + \section1 Declarative UI Development with Qt Quick \image quick_screens.png @@ -508,7 +554,7 @@ For hybrid QtWebKit and C++ projects, Qt 4.7 has added support for transporting \l{QPixmap}s between Qt C++ and WebKit. We have also - improved the documentation hybrid development. Read more here: + improved the documentation for hybrid development. Read more here: \l{The QtWebKit Bridge}. \section1 QtWebKit Performance Benchmarks @@ -680,7 +726,7 @@ See the QTouchEvent class documentation for more information on touch input and QGestureEvent for gestures. - \section1 DOM access API + \section1 DOM Access API Web pages and XML both have very complex document object models. The W3C selector API provides a very simple way to access and @@ -699,7 +745,7 @@ \list \o Rewritten the QGraphicsView rendering algorithm. - \o Made QPixmapCache support efficient Key datastructure. + \o Made QPixmapCache support efficient Key data structure. \o Reduced overhead in QNetworkAccessManager. \o Added the QContiguousCache class, which provides efficient caching of contiguous data. @@ -740,7 +786,7 @@ See the \l{XML Processing} and QXmlSchema class documentation for more information. - \section1 Qt3D enablers + \section1 Qt3D Enablers As more of Qt, and more of the applications built on Qt go 3D, API's should be provided to simplify this. Mainly, the new API @@ -750,7 +796,7 @@ The main features of the Qt3D enablers are currently: Math primitives for matrix multiplication, vectors, quaternions - (client-side), and API for vertex and fragment shaders, GLSL/ES. + (client-side), and an API for vertex and fragment shaders, GLSL/ES. Future research will, among other things include stencils, scissors, vertex buffers and arrays, texture manipulation, and geometry shaders. diff --git a/doc/src/snippets/declarative/codingconventions/private.qml b/doc/src/snippets/declarative/codingconventions/private.qml new file mode 100644 index 0000000..1d3dda8 --- /dev/null +++ b/doc/src/snippets/declarative/codingconventions/private.qml @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 1.0 + +//! [0] +Item { + id: component + width: 40; height: 50 + property real __area: width * height * 0.5 //not meant for outside use +} +//! [0] diff --git a/doc/src/snippets/declarative/comments.qml b/doc/src/snippets/declarative/comments.qml index a8e47ad..97659a5 100644 --- a/doc/src/snippets/declarative/comments.qml +++ b/doc/src/snippets/declarative/comments.qml @@ -38,7 +38,6 @@ ** ****************************************************************************/ -//![0] import QtQuick 1.0 //![0] diff --git a/doc/src/snippets/declarative/focus/advancedFocus.qml b/doc/src/snippets/declarative/focus/advancedFocus.qml new file mode 100644 index 0000000..274f54f --- /dev/null +++ b/doc/src/snippets/declarative/focus/advancedFocus.qml @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the FOO module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 1.0 + +//! [FocusScope delegate] +Rectangle { + color: "lightsteelblue"; width: 100; height: 50 + + ListView { + anchors.fill: parent + focus: true + + model: ListModel { + ListElement { name: "Bob" } + ListElement { name: "John" } + ListElement { name: "Michael" } + } + + delegate: FocusScope { + width: childrenRect.width; height: childrenRect.height + x:childrenRect.x; y: childrenRect.y + TextInput { + focus: true + text: name + Keys.onReturnPressed: console.log(name) + } + } + } +} +//! [FocusScope delegate] diff --git a/doc/src/snippets/declarative/focus/basicwidget.qml b/doc/src/snippets/declarative/focus/basicwidget.qml new file mode 100644 index 0000000..71e75ff --- /dev/null +++ b/doc/src/snippets/declarative/focus/basicwidget.qml @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the FOO module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 1.0 + +//! [focus true] +Rectangle { + color: "lightsteelblue"; width: 240; height: 25 + Text { id: myText } + Item { + id: keyHandler + focus: true + Keys.onPressed: { + if (event.key == Qt.Key_A) + myText.text = 'Key A was pressed' + else if (event.key == Qt.Key_B) + myText.text = 'Key B was pressed' + else if (event.key == Qt.Key_C) + myText.text = 'Key C was pressed' + } + } +} +//! [focus true] diff --git a/doc/src/snippets/declarative/focus/clickablewidget.qml b/doc/src/snippets/declarative/focus/clickablewidget.qml new file mode 100644 index 0000000..34b0d87 --- /dev/null +++ b/doc/src/snippets/declarative/focus/clickablewidget.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the FOO module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 1.0 + +//! [clickable window] +Rectangle { + id: window + + color: "white"; width: 240; height: 150 + + Column { + anchors.centerIn: parent; spacing: 15 + + MyClickableWidget { + focus: true //set this MyWidget to receive the focus + color: "lightblue" + } + MyClickableWidget { + color: "palegreen" + } + } + +} +//! [clickable window] diff --git a/doc/src/snippets/declarative/focus/focusColumn.qml b/doc/src/snippets/declarative/focus/focusColumn.qml new file mode 100644 index 0000000..eb59309 --- /dev/null +++ b/doc/src/snippets/declarative/focus/focusColumn.qml @@ -0,0 +1,25 @@ +import QtQuick 1.0 + +Rectangle { + width: 200; height: 200 + + // Column { + FocusScope { + x: rect1.x; y:rect1.y; width: rect1.width; height: rect1.height + Rectangle {id: rect1; width: 50; height: 50; focus:true + color: focus ? "red":"blue" + } + Rectangle {id: rect2; width: 50; height: 50; focus:true + color: focus ? "red":"blue" + y: 75 + } +// } +/* + FocusScope { + x: rect2.x; y:rect2.y; width: rect2.width; height: rect2.height + Rectangle {id: rect2; width: 50; height: 50; color: "red"} + } +*/ + } + +} diff --git a/doc/src/snippets/declarative/focus/focusscopewidget.qml b/doc/src/snippets/declarative/focus/focusscopewidget.qml new file mode 100644 index 0000000..48e5750 --- /dev/null +++ b/doc/src/snippets/declarative/focus/focusscopewidget.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the FOO module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 1.0 + +//! [focusscope window] +Rectangle { + id: window + + color: "white"; width: 240; height: 150 + + Column { + anchors.centerIn: parent; spacing: 15 + + MyFocusScopeWidget { + focus: true //set this MyWidget to receive the focus + color: "lightblue" + } + MyFocusScopeWidget { + color: "palegreen" + } + } + +} +//! [focusscope window] diff --git a/doc/src/snippets/declarative/focus/myclickablewidget.qml b/doc/src/snippets/declarative/focus/myclickablewidget.qml new file mode 100644 index 0000000..3294662 --- /dev/null +++ b/doc/src/snippets/declarative/focus/myclickablewidget.qml @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the FOO module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 1.0 + +//! [clickable in focusscope] +FocusScope { + + id: scope + + //FocusScope needs to bind to visual properties of the children + property alias color: rectangle.color + x: rectangle.x; y: rectangle.y + width: rectangle.width; height: rectangle.height + + Rectangle { + id: rectangle + anchors.centerIn: parent + color: "lightsteelblue"; width: 175; height: 25; radius: 10; smooth: true + Text { id: label; anchors.centerIn: parent } + focus: true + Keys.onPressed: { + if (event.key == Qt.Key_A) + label.text = 'Key A was pressed' + else if (event.key == Qt.Key_B) + label.text = 'Key B was pressed' + else if (event.key == Qt.Key_C) + label.text = 'Key C was pressed' + } + } + MouseArea { anchors.fill: parent; onClicked: { scope.focus = true } } +} +//! [clickable in focusscope] diff --git a/doc/src/snippets/declarative/focus/myfocusscopewidget.qml b/doc/src/snippets/declarative/focus/myfocusscopewidget.qml new file mode 100644 index 0000000..231ae3a --- /dev/null +++ b/doc/src/snippets/declarative/focus/myfocusscopewidget.qml @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the FOO module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 1.0 + +//! [widget in focusscope] +FocusScope { + + //FocusScope needs to bind to visual properties of the children + property alias color: rectangle.color + x: rectangle.x; y: rectangle.y + width: rectangle.width; height: rectangle.height + + Rectangle { + id: rectangle + anchors.centerIn: parent + color: "lightsteelblue"; width: 175; height: 25; radius: 10; smooth: true + Text { id: label; anchors.centerIn: parent } + focus: true + Keys.onPressed: { + if (event.key == Qt.Key_A) + label.text = 'Key A was pressed' + else if (event.key == Qt.Key_B) + label.text = 'Key B was pressed' + else if (event.key == Qt.Key_C) + label.text = 'Key C was pressed' + } + } +} +//! [widget in focusscope] diff --git a/doc/src/snippets/declarative/focus/mywidget.qml b/doc/src/snippets/declarative/focus/mywidget.qml new file mode 100644 index 0000000..bea723d --- /dev/null +++ b/doc/src/snippets/declarative/focus/mywidget.qml @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the FOO module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 1.0 + +//! [mywidget] +//MyWidget code +Rectangle { + id: widget + color: "lightsteelblue"; width: 175; height: 25; radius: 10; smooth: true + Text { id: label; anchors.centerIn: parent} + focus: true + Keys.onPressed: { + if (event.key == Qt.Key_A) + label.text = 'Key A was pressed' + else if (event.key == Qt.Key_B) + label.text = 'Key B was pressed' + else if (event.key == Qt.Key_C) + label.text = 'Key C was pressed' + } +} +//! [mywidget] diff --git a/doc/src/snippets/declarative/focus/qmldir b/doc/src/snippets/declarative/focus/qmldir new file mode 100644 index 0000000..d0683b2 --- /dev/null +++ b/doc/src/snippets/declarative/focus/qmldir @@ -0,0 +1,4 @@ +MyWidget 1.0 mywidget.qml +MyFocusScopeWidget 1.0 myfocusscopewidget.qml +MyClickableWidget 1.0 myclickablewidget.qml + diff --git a/doc/src/snippets/declarative/focus/rectangle.qml b/doc/src/snippets/declarative/focus/rectangle.qml new file mode 100644 index 0000000..01d1f0c --- /dev/null +++ b/doc/src/snippets/declarative/focus/rectangle.qml @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the FOO module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 1.0 + +//! [simple key event] +Rectangle { + width: 100; height: 100 + focus: true + Keys.onPressed: { + if (event.key == Qt.Key_A) { + console.log('Key A was pressed'); + event.accepted = true; + } + } +//! [simple key event] + +//! [active focus] + Text { + text: activeFocus ? "I have active focus!" : "I do not have active focus" + } +//! [active focus] + +//! [simple key event end] +} +//! [simple key event end] diff --git a/doc/src/snippets/declarative/focus/widget.qml b/doc/src/snippets/declarative/focus/widget.qml new file mode 100644 index 0000000..cef34c5 --- /dev/null +++ b/doc/src/snippets/declarative/focus/widget.qml @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the FOO module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:BSD$ +** You may use this file under the terms of the BSD license as follows: +** +** "Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are +** met: +** * Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in +** the documentation and/or other materials provided with the +** distribution. +** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor +** the names of its contributors may be used to endorse or promote +** products derived from this software without specific prior written +** permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +** $QT_END_LICENSE$ +** +****************************************************************************/ +import QtQuick 1.0 + +//! [window] + +//Window code that imports MyWidget +Rectangle { + id: window + color: "white"; width: 240; height: 150 + + Column { + anchors.centerIn: parent; spacing: 15 + + MyWidget { + focus: true //set this MyWidget to receive the focus + color: "lightblue" + } + MyWidget { + color: "palegreen" + } + } +} +//! [window] |