diff options
Diffstat (limited to 'doc')
372 files changed, 13496 insertions, 8563 deletions
diff --git a/doc/src/classes.qdoc b/doc/src/classes.qdoc index a1b5282..90a783e 100644 --- a/doc/src/classes.qdoc +++ b/doc/src/classes.qdoc @@ -153,7 +153,7 @@ \brief A Qt namespace contains enum types, functions, and sometimes classes. - This is a list of the main namespaces in Qt. + This is a list of the main namespaces in Qt. \generatelist{namespaces} */ diff --git a/doc/src/classes/phonon-api.qdoc b/doc/src/classes/phonon-api.qdoc index c9f7a66..95e20dd 100644 --- a/doc/src/classes/phonon-api.qdoc +++ b/doc/src/classes/phonon-api.qdoc @@ -691,11 +691,11 @@ Example where data is written repeatedly. - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 0 + \snippet doc/src/snippets/code/doc_src_phonon-api.cpp 0 Example where data is written once: - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 1 + \snippet doc/src/snippets/code/doc_src_phonon-api.cpp 1 \sa Phonon::MediaSource, Phonon::MediaObject @@ -811,7 +811,7 @@ The function is necessary for the case where a non-seekable MediaStream is played more than once. For a seekable stream the implementation can simply call - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 2 + \snippet doc/src/snippets/code/doc_src_phonon-api.cpp 2 \sa writeData(), needData() */ @@ -1003,7 +1003,7 @@ send an URL or filename directly to the constructors of the \l{Phonon::}{MediaObject}. - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 3 + \snippet doc/src/snippets/code/doc_src_phonon-api.cpp 3 A MediaSource object cannot be reused for another multimedia source. It is possible to play the same source again, and also @@ -1382,7 +1382,7 @@ immediately after you call the play() function. A play and forget code example: - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 4 + \snippet doc/src/snippets/code/doc_src_phonon-api.cpp 4 \sa {Phonon Module}, MediaObject */ @@ -1471,7 +1471,7 @@ If you need low latency between calling play() and the sound actually starting to play on your output device you need to use MediaObject and be able to set the URL before calling play(). Note that - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 5 + \snippet doc/src/snippets/code/doc_src_phonon-api.cpp 5 doesn't make a difference: the application should be idle between the load and play calls so that the backend can start preloading the media and fill audio buffers. @@ -1612,13 +1612,13 @@ queue; the new source is then removed from the queue. The queue can be altered at any time. - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 7 + \snippet doc/src/snippets/code/doc_src_phonon-api.cpp 7 You can also make use of the \l{Phonon::MediaObject::}{aboutToFinish()} signal, which is guaranteed to be emitted in time for altering the queue. - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 8 + \snippet doc/src/snippets/code/doc_src_phonon-api.cpp 8 When playback is finishing, i.e., when a media source has been played to the end and the queue is empty, several signals are @@ -1715,9 +1715,9 @@ \warning The back-end is free to choose a different tick interval close to what you asked for. This means that the following code \c may fail: - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 9 + \snippet doc/src/snippets/code/doc_src_phonon-api.cpp 9 On the other hand the following is guaranteed: - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 10 + \snippet doc/src/snippets/code/doc_src_phonon-api.cpp 10 \sa tick() */ @@ -1745,7 +1745,7 @@ media object gets a new source. Listen to the hasVideoChanged() signal instead. - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 11 + \snippet doc/src/snippets/code/doc_src_phonon-api.cpp 11 Returns \c true if the media contains video data; otherwise, returns \c false. @@ -1763,7 +1763,7 @@ media object gets a new media source. The hasVideoChanged() signal is emitted after this information is available. - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 12 + \snippet doc/src/snippets/code/doc_src_phonon-api.cpp 12 Returns \c true if the current media may be seeked; otherwise, returns \c false. @@ -1786,7 +1786,7 @@ A typical usage looks like this: - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 13 + \snippet doc/src/snippets/code/doc_src_phonon-api.cpp 13 */ /*! @@ -1867,7 +1867,7 @@ We show an example: - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 14 + \snippet doc/src/snippets/code/doc_src_phonon-api.cpp 14 \sa currentSource(), MediaSource */ @@ -2126,7 +2126,7 @@ You can use this signal to show a progress bar to the user when in BufferingState: - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 15 + \snippet doc/src/snippets/code/doc_src_phonon-api.cpp 15 Note that the \l{Phonon::}{BufferingState} is commonly used when waiting for data over a network connection, but this might not be @@ -2270,7 +2270,7 @@ happen if the user has requested a backend change. To connect to this signal do the following: - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 16 + \snippet doc/src/snippets/code/doc_src_phonon-api.cpp 16 \sa Notifier::capabilitiesChanged() */ @@ -2362,10 +2362,10 @@ An example use case would be to give the user a QComboBox to select the output device: - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 17 + \snippet doc/src/snippets/code/doc_src_phonon-api.cpp 17 And to retrieve the selected AudioOutputDevice: - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 18 + \snippet doc/src/snippets/code/doc_src_phonon-api.cpp 18 */ @@ -2565,7 +2565,7 @@ In order to use an effect, insert it into the path as follows: - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 19 + \snippet doc/src/snippets/code/doc_src_phonon-api.cpp 19 The effect will immediately begin applying it's transformations on the path. To stop it, remove the Effect from the path. @@ -3108,7 +3108,7 @@ The following code example shows how to create a path between two media nodes and insert an effect on that path. - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 20 + \snippet doc/src/snippets/code/doc_src_phonon-api.cpp 20 \sa Phonon::MediaNode, Phonon::MediaObject, Phonon::AudioOutput, Phonon::VideoWidget, {Phonon Module} @@ -4085,7 +4085,7 @@ A typical example of usage follows below: - \snippet doc/src/snippets/code/doc_src_phonon-api.qdoc 21 + \snippet doc/src/snippets/code/doc_src_phonon-api.cpp 21 \sa {Phonon Module} */ diff --git a/doc/src/declarative/anchor-layout.qdoc b/doc/src/declarative/anchor-layout.qdoc index 0655fdb..4dd5eb9 100644 --- a/doc/src/declarative/anchor-layout.qdoc +++ b/doc/src/declarative/anchor-layout.qdoc @@ -28,15 +28,16 @@ /*! \page qml-anchor-layout.html \target anchor-layout -\title Anchor-Based Layout in QML - -\section1 Overview +\contentspage QML Features +\previouspage {Using QML Positioner and Repeater Items}{Component Layouts} +\nextpage {QML Mouse Events}{Mouse Events} +\title Anchor-based Layout in QML In addition to the more traditional \l Grid, \l Row, and \l Column, QML also provides a way to layout items using the concept of \e anchors. Each item can be thought of as having a set of 7 invisible "anchor lines": \l {Item::anchors.left}{left}, \l {Item::anchors.horizontalCenter}{horizontalCenter}, -\l {Item::anchors.right}{right}, \l {Item::anchors.top}{top}, +\l {Item::anchors.right}{right}, \l {Item::anchors.top}{top}, \l {Item::anchors.verticalCenter}{verticalCenter}, \l {Item::anchors.baseline}{baseline}, and \l {Item::anchors.bottom}{bottom}. diff --git a/doc/src/declarative/animation.qdoc b/doc/src/declarative/animation.qdoc index 59bf8f6..129fa34 100644 --- a/doc/src/declarative/animation.qdoc +++ b/doc/src/declarative/animation.qdoc @@ -27,308 +27,214 @@ /*! \page qdeclarativeanimation.html -\title QML Animation +\ingroup qml-features +\contentspage QML Features +\previouspage {QML States}{States} +\nextpage {QML Data Models}{Structuring Data with Models} +\title QML Animation and Transitions + +\keyword qml-animation-elements +\section1 Animation and Transitions Elements +\list +\o \l {Transition} - Animates transitions during state changes +\o \l {SequentialAnimation} - Runs animations sequentially +\o \l {ParallelAnimation} - Runs animations in parallel +\o \l {Behavior} - Specifies a default animation for property changes +\o \l {PropertyAction} - Sets immediate property changes during animation +\o \l {PauseAnimation} - Introduces a pause in an animation +\o \l {SmoothedAnimation} - Allows a property to smoothly track a value +\o \l {SpringAnimation} - Allows a property to track a value in a spring-like motion +\o \l {ScriptAction} - Runs scripts during an animation +\endlist +\keyword qml-property-animation-elements +Elements that animate properties based on data types +\list +\o \l {PropertyAnimation} - Animates property changes +\o \l {NumberAnimation} - Animates properties of type qreal +\o \l {Vector3dAnimation} - Animates properties of type QVector3d +\o \l {ColorAnimation} - Animates color changes +\o \l {RotationAnimation} - Animates rotations +\o \l {ParentAnimation} - Animates parent changes +\o \l {AnchorAnimation} - Animates anchor changes +\endlist -In QML, animations are created by applying animation objects to object property -values to gradually change them over time. Animation objects are created from -the built-in set of animation elements, which can be used to animate various -types of property values. In addition, animation objects can be applied in -different ways depending on the context in which they are required. +In QML, animations are created by applying animation elements to property +values. Animation elements will interpolate property values to create smooth +transitions. As well, state transitions may assign animations to state changes. To create an animation, use an appropriate animation element for the type of the property that is to be animated, and apply the animation depending on the -type of behavior that is required. This page describes the \l {Types of -Animations} that can be created and the \l {Animation Elements} that are used -to create these animations. - - -\section1 Types of Animations - -An animation is created in different ways depending on the context in which it -is required. Suppose a \l Rectangle's movement - that is, changes in its \c x -or \c y property values - should be animated. The semantics of the animation -differ depending on whether you want to create: - -\list -\o An animation that moves the \l Rectangle as soon as it is created, to a -known position -\o An animation that only triggers when the \l Rectangle is moved by external -sources - for example, when the mouse is clicked, animate the movement to the -mouse position -\o An animation that triggers when a particular signal is received -\o A standalone animation that is not bound to the \l Rectangle's movement, but -instead can be started and stopped from script as required -\o An animation that only triggers during \l{QML States}{state changes} -\endlist +type of behavior that is required. -To support these different types of animation methods, QML provides several -methods for defining an animation. These are: +\keyword qml-triggering-animations +\section1 Triggering Animations -\list -\o Creating an \l{Animations as Property Value Sources}{animation using -property value sources}, to immediately animate a specific property -\o Using \l{Behavioral Animations}{behavioral animations}, which are triggered -when a property changes value -\o \l{Animations in a Signal Handler}{Within a signal handler}, to be triggered -when a signal is received -\o As a \l{Standalone Animation}{standalone animation}, that can be -started/stopped from script and can be rebound to different objects -\o Using \l{Transitions}{transitions}, to provide animations between \l{QML -States}{state changes} -\endlist +There are several ways of setting animation to an object. -These methods are demonstrated below. Notice these examples use -PropertyAnimation, which is one of several QML elements that can be used to -create an animation. See the \l {Animation Elements} section further below for -details. +\keyword qml-direct-animation +\section2 Direct Property Animation +To create an immediate movement or animated movement, set the property value +directly. This may be done in signal handlers or attached properties. +\snippet doc/src/snippets/declarative/animation.qml direct property change -\section2 Animations as Property Value Sources +However, to create more control, \e {property animations} apply smooth movements +by interpolating values between property value changes. Property animations +provide timing controls and allows different interpolations through +\l{qml-easing-animation}{easing curves}. -An animation is applied as a \l{QDeclarativePropertyValueSource}{property value -source} using the \e Animation \bold on \e Property syntax. Here is a \l -Rectangle whose movement is animated using this method: +\snippet doc/src/snippets/declarative/animation.qml property animation -\snippet doc/src/snippets/declarative/animation-propertyvaluesource.qml 0 - -This applies a PropertyAnimation to the \l Rectangle's \c x and \c y properties -to animate from their current values (i.e. zero) to 50, over 1000 milliseconds. -The animation starts as soon as the \l Rectangle is loaded. To animate from -specific values rather than the current \c x and \c y values, set the -PropertyAnimation's \l {PropertyAnimation::}{from} property. - -Specifying an animation as a property value source is useful for animating a -property to a particular value as soon as the object is loaded. - - -\section2 Behavioral Animations - -Often an animation should be applied whenever a particular property value -changes. In these cases, a \l Behavior can be used to specify a default -animation for a property change. Here is an example: - -\snippet doc/src/snippets/declarative/animation-behavioral.qml 0 - -This \l Rectangle has \l Behavior objects applied to its \c x and \c y -properties. Whenever these properties change (in this case, when the mouse is -clicked within the parent \l Item), the PropertyAnimation objects defined -within the behaviors will be applied to these properties, thus animating the \l -Rectangle's movement to its new position. Unlike the method of \l {Animations -as Property Value Sources}{defining an animation as a property value source}, -which creates a one-time animation that animates a property to a known value, a -behavioral animation is an animation that is triggered \e {in response to} a -value change. - -Any changes to these properties will trigger their animations. If \c x or \c y -were bound to other properties, and those properties changed, the animation -would be triggered. The \l{Behavior::}{enabled} property can be used to force a -\l Behavior to only apply under certain circumstances. - -Notice that unlike for property value source animations, the -PropertyAnimation's \l {PropertyAnimation::}{from} and \l -{PropertyAnimation::}{to} properties do not need to be defined because these -values are already provided, respectively, by the \l Rectangle's current values -and the new values set in the \c onClicked handler. If these properties were -defined anyway, they would override the default values. +Specialized \l{qml-property-animation-elements}{property animation elements} +have more efficient implementations than the \l{PropertyAnimation} element. They +are for setting animations to different QML types such as \c int, \c color, and +rotations. Similarly, the \l{ParentAnimation} can animate parent changes. -See the \l {declarative/animation/behaviors}{Behaviors example} for a -demonstration of behavioral animations. +See the \l {qml-controlling-animations}{Controlling Animations} section for more +information about the different animation properties. +\keyword qml-transition-animations +\section2 Transitions during State Changes -\section2 Animations in a Signal Handler +\l{QML States}{States} are property configurations where a property may have different values to reflect different states. State changes introduce +abrupt property changes; animations smooth transitions to produce visually +appealing state changes. -An animation can be created within a signal handler to be triggered when the -signal is received. For example: - -\snippet doc/src/snippets/declarative/animation-signalhandler.qml 0 +The \l{Transition} element can contain +\l{qml-animation-elements}{animation elements} to interpolate property changes +caused by state changes. To assign the transition to an object, bind it to the +\c transitions property. -The PropertyAnimation is triggered when the MouseArea is clicked, animating the -\c x and \c y properties to a value of 50 over 1000 milliseconds. Since the -animation is not bound to a particular object or property, it must define the -\l {PropertyAnimation::}{target} and \l {PropertyAnimation::}{property} (or \l -{PropertyAnimation::}{targets} and \l{PropertyAnimation::}{properties}) values. -The \l {PropertyAnimation::}{to} property is also required to specify the new -\c x and \c y values. +A button might have two states, the \c pressed state when the user clicks on the +button and a \c released state when the user releases the button. We can assign +different property configurations for each state. A transition would animate the +change from the \c pressed state to the \c released state. Likewise, there would +be an animation during the change from the \c released state to the \c pressed +state. +\snippet doc/src/snippets/declarative/animation.qml transition animation -\section2 Standalone Animations +Binding the \c to and \c from properties to the state's name will assign that +particular transition to the state change. For simple or symmetric transitions, +setting the to \c to property to the wild card symbol, "\c{*}", denotes +that the transition applies to any state change. -Animations can also be created as ordinary QML objects that are not bound to -any particular objects and properties. Here is an example, using a -PropertyAnimation object. The animation is explicitly started when the -\l Rectangle is clicked: +\snippet doc/src/snippets/declarative/animation.qml wildcard animation -\snippet doc/src/snippets/declarative/animation-standalone.qml 0 +\section2 Default Animation as Behaviors -A standalone animation object is not running by default and must be started explicitly -using the \l {Animation::}{running} property or \l {Animation::}{start()} and -\l {Animation::}{stop()} methods. Since the animation is not bound to a -particular object or property, it must define the \l -{PropertyAnimation::}{target} and \l {PropertyAnimation::}{property} (or \l -{PropertyAnimation::}{targets} and \l{PropertyAnimation::}{properties}) values. -The \l {PropertyAnimation::}{to} property is also required to specify the new -\c x and \c y values. (The \l {PropertyAnimation::}{from} value can optionally -be provided.) +Default property animations are set using \e {behavior animations}. Animations +declared in \l {Behavior} elements apply to the property and animates any +property value changes. However, Behavior elements have an +\c enabled property to purposely enable or disable the behavior animations. -Standalone animations are useful when an animation is not targeted towards a -single object property and the animation should be explicitly started and -stopped. +A ball component might have a behavior animation assigned to its \c x, \c y, and +\c color properties. The behavior animation could be set up to simulate an +elastic effect. In effect, this behavior animation would apply the elastic +effect to the properties whenever the ball moves. +\snippet doc/src/snippets/declarative/animation.qml behavior animation -\section2 Transitions +There are several methods of assigning behavior animations to properties. The +\c{Behavior on <property>} declaration is a convenient way of assigning a +behavior animation onto a property. -Transitions are used to describe the animations to be applied when a \l {QML -States}{state change} occurs. To create a transition, define a \l Transition -object and add it to an item's \l {Item::}{transitions} property. An example: +See the \l {declarative/animation/behaviors}{Behaviors example} for a +demonstration of behavioral animations. -\snippet doc/src/snippets/declarative/animation-transitions.qml 0 +\section1 Playing Animations in Parallel or in Sequence -The PropertyChanges object in the \e moved state defines that when the -\l Rectangle is in this state, its position should be changed -to (50, 50). When the \l Rectangle changes to the \e moved state, the -\l Transition will be triggered, and the transition's \l PropertyAnimation will -animate the changes in the \c x and \c y properties to their new values. -The animation will not be applied at any time other than during the state -change. +Animations can run \e {in parallel} or \e {in sequence}. Parallel animations +will play a group of animations at the same time while sequential animations +play a group of animations in order: one after the other. Grouping animations in +\l{SequentialAnimation} and \l{ParallelAnimation} will play the animations in +sequence or in parallel. -Notice the example does not set any \l {PropertyAnimation::}{from} and \l -{PropertyAnimation::}{to} values for the PropertyAnimation. As a convenience, -these properties are automatically set to the values of \c x and \c y before -and after the state change, respectively. However, they can be explicitly set -if these values should be overrided. +A banner component may have several icons or slogans to display, one after the +other. The \c opacity property could transform to \c 1.0 denoting an opaque +object. Using the \l{SequentialAnimation} element, the opacity animations will +play after the preceding animation finishes. The \l{ParallelAnimation} element +will play the animations at the same time. -Also notice the PropertyAnimation does not need to specify a \l -{PropertyAnimation::}{target} object; any \c x or \c y value of any object that -has changed during the state change will be animated. However, the target can -be set if the animation should be restricted to certain objects. +\snippet doc/src/snippets/declarative/animation.qml sequential animation -The top-level animations in a \l Transition are run in parallel. To run them -one after the other, use a SequentialAnimation, as shown below in \l {Grouping -Animations}. +Once individual animations are placed into a SequentialAnimation or +ParallelAnimation, they can no longer be started and stopped independently. The +sequential or parallel animation must be started and stopped as a group. -See the \l Transition documentation for more information. +The \l SequentialAnimation element is also useful for playing +\l{qml-transition-animations}{transition animations} because animations are +played in parallel inside transitions. +See the \l {declarative/animation/basics}{Animation basics example} for a +demonstration of creating and combining multiple animations in QML. -\section1 Animation Elements +\keyword qml-controlling-animations +\section1 Controlling Animations -To create an animation, choose from one of the built-in QML animation elements. -While the above examples are demonstrated using PropertyAnimation, they could -have used other elements depending on the type of the property to be animated -and whether a single or multiple animations are required. +There are different methods to control animations. -All animation elements inherit from the \l Animation element. It is not +\section2 Animation Playback +All \l{qml-animation-elements}{animation elements} inherit from the \l Animation element. It is not possible to create \l Animation objects; instead, this element provides the -essential properties and methods for animation elements. For example, it allows -animations to be started and stopped through the \l {Animation::}{running} -property and the \l{Animation::}{start()} and \l{Animation::}{stop()} methods. -It can also define the number of \l {Animation::}{loops} for an animation. +essential properties and methods for animation elements. Animation elements have +\c{start()}, \c{stop()}, \c{resume()}, \c{pause()}, \c {restart()}, and +\c{complete()} -- all of these methods control the execution of animations. +\keyword qml-easing-animation +\section2 Easing -\section2 Property Animation Elements +Easing curves define how the animation will interpolate between the start value +and the end value. Different easing curves might go beyond the defined range of +interpolation. The easing curves simplify the creation of animation effects such +as bounce effects, acceleration, deceleration, and cyclical animations. -PropertyAnimation is the most basic animation element for animating a property. -It can be used to animate \c real, \c int, \c color, \c rect, \c point, \c size, and -\c vector3d properties. It is inherited by NumberAnimation, ColorAnimation, -RotationAnimation and Vector3dAnimation: NumberAnimation provides a more -efficient implementation for animating \c real and \c int properties, and -Vector3dAnimation does the same for \c vector3d properties. ColorAnimation -and RotationAnimation provide more specific attributes for animating color -and rotation changes. +A QML object may have different easing curve for each property animation. There +are also different parameters to control the curve, some of which are exclusive +to a particular curve. For more information about the easing curves, visit the +\l {PropertyAnimation::easing.type}{easing} documentation. -A ColorAnimation allows color values for the \l {ColorAnimation::}{from} -and \l {ColorAnimation::}{to} properties. The -following animates the rectangle's \l {Rectangle::}{color} property: - -\snippet doc/src/snippets/declarative/animation-elements.qml color +The \l{declarative/animation/easing}{easing example} visually demonstrates each +of the different easing types. -RotationAnimation allows a rotation's direction to be specified. The following -animates the rectangle's \l {Item::rotation} property: +\section2 Other Animation Elements -\snippet doc/src/snippets/declarative/animation-elements.qml rotation +In addition, QML provides several other elements useful for animation: -In addition, the following specialized animation elements are available: +\list +\o PauseAnimation: enables pauses during animations +\o ScriptAction: allows JavaScript to be executed during an animation, and can +be used together with StateChangeScript to reused existing scripts +\o PropertyAction: changes a property \e immediately during an animation, +without animating the property change +\endlist +These are specialized animation elements that animate different property types \list -\o SmoothedAnimation: a specialized NumberAnimation that provides smooth +\o SmoothedAnimation: a specialized NumberAnimation that provides smooth changes in animation when the target value changes -\o SpringAnimation: provides a spring-like animation with specialized -attributes such as \l {SpringAnimation::}{mass}, +\o SpringAnimation: provides a spring-like animation with specialized +attributes such as \l {SpringAnimation::}{mass}, \l{SpringAnimation::}{damping} and \l{SpringAnimation::}{epsilon} \o ParentAnimation: used for animating a parent change (see ParentChange) \o AnchorAnimation: used for animating an anchor change (see AnchorChanges) \endlist -See their respective documentation pages for more details. - - -\section3 Easing - -Any PropertyAnimation-based animations can specify \l -{PropertyAnimation::easing.type}{easing attributes} to control the -easing curve applied when a property value is animated. These control the -effect of the animation on the property value, to provide visual effects like -bounce, acceleration and deceleration. - -For example, this modified version of an \l {Animations as Property Value -Sources}{earlier example} uses \c Easing.OutBounce to create a bouncing effect -when the animation reaches its target value: - -\snippet doc/src/snippets/declarative/animation-easing.qml 0 - -The \l{declarative/animation/easing}{easing example} visually demonstrates each -of the different easing types. +*/ -\section2 Grouping Animations -Multiple animations can be combined into a single animation using one of the -animation group elements: ParallelAnimation or SequentialAnimation. As their -names suggest, animations in a ParallelAnimation are run at the same time, -while animations in a SequentialAnimation are run one after the other. -To run multiple animations, define the animations within an animation group. -The following example creates a SequentialAnimation that runs three animations -one after the other: a NumberAnimation, a PauseAnimation and another -NumberAnimation. The SequentialAnimation is applied as a \l{Animations as -Property Value Sources}{property value source animation} on the image's \c y -property, so that the animation starts as soon as the image is loaded, moving -the image up and down: +\snippet doc/src/snippets/declarative/animation-elements.qml color +\snippet doc/src/snippets/declarative/animation-propertyvaluesource.qml 0 +\snippet doc/src/snippets/declarative/animation-signalhandler.qml 0 +\snippet doc/src/snippets/declarative/animation-standalone.qml 0 +\snippet doc/src/snippets/declarative/animation-transitions.qml 0 \snippet doc/src/snippets/declarative/animation-groups.qml 0 -\image propanim.gif - -Since the SequentialAnimation is applied to the \c y property, the individual -animations within the group are automatically applied to the \c y property as -well; it is not required to set their \l{PropertyAnimation::}{properties} -values to a particular property. - -Animation groups can be nested. Here is a rather complex animation making use -of both sequential and parallel animations: \snippet doc/src/snippets/declarative/animation-groups.qml 1 +\snippet doc/src/snippets/declarative/animation-groups.qml 0 +\image propanim.gif -Once individual animations are placed into a SequentialAnimation or -ParallelAnimation, they can no longer be started and stopped independently. The -sequential or parallel animation must be started and stopped as a group. - -See the \l {declarative/animation/basics}{Animation basics example} for a -demonstration of creating and combining multiple animations in QML. - - - -\section2 Other Animation Elements - -In addition, QML provides several other elements useful for animation: - -\list -\o PauseAnimation: enables pauses during animations -\o ScriptAction: allows JavaScript to be executed during an animation, and can -be used together with StateChangeScript to reused existing scripts -\o PropertyAction: changes a property \e immediately during an animation, -without animating the property change -\endlist - -See their respective documentation pages for more details. - -*/ diff --git a/doc/src/declarative/basicelements.qdoc b/doc/src/declarative/basicelements.qdoc new file mode 100644 index 0000000..0146591 --- /dev/null +++ b/doc/src/declarative/basicelements.qdoc @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** 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:FDL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Free Documentation License +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of this +** file. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! +\page qmlbasicelements.html +\ingroup qml-features +\contentspage QML Features +\previouspage QML Features +\nextpage {QML Basic Types}{Data Types} + +\title QML Basic Elements + +QML's basic elements allow the easy inclusion of objects into the +scene. + +\section1 Basic Elements +This is a list of some of the elements readily available for users. +\list +\o \l {Item} +\o \l {Rectangle} +\o \l {Image} +\o \l {Text} +\o \l {TextInput} +\o \l {TextEdit} +\o \l {FocusScope} +\o \l {Component} +\o \l {MouseArea} +\endlist + +For a complete list of QML elements, please visit the \l {QML Elements} page. + +\section1 Properties and Qt Declarative Module + +When using QML elements, keep in mind that elements may possess properties that +other elements also possess. This is because QML and its underlying engine is +implemented in C++ using Qt. More importantly, the chain of property inheritance +is directly due to QML's use of the \l {Qt Declarative Module} and Qt's +\l {Meta-Object System}{meta-object} and \l {The Property System}{property} systems. For example, visual elements that have C++ implementation are sublcasses of +\l {QDeclarativeItem}. As a result, elements such as \l {Rectangle} and +\l {Text} elements inherit properties such as \c clip and \c smooth. + +\section1 Item Element + +Many QML elements inherit \l Item properties. \c Item possesses important properties +such as \c focus, \c children, and dimension properties such as \c width and +\c height. Although \c Item has physical properties, it is not a visual element. +Using \c Item as the top-level QML element (as the screen) will not produce a +visual result, use the \l {Rectangle} element instead. Use the \c Item to create +opacity effects, such as when creating an invisible container to hold other +components. + +\section1 Rectangle Element + +The \l Rectangle element is the basic visual element, for displaying different +types of items onto the screen. The \c Rectangle is customizable and utilizes +other elements such as \l Gradient and \l BorderImage for displaying advanced +customized graphics. + +\section1 Image Element + +To insert an image into a QML scene, merely declare an \l Image element. The +\c Image element can load images in formats supported by Qt. + +\section1 Text Elements + +The \l Text and \l TextEdit elements display formatted text onto the screen. +\c TextEdit features multi-line editing while the \l TextInput element is for +single line text input. + +\keyword qml-top-level-component +\section1 Using Elements as the Top-Level Component + +For creating components (or displaying a simple scene), there are different +elements that could be used as the top-level component. To display a simple scene, +a \l Rectangle as the top-level component may suffice. \l Rectangle, +\l FocusScope, \l Component, \l {QML:QtObject} {QtObject}, \l Item, are some of +the commonly used elements as the top-level component. + +When importing components, the top-level component is important because the +top-level component's properties are the only properties exposed to the parent. + +For example, a \c Button component may be implemented using different elements as +its top-level component. When this component is loaded into another QML scene, +the component will retain the top-level component's properties. If a non-visual +component is the top-level component, the visual properties should be aliased to +the top-level to display the component properly. + +For more information on how to build upon QML elements, see the +\l{Importing Reusable Components} document. +*/ diff --git a/doc/src/declarative/basictypes.qdoc b/doc/src/declarative/basictypes.qdoc index 8503f4e..4792bba 100644 --- a/doc/src/declarative/basictypes.qdoc +++ b/doc/src/declarative/basictypes.qdoc @@ -27,23 +27,26 @@ /*! \page qdeclarativebasictypes.html + \ingroup qml-features + \contentspage QML Features + \previouspage {QML Basic Elements} + \nextpage Property Binding \title QML Basic Types QML has a set of primitive types, as listed below, that are used throughout the \l {QML Elements}. - Some of these types can also be used for defining - \c property values in QML. See \l{Writing QML Components: Properties, Methods and Signals} for the - list of types that can be used for \c property values. - \annotatedlist qmlbasictypes + + To create additional types, such as data types created in C++, read the + \l{Extending QML Functionalities using C++} article. */ /*! \qmlbasictype int \ingroup qmlbasictypes - \brief An integer is a whole number, e.g. 0, 10, or -20. + \brief An integer is a whole number, e.g. 0, 10, or -20. An integer is a whole number, e.g. 0, 10, or -20. The possible \c int values range from around -2000000000 to around 2000000000, @@ -137,7 +140,7 @@ \qmlbasictype url \ingroup qmlbasictypes - \brief A URL is a resource locator, like a file name. + \brief A URL is a resource locator, like a file name. A URL is a resource locator, like a file name. It can be either absolute, e.g. "http://qt.nokia.com", or relative, e.g. @@ -150,9 +153,6 @@ Image { source: "pics/logo.png" } \endqml - \raw HTML - \endraw - \sa {QML Basic Types} */ @@ -215,7 +215,7 @@ /*! \qmlbasictype size \ingroup qmlbasictypes - + \brief A size type has width and height attributes A \c size type has \c width and \c height attributes. @@ -254,7 +254,7 @@ For example, to read the \l {Item::childrenRect.x}{Item::childrenRect} \c rect property: \qml - Rectangle { + Rectangle { width: childrenRect.width height: childrenRect.height @@ -290,7 +290,7 @@ MyDatePicker { minDate: "2000-01-01"; maxDate: "2020-12-31" } \endqml - To read a date value returned from a C++ extension class, use + To read a date value returned from a C++ extension class, use \l{QML:Qt::formatDate()}{Qt.formatDate()} and \l{QML:Qt::formatDateTime()}{Qt.formatDateTime()}. \sa {QML Basic Types} @@ -309,7 +309,7 @@ MyTimePicker { time: "14:22:15" } \endqml - To read a time value returned from a C++ extension class, use + To read a time value returned from a C++ extension class, use \l{QML:Qt::formatTime()}{Qt.formatTime()} and \l{QML:Qt::formatDateTime()}{Qt.formatDateTime()}. \sa {QML Basic Types} @@ -399,8 +399,9 @@ \c child1, \c child2 and \c child3 will be added to the children list in the order in which they appear. - List \l {Adding Properties}{properties} can be declared as \c list<Type> - type, where \c Type is the type of the object in the list: + List \l {Property Binding}{properties} can be created as a + \c variant type, or as a \c list<Type> type, where \c Type is the + type of the object in the list: \qml Item { @@ -503,7 +504,7 @@ \qml Item { - property variant attributes: { ''color': 'red', 'width': 100 } + property variant attributes: { 'color': 'red', 'width': 100 } Component.onCompleted: { // Change the value of attributes.color to 'blue': @@ -570,7 +571,7 @@ \qml Text { horizontalAlignment: "AlignRight" } \endqml - + or as \c {<Element>.<value>}: \qml Text { horizontalAlignment: Text.AlignRight } diff --git a/doc/src/declarative/declarativeui.qdoc b/doc/src/declarative/declarativeui.qdoc index 3962514..93571bd 100644 --- a/doc/src/declarative/declarativeui.qdoc +++ b/doc/src/declarative/declarativeui.qdoc @@ -31,12 +31,10 @@ \ingroup qt-gui-concepts \brief Qt Quick provides a declarative framework for building highly -dynamic, custom user interfaces. - -\section1 Introduction +dynamic user interfaces. Qt Quick is a collection of technologies that are designed to help -developers create the kind of intuitive, modern-looking, fluid user +developers create the kind of intuitive, modern, fluid user interfaces that are increasingly used on mobile phones, media players, set-top boxes and other portable devices. @@ -45,115 +43,108 @@ language for describing user interfaces and a language runtime. A collection of C++ APIs is used to integrate these high level features with classic Qt applications. -\section2 QML, Elements and the Qt Declarative Module - -User interfaces and their behavior are described using QML, an extension to -\l{About JavaScript}{JavaScript} that lets developers and designers -use a declarative syntax to specify each user interface in terms of -\l{QML Elements}{QML elements}. These elements are a sophisticated set of -graphical and behavioral building blocks that can be combined together in -\l{QML Documents}{QML documents} to build components ranging in complexity -from simple buttons and sliders, to complete Internet-enabled applications. - -QML improves the integration between JavaScript and Qt's existing -QObject-based type system, adds support for automatic -\l{Property Binding}{property bindings} and provides -\l{Network Transparency}{network transparency} at the language level. - -The Qt Declarative module implements the interface between the QML language -and the elements available to it. It also provides a C++ API that can be -used to load and interact with QML files from within Qt applications. - -Qt Quick builds on \l{QML for Qt programmers}{Qt's existing strengths}. -QML can be be used to incrementally extend an existing application or -to build completely new applications. QML is fully -\l{Extending QML in C++}{extensible from C++} through the Qt Declarative -Module. - \section1 Getting Started \list -\o \l{What's new in Qt Quick} -\o \l{Introduction to the QML language} -\o \l{QML for Qt Programmers} +\o \l{Intro to Qt Quick}{Introduction to Qt Quick} +\o \l{QML for Qt Programmers}{QML Programming for Qt Programmers} \o \l{Getting Started Programming with QML} -\o \l{Intro to Qt Quick} -\endlist -\list -\o \l{QML Tutorial}{Tutorial: "Hello World"} -\o \l{QML Advanced Tutorial}{Tutorial: "Same Game"} +\o \l{What's new in Qt Quick}{What's New in the Qt Quick Release} \o \l{QML Examples and Demos} \endlist -\section1 QML Concepts +\section1 QML Features \list -\o \l{QML Documents} +\o \l{QML Basic Elements}{Basic Elements} +\o \l{QML Basic Types}{Data Types} \o \l{Property Binding} -\o \l{Anchor-Based Layout in QML} -\o \l{Writing QML Components: Properties, Methods and Signals} -\o \l{QML Scope} -\o \l{QML Modules} +\o \l{Using QML Positioner and Repeater Items}{Component Layouts} +\o \l{Anchor-based Layout in QML}{Layouts using Anchors} +\o \l{QML Mouse Events}{Mouse Events} +\o \l{QML Text Handling and Validators}{Text Handling and Validators} +\o \l{Keyboard Focus in QML}{Keyboard Focus} +\o \l{QML Signal and Handler Event System}{Signal and Handler Event System} +\o \l{Importing Reusable Components} +\o \l{QML States}{States} +\o \l{QML Animation and Transitions}{Animation and Transitions} +\o \l{QML Data Models}{Structuring Data with Models} +\o \l{Presenting Data with Views} +\o \l{Extending QML Functionalities using C++} +\o \l{Using QML Bindings in C++ Applications} +\o \l{Integrating QML Code with Existing Qt UI Code} +\o \l{Dynamic Object Management in QML}{Dynamic Object Management} +\o \l{Network Transparency}{Loading Resources in QML} +\o \l{QML Internationalization}{Internationalization} \endlist -\section1 User Interaction +\section1 QML Add-Ons \list -\o \l{Keyboard Focus in QML} -\o \l{QML States} -\o \l{QML Animation} +\o \l{QtWebKit QML Module} +\o \l{http://doc.qt.nokia.com/qtmobility-1.1.0/qml-plugins.html}{Mobility QML Plugins} \endlist -\section1 Handling Data +\section1 Qt Quick Tools \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} -\o \l{Network Transparency} +\o \l{Debugging QML} +\o \l{external: Developing Qt Quick Applications with Creator}{Developing with Qt Creator} +\o \l{QML Viewer} \endlist -\section1 Architecture +\section1 Reference \list -\o \l{Qt Declarative UI Runtime} -\o \l{Integrating JavaScript} -\o \l{Dynamic Object Management in QML} +\o \l{Introduction to the QML language}{QML Syntax} +\o \l{QML Elements} +\o \l{Qt Declarative Module} +\o \l{QML Basic Types}{QML Data Types} +\o \l{QML Coding Conventions} +\o \l{external: Qt Creator Manual}{Qt Creator Manual} +\o \l{Programming with Qt} +\o \l{http://doc.qt.nokia.com/qtmobility-1.1.0/index.html}{Qt Mobility Documentation} \endlist -\section1 Using QML with C++ +\section1 Architecture \list \o \l{Qt Declarative UI Runtime} -\o \l{Using QML in C++ Applications} -\o \l{Integrating QML with existing Qt UI code} -\o \l{Tutorial: Writing QML extensions with C++} -\o \l{Extending QML in C++} -\endlist - -\section1 Reference - -\list -\o \l{QML Elements} -\o \l{QML Basic Types} +\o \l{Integrating JavaScript} +\o \l{QML Scope} +\o \l{QML Modules} +\o \l{QML Documents} \o \l{QML Global Object} \o \l{QML Internationalization} \o \l{QML Right-to-left User Interfaces} \o \l{QML Security} \o \l{Qt Declarative Module} -\o \l{Debugging QML} -\o \l{QML Viewer} -\o \l{QML Performance} -\o \l{QML Coding Conventions} \endlist -\section1 Online Examples +\section1 Examples \list +\o \l{QML Tutorial}{"Hello World" Tutorial} +\o \l{Getting Started Programming with QML} +\o \l{QML Advanced Tutorial}{Tutorial: "Same Game"} +\o \l{Tutorial: Writing QML extensions with C++} +\o \l{QML Examples and Demos} + \o Forum Nokia: \l{http://wiki.forum.nokia.com/index.php/Qt_Quick_examples_for_porting}{Qt Quick examples for porting} \endlist + +\section1 Best Practices + +\list +\o \l{QML Best Practices: Coding Conventions}{Coding Tips} +\o \l{QML Performance}{Performance Tips} +\endlist + +\section1 License Information +\list +\o \l{Qt Quick Licensing Information} +\endlist */ diff --git a/doc/src/declarative/dynamicobjects.qdoc b/doc/src/declarative/dynamicobjects.qdoc index f2ca0fd..90fb715 100644 --- a/doc/src/declarative/dynamicobjects.qdoc +++ b/doc/src/declarative/dynamicobjects.qdoc @@ -27,13 +27,17 @@ /*! \page qdeclarativedynamicobjects.html +\ingroup qml-features +\contentspage {QML Features} +\previouspage {Integrating QML Code with Existing Qt UI Code} +\nextpage {Network Transparency}{Loading Resources in QML} \title Dynamic Object Management in QML -QML provides a number of ways to dynamically create and manage QML objects. +QML provides a number of ways to dynamically create and manage QML objects. The \l{Loader}, \l{Repeater}, \l{ListView}, \l{GridView} and \l{PathView} elements -all support dynamic object management. Objects can also be created and managed +all support dynamic object management. Objects can also be created and managed from C++, and this is the preferred method for hybrid QML/C++ applications -(see \l{Using QML in C++ Applications}). +(see \l{Using QML Bindings in C++ Applications}). QML also supports the dynamic creation of objects from within JavaScript code. This is useful if the existing QML elements do not fit the needs of your @@ -45,24 +49,24 @@ of the concepts discussed on this page. \section1 Creating Objects Dynamically -There are two ways to create objects dynamically from JavaScript. You can either call +There are two ways to create objects dynamically from JavaScript. You can either call \l {QML:Qt::createComponent()}{Qt.createComponent()} to dynamically create a \l Component object, or use \l{QML:Qt::createQmlObject()}{Qt.createQmlObject()} to create an item from a string of QML. -Creating a component is better if you have an existing component defined in a \c .qml +Creating a component is better if you have an existing component defined in a \c .qml file, and you want to dynamically create instances of that component. Otherwise, -creating an item from a string of QML is useful when the item QML itself is generated +creating an item from a string of QML is useful when the item QML itself is generated at runtime. -\section2 Creating a Component dynamically +\section2 Creating a Component Dynamically -To dynamically load a component defined in a QML file, call the -\l {QML:Qt::createComponent()}{Qt.createComponent()} function on the \l{QML Global Object}. +To dynamically load a component defined in a QML file, call the +\l {QML:Qt::createComponent()}{Qt.createComponent()} function on the \l{QML Global Object}. This function takes the URL of the QML file as its only argument and creates a \l Component object from this URL. -Once you have a \l Component, you can call its \l {Component::createObject()}{createObject()} method to create an instance of +Once you have a \l Component, you can call its \l {Component::createObject()}{createObject()} method to create an instance of the component. This function can take one or two arguments: \list \o The first is the parent for the new item. Since graphical items will not appear on the scene without a parent, it is @@ -96,25 +100,27 @@ in case the QML file is loaded over a network and thus is not ready immediately. \codeline \snippet doc/src/snippets/declarative/componentCreation.js finishCreation -If you are certain the QML file to be loaded is a local file, you could omit the \c finishCreation() +If you are certain the QML file to be loaded is a local file, you could omit the \c finishCreation() function and call \l {Component::createObject()}{createObject()} immediately: \snippet doc/src/snippets/declarative/componentCreation.js func \snippet doc/src/snippets/declarative/componentCreation.js local \snippet doc/src/snippets/declarative/componentCreation.js func-end -Notice in both instances, \l {Component::createObject()}{createObject()} is called with +Notice in both instances, \l {Component::createObject()}{createObject()} is called with \c appWindow passed as an argument so that the created object will become a child of the \c appWindow item in \c main.qml. Otherwise, the new item will not appear in the scene. When using files with relative paths, the path should be relative to the file where \l {QML:Qt::createComponent()}{Qt.createComponent()} is executed. -To connect signals to (or receive signals from) dynamically created objects, use the signal -\c connect() method. See \l {Connecting signals to methods and other signals} for more information. +To connect signals to (or receive signals from) dynamically created objects, +use the signal \c connect() method. See +\l{QML Signal and Handler Event System#Connecting Signals to Methods and Signals} +{Connecting Signals to Methods and Signals} for more information. -\section2 Creating an object from a string of QML +\section2 Creating an Object from a String of QML If the QML is not defined until runtime, you can create a QML item from a string of QML using the \l{QML:Qt::createQmlObject()}{Qt.createQmlObject()} function, as in the following example: @@ -164,7 +170,7 @@ items that you did not dynamically create yourself. Items can be deleted using the \c destroy() method. This method has an optional argument (which defaults to 0) that specifies the approximate delay in milliseconds -before the object is to be destroyed. +before the object is to be destroyed. Here is an example. The \c application.qml creates five instances of the \c SelfDestroyingRect.qml component. Each instance runs a NumberAnimation, and when the animation has finished, calls @@ -198,7 +204,7 @@ Item { } \endqml -This would result in an error, since items can only be dynamically +This would result in an error, since items can only be dynamically destroyed if they were dynamically created. Objects created with \l{QML:Qt::createQmlObject()}{Qt.createQmlObject()} @@ -206,6 +212,4 @@ can similarly be destroyed using \c destroy(): \snippet doc/src/snippets/declarative/createQmlObject.qml 0 \snippet doc/src/snippets/declarative/createQmlObject.qml destroy - */ - diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc index e2d9350..8fb64c1 100644 --- a/doc/src/declarative/elements.qdoc +++ b/doc/src/declarative/elements.qdoc @@ -31,7 +31,8 @@ \title QML Elements \brief A listing of standard QML elements. -These are the functionally grouped lists of QML elements. +These are the functionally grouped lists of QML elements as part of +\l{Qt Quick}. Elements are declared with the their name and two curly braces. Elements may be nested in elements, thereby creating a parent-child relationship between the @@ -44,7 +45,7 @@ To see the QML elements listed by functional area, see the \list \o \l {Item} - Basic item element inherited by QML elements \o \l {Component} - Encapsulates QML elements during importing -\o \l {QML:QtObject} {QtObject} - Basic element containing only the objectName property +\o \l {QML:QtObject} {QtObject} - Basic element containing only the \c {objectName} property \endlist \section1 Graphics @@ -54,7 +55,7 @@ To see the QML elements listed by functional area, see the \o \l {BorderImage} - Allows the use of images as borders \o \l {AnimatedImage} - For playing animations stored in a series of frames \o \l {Gradient} - For defining a color gradient -\o \l {GradientStop} - Used to define a color within a \l {Gradient} +\o \l {GradientStop} - Used to define a color within a \l {Gradient} \o \l {SystemPalette} - Provides access to the Qt palettes \endlist @@ -74,7 +75,7 @@ To see the QML elements listed by functional area, see the \o \l {MouseArea} - Sets up an area for mouse interaction \o \l {Keys} - Provides components with attached properties to handle key input. \o \l {FocusScope} - Element that mediate keyboard focus changes -\o \l {Flickable} - Provides a surface that can be "flicked" +\o \l {Flickable} - Provides a surface that can be "flicked" \o \l {Flipable} - Provides a surface that produces "flipping" effects \o \l {PinchArea} - Enables simple pinch gesture handling \endlist diff --git a/doc/src/declarative/example-slideswitch.qdoc b/doc/src/declarative/example-slideswitch.qdoc index 27c8f58..201ff2b 100644 --- a/doc/src/declarative/example-slideswitch.qdoc +++ b/doc/src/declarative/example-slideswitch.qdoc @@ -33,8 +33,6 @@ This example shows how to create a reusable switch component in QML. The code for this example can be found in the \c $QTDIR/examples/declarative/ui-components/slideswitch directory. -\section1 Overview - The elements that compose the switch are: \list @@ -123,7 +121,7 @@ For more information on scripts see \l{Integrating JavaScript}. At this point, when the switch toggles between the two states the knob will instantly change its \c x position between 1 and 78. In order for the the knob to move smoothly we add a transition that will animate the \c x property with an easing curve for a duration of 200ms. -For more information on transitions see \l{qdeclarativeanimation.html#transitions}{QML Transitions}. +For more information on transitions see \l{QML Animation and Transitions}. \section1 Usage The switch can be used in a QML file, like this: diff --git a/doc/src/declarative/examples.qdoc b/doc/src/declarative/examples.qdoc index b359877..b7420e0 100644 --- a/doc/src/declarative/examples.qdoc +++ b/doc/src/declarative/examples.qdoc @@ -146,7 +146,6 @@ The examples can be found in Qt's \c examples/declarative directory. \section2 Touch Interaction \list -\o \l{declarative/touchinteraction/gestures}{Gestures} \o \l{declarative/touchinteraction/mousearea}{MouseArea} \endlist diff --git a/doc/src/declarative/extending-tutorial.qdoc b/doc/src/declarative/extending-tutorial.qdoc index 4caa631..0ddc430 100644 --- a/doc/src/declarative/extending-tutorial.qdoc +++ b/doc/src/declarative/extending-tutorial.qdoc @@ -27,13 +27,13 @@ /*! \page qml-extending-tutorial-index.html -\title Tutorial: Writing QML extensions with C++ +\title Tutorial: Writing QML Extensions with C++ The Qt Declarative module provides a set of APIs for extending QML through C++ extensions. You can write extensions to add your own QML types, extend existing Qt types, or call C/C++ functions that are not accessible from ordinary QML code. -This tutorial shows how to write a QML extension using C++ that includes +This tutorial shows how to write a QML extension using C++ that includes core QML features, including properties, signals and bindings. It also shows how extensions can be deployed through plugins. @@ -45,7 +45,7 @@ Tutorial chapters: \list 1 \o \l{declarative/tutorials/extending/chapter1-basics}{Creating a New Type} \o \l{declarative/tutorials/extending/chapter2-methods}{Connecting to C++ Methods and Signals} -\o \l{declarative/tutorials/extending/chapter3-bindings}{Adding Property Bindings} +\o \l{declarative/tutorials/extending/chapter3-bindings}{Property Binding} \o \l{declarative/tutorials/extending/chapter4-customPropertyTypes}{Using Custom Property Types} \o \l{declarative/tutorials/extending/chapter5-listproperties}{Using List Property Types} \o \l{declarative/tutorials/extending/chapter6-plugins}{Writing an Extension Plugin} @@ -67,18 +67,18 @@ like network programming that are not accessible through built-in QML features. In this tutorial, we will show how to use the C++ classes in the Qt Declarative module to extend QML. The end result will be a simple Pie Chart display implemented by -several custom QML types connected together through QML features like bindings and +several custom QML types connected together through QML features like bindings and signals, and made available to the QML runtime through a plugin. To begin with, let's create a new QML type called "PieChart" that has two properties: a name and a color. We will make it available in a \l {Modules}{module} called "Charts", with -a module version of 1.0. +a module version of 1.0. We want this \c PieChart type to be usable from QML like this: \code import Charts 1.0 - + PieChart { width: 100; height: 100 name: "A simple pie chart" @@ -99,16 +99,16 @@ Here is our \c PieChart class, defined in \c piechart.h: \snippet declarative/tutorials/extending/chapter1-basics/piechart.h 0 -The class inherits from QDeclarativeItem because we want to override +The class inherits from QDeclarativeItem because we want to override QDeclarativeItem::paint() in order to draw. If the class just represented some data type and was not an item that actually needed to be displayed, it could simply inherit -from QObject. Or, if we want to extend the functionality of an existing QObject-based +from QObject. Or, if we want to extend the functionality of an existing QObject-based class, it could inherit from that class instead. The \c PieChart class defines the two properties, \c name and \c color, with the Q_PROPERTY macro, -and overrides QDeclarativeItem::paint(). The class implementation in \c piechart.cpp -simply sets and returns the \c m_name and \c m_color values as appropriate, and -implements \c paint() to draw a simple pie chart. It also turns off the +and overrides QDeclarativeItem::paint(). The class implementation in \c piechart.cpp +simply sets and returns the \c m_name and \c m_color values as appropriate, and +implements \c paint() to draw a simple pie chart. It also turns off the QGraphicsItem::ItemHasNoContents flag to enable painting: \snippet declarative/tutorials/extending/chapter1-basics/piechart.cpp 0 @@ -150,19 +150,19 @@ Try it yourself with the code in Qt's \c examples/tutorials/extending/chapter1-b At the moment, the \c app.qml is run from within a C++ application. This may seem odd if you're used to running QML files with the \l {QML Viewer}. -Later on, we'll show how to create a plugin so that you can run \c app.qml using the +Later on, we'll show how to create a plugin so that you can run \c app.qml using the \l {QML Viewer} instead. */ /*! -\title Chapter 2: Connecting to C++ Methods and Signals +\title Chapter 2: Connecting to C++ Methods and Signals \example declarative/tutorials/extending/chapter2-methods Suppose we want \c PieChart to have a "clearChart()" method that erases the -chart and then emits a "chartCleared" signal. Our \c app.qml would be able +chart and then emits a "chartCleared" signal. Our \c app.qml would be able to call \c clearChart() and receive \c chartCleared() signals like this: \snippet declarative/tutorials/extending/chapter2-methods/app.qml 0 @@ -210,7 +210,7 @@ Property bindings is a powerful feature of QML that allows values of different elements to be synchronized automatically. It uses signals to notify and update other elements' values when property values are changed. -Let's enable property bindings for the \c color property. That means +Let's enable property bindings for the \c color property. That means if we have code like this: \snippet declarative/tutorials/extending/chapter3-bindings/app.qml 0 @@ -224,7 +224,7 @@ updates to the same value. When the window is clicked, the \c onClicked handler in the MouseArea changes the color of \c chartA, thereby changing both charts to the color blue. -It's easy to enable property binding for the \c color property. +It's easy to enable property binding for the \c color property. We add a \l{Qt's Property System}{NOTIFY} feature to its Q_PROPERTY() declaration to indicate that a "colorChanged" signal is emitted whenever the value changes. @@ -244,7 +244,7 @@ It's important for \c setColor() to check that the color value has actually chan before emitting \c colorChanged(). This ensures the signal is not emitted unnecessarily and also prevents loops when other elements respond to the value change. -The use of bindings is essential to QML. You should always add NOTIFY +The use of bindings is essential to QML. You should always add NOTIFY signals for properties if they are able to be implemented, so that your properties can be used in bindings. Properties that cannot be bound cannot be automatically updated and cannot be used as flexibly in QML. Also, since @@ -286,7 +286,7 @@ int-type property to store an identifier for each chart: \endcode We can also use various other property types. QML has built-in support for the types -listed in the \l{Adding Properties} documentation, which includes the following: +listed in the \l{QML Basic Types} documentation, which includes the following: \list \o bool, unsigned int, int, float, double, qreal @@ -299,7 +299,7 @@ listed in the \l{Adding Properties} documentation, which includes the following: If we want to create a property whose type is not supported by QML by default, we need to register the type with QML. -For example, let's replace the use of the \c property with a type called +For example, let's replace the use of the \c property with a type called "PieSlice" that has a \c color property. Instead of assigning a color, we assign an \c PieSlice value which itself contains a \c color: @@ -358,10 +358,10 @@ have a \c slices property that accepts a list of \c PieSlice items: \image extending-tutorial-chapter5.png To do this, we replace the \c pieSlice property in \c PieChart with a \c slices property, -declared as a QDeclarativeListProperty type. The QDeclarativeListProperty class enables the +declared as a QDeclarativeListProperty type. The QDeclarativeListProperty class enables the creation of list properties in QML extensions. We replace the \c pieSlice() -function with a \c slices() function that returns a list of slices, and add -an internal \c append_slice() function (discussed below). We also use a QList to +function with a \c slices() function that returns a list of slices, and add +an internal \c append_slice() function (discussed below). We also use a QList to store the internal list of slices as \c m_slices: \snippet declarative/tutorials/extending/chapter5-listproperties/piechart.h 0 @@ -409,7 +409,7 @@ To create a plugin library, we need: \list \o A plugin class that registers our QML types -\o A project file that describes the plugin +\o A project file that describes the plugin \o A \l{Writing a qmldir file}{qmldir} file that tells the QML engine to load the plugin \endlist @@ -468,8 +468,9 @@ In this tutorial, we've shown the basic steps for creating a QML extension: \endlist -The \l {Extending QML in C++} reference documentation shows other useful features that can be added to -QML extensions. For example, we could use \l{Default Property}{default properties} to allow +The \l {Extending QML Functionalities using C++} reference documentation shows +other useful features that can be added to QML extensions. For example, we +could use \l{Default Property}{default properties} to allow slices to be added without using the \c slices property: \code @@ -489,7 +490,8 @@ Or randomly add and remove slices from time to time using \l{Property Value Sour \endcode -See the \l{Extending QML in C++}{reference documentation} for more information. +See the \l{Extending QML Functionalities using C++} reference documentation +for more information. */ diff --git a/doc/src/declarative/extending.qdoc b/doc/src/declarative/extending.qdoc index 80b6e72..c417c04 100644 --- a/doc/src/declarative/extending.qdoc +++ b/doc/src/declarative/extending.qdoc @@ -27,7 +27,11 @@ /*! \page qml-extending.html -\title Extending QML in C++ +\ingroup qml-features +\contentspage QML Features +\previouspage {Presenting Data with Views} +\nextpage {Using QML Bindings in C++ Applications} +\title Extending QML Functionalities using C++ The QML syntax declaratively describes how to construct an in-memory object tree. In Qt, QML is mainly used to describe a visual scene graph, but it is @@ -82,7 +86,7 @@ Types can be registered by libraries, application code, or by plugins Once registered, all \l {Qt's Property System}{properties} of the supported types are available in QML. QML has intrinsic support for -properties of the types listed in the \l{Adding Properties} +properties of the types listed in the \l{QML Basic Types} document, which includes the following: \list @@ -429,28 +433,28 @@ pointers to invalid objects. QML makes the following guarentees: \list \o An object assigned to a QObject (or QObject-derived) pointer property will be -valid at the time of assignment. +valid at the time of assignment. -Following assignment, it is the responsibility of the class to subsequently guard +Following assignment, it is the responsibility of the class to subsequently guard this pointer, either through a class specific method or the generic QPointer class. -\o An object assigned to a QVariant will be valid at the time of assignment. +\o An object assigned to a QVariant will be valid at the time of assignment. -When assigning an object to a QVariant property, QML will always use a QMetaType::QObjectStar -typed QVariant. It is the responsibility of the class to guard the pointer. A -general rule when writing a class that uses QVariant properties is to check the -type of the QVariant when it is set and if the type is not handled by your class, +When assigning an object to a QVariant property, QML will always use a QMetaType::QObjectStar +typed QVariant. It is the responsibility of the class to guard the pointer. A +general rule when writing a class that uses QVariant properties is to check the +type of the QVariant when it is set and if the type is not handled by your class, reset it to an invalid variant. -\o An object assigned to a QObject (or QObject-derived) list property will be -valid at the time of assignment. +\o An object assigned to a QObject (or QObject-derived) list property will be +valid at the time of assignment. -Following assignment, it is the responsibility of the class to subsequently guard +Following assignment, it is the responsibility of the class to subsequently guard this pointer, either through a class specific method or the generic QPointer class. \endlist Elements should assume that any QML assigned object can be deleted at any time, and -respond accordingly. If documented as such an element need not continue to work in +respond accordingly. If documented as such an element need not continue to work in this situation, but it must not crash. \section1 Signal Support @@ -477,7 +481,7 @@ but different parameters cannot be distinguished. Signal parameters become accessible by name to the assigned script. An unnamed parameter cannot be accessed, so care should be taken to name all the signal parameters in the C++ class declaration. The intrinsic types -listed in \l {Adding Types}, as well registered object types are permitted as +listed in \l{Adding Types}, as well registered object types are permitted as signal parameter types. Using other types is not an error, but the parameter value will not be accessible from script. @@ -498,7 +502,7 @@ on<Property-name>Changed, regardless of the name used for the NOTIFY signal in C++. We recommend using <property-name>Changed() for the NOTIFY signal in C++. -See also \l {Writing QML Components: Properties, Methods and Signals} +See also \l {Importing Reusable Components} \section1 Methods @@ -701,478 +705,4 @@ public: } }; \endcode - -*/ - -/*! -\page qml-extending-types.html -\title Writing QML Components: Properties, Methods and Signals - -One of the key concepts in QML is the ability to define your own QML components that suit -the purposes of your application. The standard \l {QML Elements} provide the essential components -for creating a QML application; beyond these, you can write your own custom components that can -be created and reused, without the use of C++. - -Components are the building blocks of a QML project. When writing a QML application, whether -large or small, it is best to separate QML code into smaller components that perform specific -sets of operations, instead of creating mammoth QML files with large, combined functionality -that is more difficult to manage and may contain duplicated code. - - -\section1 Defining New Components - -A component is a reusable type with a well-defined interface, built entirely in QML. -Any snippet of QML code can become a component, by placing the code in a file "<Name>.qml" where -<Name> is the new component name, beginning with an uppercase letter. These QML files automatically -become available as new QML element types to other QML components and applications in the same directory. - -For example, one of the simplest and most common components you can build in QML is a -button-type component. Below, we implement this component as a \l Rectangle with a clickable -\l MouseArea, in a file named \c Button.qml: - -\snippet doc/src/snippets/declarative/qml-extending-types/components/Button.qml 0 - -Now this component can be reused by another file within the same directory. Since the file is -named \c Button.qml, the component is referred to as \c Button: - -\table -\row -\o \snippet doc/src/snippets/declarative/qml-extending-types/components/application.qml 0 -\o \image qml-extending-types.png -\endtable - -The root object in \c Button.qml defines the attributes that are available to users of the -\c Button component. In this case, the root object is a \l Rectangle, so any properties, methods -and signals of \l Rectangle are made available, allowing \c application.qml to -customize the \c width, \c height, \c radius and \c color properties of \c Button objects. - - -If \c Button.qml was not in the same directory, \c application.qml would need to load it as a -\l {Modules}{module} from a specific filesystem path or \l{QDeclarativeExtensionPlugin}{plugin}. -Also, note the letter case of the component file name is significant on some (notably UNIX) -filesystems. It is recommended the file name case matches the case of the QML component name -exactly - for example, \c Box.qml and not \c BoX.qml - regardless of the platform to which the -QML component will be deployed. - -To write a useful component, it is generally necessary to provide it with custom attributes that store and -communicate specific data. This is achieved by adding the following attributes to your components: - -\list -\o \bold Properties that can be accessed externally to modify an object (for example, \l Item has - \l {Item::}{width} and \l {Item::}{height} properties) and used in \l {Property Binding} -\o \bold Methods of JavaScript code can be invoked internally or externally (for example, - \l Animation has a \l {Animation::}{start()} method) -\o \bold Signals to notify other objects when an event has occurred (for example, MouseArea has a - \c clicked signal) -\endlist - -The following sections show how these attributes can be added to QML components. - - -\section1 Adding Properties - -A property is a value of a QML component that can be read and modified by other objects. For -example, a \l Rectangle component has \l {Item::}{width}, \l {Item::}{height} and \l -{Rectangle::}{color} properties. Significantly, properties be used with \l {Property Binding}, where -a property value is automatically updated using the value of another property. - -The syntax for defining a new property is: - -\code -[default] property <type> <name>[: defaultValue] -\endcode - -A \c property declaration can appear anywhere within a QML component definition, but it is customary -to place it at the top. A component cannot declare more than one property with the same name. (It is -possible to have a property name that is the same as an existing property in a type, but this is not -recommended as the existing property becomes hidden and inaccessible.) - -Below is an example. The \c ImageViewer component has defined a \c string type property named -\c currentImage, and its initial value is "default-image.png". This property is used to set the image -displayed in the child \l Image object. Another file, \c application.qml, can create -an \c ImageViewer object and read or modify the \c currentImage value: - -\table -\row -\o \snippet doc/src/snippets/declarative/qml-extending-types/properties/ImageViewer.qml 0 -\o \snippet doc/src/snippets/declarative/qml-extending-types/properties/application.qml 0 -\endtable - -It is optional for a property to have a default value. The default value is a convenient shortcut, and is -behaviorally identical to doing it in two steps, like this: - -\qml -Item { - // Use default value - property int myProperty: 10 - - // Longer, but behaviorally identical - property int myProperty - myProperty: 10 -} -\endqml - - -\section2 Supported property types - -All QML properties are typed. The examples above show properties with \c int and \c string types; -notice that the type of the property must be declared. The type is used to determine the property -behavior, and how the property is defined in C++. - -A number of property types are supported by default. These are listed in the table below, -with their default values and the corresponding C++ type: - -\table -\header \o QML Type Name \o Default value \o C++ Type Name -\row \o \l int \o 0 \o int -\row \o \l bool \o \c false \o bool -\row \o \l double \o 0.0 \o double -\row \o \l real \o 0.0 \o double -\row \o \l string \o "" (empty string) \o QString -\row \o \l url \o "" (empty url) \o QUrl -\row \o \l color \o #000000 (black) \o QColor -\row \o \l date \o \c undefined \o QDateTime -\row \o \l variant \o \c undefined \o QVariant -\endtable - -QML object types can also be used as property types. This includes -\l {Defining new QML elements}{custom QML types} implemented in C++. Such properties are -defined like this: - -\qml -Item { - property Item itemProperty - property QtObject objectProperty - property MyCustomType customProperty -} -\endqml - -Such object-type properties default to an \c undefined value. - -It is also possible to store a copy of a JavaScript object using the \c variant -property type. This creates some restrictions on how the property should be used; -see the \l {variant}{variant type documentation} for details. - -\l{list}{List properties} are created with the \c list<Type> syntax, and default to an empty -list: - -\qml -Item { - property list<Item> listOfItems -} -\endqml - -Note that list properties cannot be modified like ordinary JavaScript -arrays. See the \l {list}{list type documentation} for details. - - -\section2 Property change signals - -Adding a \c property to an item automatically adds a \e {value changed} -signal handler to the item. To connect to this signal, use a \l {Signal Handlers}{signal handler} -named with the \c on<Property>Changed syntax, using upper case for the first letter of the -property name. - -For example, the following \c onMyNumberChanged signal handler is automatically called whenever the -\c myNumber property changes: - -\snippet doc/src/snippets/declarative/qml-extending-types/properties/property-signals.qml 0 - - -\section2 Default properties - -The optional \c default attribute for a property marks it as the \e {default property} -for a type. This allows other items to specify the default property's value -as child elements. For example, the \l Item element's default property is its -\l{Item::children}{children} property. This allows the children of an \l Item -to be set like this: - -\qml -Item { - Rectangle {} - Rectangle {} -} -\endqml - -If the \l{Item::children}{children} property was not the default property for -\l Item, its value would have to be set like this instead: - -\qml -Item { - children: [ - Rectangle {}, - Rectangle {} - ] -} -\endqml - -See the \l{declarative/ui-components/tabwidget}{TabWidget} example for a -demonstration of using default properties. - -Specifying a default property overrides any existing default property (for -example, any default property inherited from a parent item). Using the -\c default attribute twice in the same type block is an error. - - -\section2 Property aliases - -Property aliases are a more advanced form of property declaration. Unlike a -property definition, which allocates a new, unique storage space for the -property, a property alias connects the newly declared property (called the -aliasing property) as a direct reference to an existing property (the aliased property). Read -operations on the aliasing property act as read operations on the aliased -property, and write operations on the aliasing property as write operations on -the aliased property. - -A property alias declaration looks a lot like an ordinary property definition: -\code - [default] property alias <name>: <alias reference> -\endcode - -As the aliasing property has the same type as the aliased property, an explicit -type is omitted, and the special "alias" keyword is used. Instead of a default -value, a property alias includes a compulsory alias reference. The alias -reference is used to locate the aliased property. While similar to a property -binding, the alias reference syntax is highly restricted. - -An alias reference takes one of the following forms: -\code - <id>.<property> - <id> -\endcode - -where <id> must refer to an object id within the same component as the type -declaring the alias, and, optionally, <property> refers to a property on that object. - -For example, below is a \c Button.qml component with a \c buttonText aliased property which is -connected to the child Text object's \c text property: - -\snippet doc/src/snippets/declarative/qml-extending-types/properties/alias.qml 0 - -The following code would create a \c Button with a defined text string for the -child \l Text object: - -\qml -Button { buttonText: "This is a button" } -\endqml - -Here, modifying \c buttonText directly modifies the \c textItem.text value; it does not -change some other value that then updates \c textItem.text. - -In this case, the use of aliased properties is essential. If \c buttonText was not an alias, -changing its value would not actually change the displayed text at all, as -\l {Property Binding}{property bindings} are not bi-directional: the \c buttonText value would -change when \c textItem.text changes, but not the other way around. - -Aliased properties are also useful for allowing external objects to directly modify and -access child objects in a component. For example, here is a modified version of the \c ImageViewer -component shown \l {Adding Properties}{earlier} on this page. The \c currentImage property has -been changed to an alias to the child \l Image object: - -\table -\row -\o \snippet doc/src/snippets/declarative/qml-extending-types/properties/alias/ImageViewer.qml 0 -\o \snippet doc/src/snippets/declarative/qml-extending-types/properties/alias/application.qml 0 -\endtable - -Instead of being limited to setting the \l Image source, \c application.qml can now directly -access and modify the child \l Image object and its properties. - -Obviously, exposing child objects in this manner should be done with care, as it allows external -objects to modify them freely. However, this use of aliased properties can be quite useful in -particular situations, such as for the \l {declarative/ui-components/tabwidget}{TabWidget} -example, where new tab items are actually parented to a child object that displays the current tab. - - -\section3 Considerations for property aliases - -Aliases are only activated once the component specifying them is completed. The -most obvious consequence of this is that the component itself cannot generally -use the aliased property directly during creation. For example, this will not work: - -\code - // Does NOT work - property alias buttonText: textItem.text - buttonText: "Some text" // buttonText is not yet defined when this value is set -\endcode - -A second, much less significant, consequence of the delayed activation of -aliases is that an alias reference cannot refer to another aliasing property -declared within the same component. This will not work: - -\code - // Does NOT work - id: root - property alias buttonText: textItem.text - property alias buttonText2: root.buttonText -\endcode - -At the time the component is created, the \c buttonText value has not yet been assigned, -so \c root.buttonText would refer to an undefined value. (From outside the component, -however, aliasing properties appear as regular Qt properties and consequently can be -used in alias references.) - -It is possible for an aliased property to have the same name as an existing property. For example, -the following component has a \c color alias property, named the same as the built-in -\l {Rectangle::color} property: - -\snippet doc/src/snippets/declarative/qml-extending-types/properties/alias-override.qml 0 - -Any objects that use this component and refer to its \c color property will be -referring to the alias rather than the ordinary \l {Rectangle::color} property. Internally, -however, the rectangle can correctly set this property to "red" and refer to the actual defined -property rather than the alias. - - -\section1 Adding Methods - -A QML component can define methods of JavaScript code. These methods can be invoked -either internally or by other objects. - -The syntax for defining a method is: - -\code -function <name>([<parameter name>[, ...]]) { <body> } -\endcode - -This declaration may appear anywhere within a type body, but it is customary to -include it at the top. Attempting to declare two methods or signals with the -same name in the same type block is an error. However, a new method may reuse -the name of an existing method on the type. (This should be done with caution, -as the existing method may be hidden and become inaccessible.) - -Unlike \l{Adding Signals}{signals}, method parameter types do not have to be declared as they -default to the \c variant type. The body of the method is written in JavaScript and may access -the parameters by name. - -Here is an example of a component with a \c say() method that accepts a single \c text argument: - -\snippet doc/src/snippets/declarative/qml-extending-types/methods/app.qml 0 - -A method can be connected to a signal so that it is automatically invoked whenever the signal -is emitted. See \l {Connecting signals to methods and other signals} below. - -Also see \l {Integrating JavaScript} for more information on using JavaScript with QML. - - -\section1 Adding Signals - -Signals provide a way to notify other objects when an event has occurred. For example, the MouseArea -\c clicked signal notifies other objects that the mouse has been clicked within the area. - -The syntax for defining a new signal is: - -\code -signal <name>[([<type> <parameter name>[, ...]])] -\endcode - -This declaration may appear anywhere within a type body, but it is customary to -include it at the top. Attempting to declare two signals or methods with the -same name in the same type block is an error. However, a new signal may reuse -the name of an existing signal on the type. (This should be done with caution, -as the existing signal may be hidden and become inaccessible.) - -Here are three examples of signal declarations: - -\code -Item { - signal clicked - signal hovered() - signal performAction(string action, variant actionArgument) -} -\endcode - -If the signal has no parameters, the "()" brackets are optional. If parameters are used, the -parameter types must be declared, as for the \c string and \c variant arguments for the \c -performAction signal above; the allowed parameter types are the same as those listed in the \l -{Adding Properties} section on this page. - -Adding a signal to an item automatically adds a \l {Signal Handlers}{signal handler} as well. -The signal hander is named \c on<SignalName>, with the first letter of the signal being upper -cased. The above example item would now have the following signal handlers: - -\list -\o onClicked -\o onHovered -\o onPerformAction -\endlist - -To emit a signal, simply invoke it in the same way as a method. Below left, when the \l MouseArea is -clicked, it emits the parent \c buttonClicked signal by invoking \c rect.buttonClicked(). The -signal is received by \c application.qml through an \c onButtonClicked signal handler: - -\table -\row -\o \snippet doc/src/snippets/declarative/qml-extending-types/signals/basic.qml 0 -\o \snippet doc/src/snippets/declarative/qml-extending-types/signals/no-parameters.qml 0 -\endtable - -If the signal has parameters, they are accessible by parameter name in the signal handler. -In the example below, \c buttonClicked is emitted with \c xPos and \c yPos parameters instead: - -\table -\row -\o \snippet doc/src/snippets/declarative/qml-extending-types/signals/Button.qml 0 -\o \snippet doc/src/snippets/declarative/qml-extending-types/signals/parameters.qml 0 -\endtable - - -\section2 Connecting signals to methods and other signals - -Signal objects have a \c connect() method that can be used to a connect a signal to a method or -another signal. When a signal is connected to a method, the method is automatically invoked -whenever the signal is emitted. (In Qt terminology, the method is a \e slot that is connected -to the \e signal; all methods defined in QML are created as Qt slots.) This enables a signal -to be received by a method instead of a \l {Signal Handlers}{signal handler}. - -For example, the \c application.qml above could be rewritten as: - -\snippet doc/src/snippets/declarative/qml-extending-types/signals/connectslots.qml 0 - -The \c myMethod() method will be called whenever the \c buttonClicked signal is received. - -In many cases it is sufficient to receive signals through signal handlers rather than using -the \c connect() function; the above example does not provide any improvements over using a -simple \c onButtonClicked handler. However, if you are \l{Dynamic Object Management in QML}{creating objects dynamically}, -or \l {Integrating JavaScript}{integrating JavaScript code}, then you will find the -\c connect() method useful. For example, the component below creates three \c Button -objects dynamically, and connects the \c buttonClicked signal of each object to the -\c myMethod() function: - -\snippet doc/src/snippets/declarative/qml-extending-types/signals/connectdynamic.qml 0 - -In the same way, you could connect a signal to methods defined in a dynamically -created object, or \l {Receiving QML Signals in JavaScript}{connect a signal to a JavaScript method}. - -There is also a corresponding \c disconnect() method for removing connected signals. The following -code removes the connection created in \c application.qml above: - -\qml -// application.qml -Item { - // ... - - function removeSignal() { - button.clicked.disconnect(item.myMethod) - } -} -\endqml - - -\section3 Forwarding signals - -The \c connect() method can also connect a signal to other signals. This has the effect -of "forwarding" a signal: it is automatically emitted whenever the relevant signal is emitted. For -example, the MouseArea \c onClicked handler in \c Button.qml above could have been replaced with -a call to \c connect(): - -\qml -MouseArea { - anchors.fill: parent - Component.onCompleted: clicked.connect(item.buttonClicked) -} -\endqml - -Whenever the \l MouseArea \c clicked signal is emitted, the \c rect.buttonClicked signal will -automatically be emitted as well. */ diff --git a/doc/src/declarative/focus.qdoc b/doc/src/declarative/focus.qdoc index 599d63c..940f864 100644 --- a/doc/src/declarative/focus.qdoc +++ b/doc/src/declarative/focus.qdoc @@ -28,11 +28,16 @@ /*! \target qmlfocus \page qdeclarativefocus.html +\ingroup qml-features +\contentspage QML Features +\previouspage {QML Text Handling and Validators}{Text Handling and Validators} +\nextpage {QML Signal and Handler Event System}{Signal and Handler Event System} + \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 -and to address some of the cases unique to fluid user interfaces, the QML items add a +and to address some of the cases unique to fluid user interfaces, the QML items add aged \e scope based extension to Qt's traditional keyboard focus model. \tableofcontents diff --git a/doc/src/declarative/integrating.qdoc b/doc/src/declarative/integrating.qdoc index f0d3a37..c2f55f5 100644 --- a/doc/src/declarative/integrating.qdoc +++ b/doc/src/declarative/integrating.qdoc @@ -27,7 +27,11 @@ /*! \page qml-integration.html -\title Integrating QML with existing Qt UI code +\ingroup qml-features +\previouspage {Using QML Bindings in C++ Applications} +\nextpage {Dynamic Object Management in QML}{Dynamic Object Management} +\contentspage QML Features +\title Integrating QML Code with Existing Qt UI Code There are a number of ways to integrate QML into QWidget-based UI applications, depending on the characteristics of your existing UI code. @@ -37,8 +41,8 @@ depending on the characteristics of your existing UI code. If you have an existing QWidget-based UI, QML widgets can be integrated into it using QDeclarativeView. QDeclarativeView is a subclass of QWidget so you -can add it to your user interface like any other QWidget. Use -QDeclarativeView::setSource() to load a QML file into the view, then add the +can add it to your user interface like any other QWidget. Use +QDeclarativeView::setSource() to load a QML file into the view, then add the view to your UI: \code @@ -52,7 +56,7 @@ layout->addWidget(qmlView); The one drawback to this approach is that QDeclarativeView is slower to initialize and uses more memory than a QWidget, and creating large numbers of QDeclarativeView -objects may lead to performance degradation. If this is the case, it may be +objects may lead to performance degradation. If this is the case, it may be better to rewrite your widgets in QML, and load the widgets from a main QML widget instead of using QDeclarativeView. @@ -70,7 +74,7 @@ of simple and dynamic elements. If you have an existing UI based on the \l{Graphics View Framework}, you can integrate QML widgets directly into your QGraphicsScene. Use QDeclarativeComponent to create a QGraphicsObject from a QML file, and -place the graphics object into your scene using \l{QGraphicsScene::addItem()}, or +place the graphics object into your scene using \l{QGraphicsScene::addItem()}, or reparent it to an item already in the \l{QGraphicsScene}. For example: @@ -95,12 +99,13 @@ of QML UIs: \section2 Loading QGraphicsWidget objects in QML -An alternative approach is to expose your existing QGraphicsWidget objects to +An alternative approach is to expose your existing QGraphicsWidget objects to QML and construct your scene in QML instead. See the \l {declarative-cppextensions-qgraphicslayouts.html}{graphics layouts example} which shows how to expose Qt's graphics layout classes to QML in order to use QGraphicsWidget with classes like QGraphicsLinearLayout and QGraphicsGridLayout. To expose your existing QGraphicsWidget classes to QML, use \l {qmlRegisterType()}. -See \l{Extending QML in C++} for further information on using C++ types in QML. +See \l{Extending QML Functionalities using C++} for further information on +how to use C++ types in QML. */ diff --git a/doc/src/declarative/javascriptblocks.qdoc b/doc/src/declarative/javascriptblocks.qdoc index 65877f9..f78f3c2 100644 --- a/doc/src/declarative/javascriptblocks.qdoc +++ b/doc/src/declarative/javascriptblocks.qdoc @@ -205,7 +205,7 @@ component destruction. Property bindings can be created in JavaScript by assigning the property with a \c function that returns the required value. -See \l {Binding Properties from JavaScript} for details. +See \l {qml-javascript-assignment}{Property Assignment versus Property Binding} for details. \section1 Receiving QML Signals in JavaScript @@ -224,7 +224,8 @@ in \c script.js: The \c jsFunction() will now be called whenever MouseArea's \c clicked signal is emitted. -See \l {Connecting signals to methods and other signals} for more information. +See \l{QML Signal and Handler Event System#Connecting Signals to Methods and Signals} +{Connecting Signals to Methods and Signals} for more information. \section1 QML JavaScript Restrictions @@ -292,8 +293,8 @@ To run code after the environment setup has completed, refer to \o The value of \c this is currently undefined in QML in the majority of contexts -The \c this keyword is supported when \l {Binding Properties from JavaScript} -{binding properties from JavaScript}. In all other situations, the value of +The \c this keyword is supported when binding properties from JavaScript. +In all other situations, the value of \c this is undefined in QML. To refer to any element, provide an \c id. For example: diff --git a/doc/src/declarative/modules.qdoc b/doc/src/declarative/modules.qdoc index f1ebd00..dbc8806 100644 --- a/doc/src/declarative/modules.qdoc +++ b/doc/src/declarative/modules.qdoc @@ -51,16 +51,14 @@ example, an \c import statement is required to use: An \c import statement includes the module name, and possibly a version number. This can be seen in the snippet commonly found at the top of QML files: -\qml -import QtQuick 1.0 -\endqml +\snippet doc/src/snippets/declarative/imports/qtquick-1.0.qml import 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: +\l{#import-path}{import path}. There are two types of QML modules: located modules (defined by a URL) and installed modules (defined by a URI). @@ -94,24 +92,25 @@ MyQMLProject \endcode \o -\code +\qml import "../MyComponents" Window { - Slider { ... } - CheckBox { ... } + Slider { + // ... + } + CheckBox { + // ... + } } -\endcode +\endqml \endtable Similarly, if the directory resided on a network source, it could be imported like this: -\code - import "http://www.my-server.com/MyQMLProject/MyComponents" - import "http://www.my-server.com/MyQMLProject/MyComponents" 1.0 -\endcode +\snippet doc/src/snippets/declarative/imports/network-imports.qml imports A located module can also be imported as a network resource if it has a \l{Writing a qmldir file}{qmldir file} in the directory that specifies the QML files @@ -127,14 +126,18 @@ Window 1.0 Window.qml If the \c MyComponents directory was then hosted as a network resource, it could be imported as a module, like this: -\code +\qml import "http://the-server-name.com/MyQMLProject/MyComponents" Window { - Slider { ... } - CheckBox { ... } + Slider { + // ... + } + CheckBox { + // ... + } } -\endcode +\endqml with an optional "1.0" version specification. Notice the import would fail if a later version was used, as the \c qmldir file specifies that these elements @@ -145,7 +148,8 @@ defined in QML files; components defined by C++ \l{QDeclarativeExtensionPlugin}{ are not available. -\section1 Installed modules +\target import-path +\section1 Installed Modules Installed modules are modules that are made available through the QML import path, as defined by QDeclarativeEngine::importPathList(), or modules defined within @@ -156,10 +160,7 @@ path or network resource URL. When importing an installed module, an un-quoted URI is used, with a mandatory version number: -\code - import QtQuick 1.0 - import com.nokia.qml.mymodule 1.0 -\endcode +\snippet doc/src/snippets/declarative/imports/installed-module.qml imports When a module is imported, the QML engine searches the QML import path for a matching module. The root directory of the module must contain a @@ -190,7 +191,7 @@ Additional import paths can be added through QDeclarativeEngine::addImportPath() can also use the \c -I option to add an import path. -\section2 Creating installed modules +\section2 Creating Installed Modules As an example, suppose the \c MyQMLProject directory in the \l{Located Modules}{previous example} was located on the local filesystem at \c C:\qml\projects\MyQMLProject. The \c MyComponents @@ -211,8 +212,12 @@ without referring to the module's absolute filesystem location: import projects.MyQMLProject.MyComponents 1.0 Window { - Slider { ... } - CheckBox { ... } + Slider { + // ... + } + CheckBox { + // ... + } } \endqml @@ -225,22 +230,20 @@ defined in QML files; components defined by C++ \l{QDeclarativeExtensionPlugin}{ are not available. -\section2 Creating installed modules in C++ +\section2 Creating Installed Modules in C++ C++ applications can define installed modules directly within the application using qmlRegisterType(). For example, the \l {Tutorial: Writing QML extensions with C++}{Writing QML extensions with C++ tutorial} defines a C++ class named \c PieChart and makes this type available to QML by calling qmlRegisterType(): -\qml +\code qmlRegisterType<PieChart>("Charts", 1, 0, "PieChart"); -\endqml +\endcode This allows the application's QML files to use the \c PieChart type by importing the declared \c Charts module: -\qml -import Charts 1.0 -\endqml +\snippet doc/src/snippets/declarative/imports/chart.qml import For \l{QDeclarativeExtensionPlugin}{QML plugins}, the module URI is automatically passed to QDeclarativeExtensionPlugin::registerTypes(). This method @@ -253,9 +256,7 @@ example: Once the plugin is built and installed, and includes a \l{Writing a qmldir file}{qmldir file}, the module can be imported from QML, like this: -\code -import com.nokia.TimeExample 1.0 -\endcode +\snippet doc/src/snippets/declarative/imports/timeexample.qml import Unlike QML types defined by QML files, a QML type defined in a C++ extension plugin cannot be loaded by a module that is imported as a network resource. @@ -269,47 +270,34 @@ By default, when a module is imported, its contents are imported into the global To import a module into a specific namespace, use the \e as keyword: -\qml - import QtQuick 1.0 as QtLibrary - import "../MyComponents" as MyComponents - import com.nokia.qml.mymodule 1.0 as MyModule -\endqml +\snippet doc/src/snippets/declarative/imports/named-imports.qml imports Types from these modules can then only be used when qualified by the namespace: -\qml - QtLibrary.Rectangle { ... } - - MyComponents.Slider { ... } - - MyModule.SomeComponent { ... } -\endqml +\snippet doc/src/snippets/declarative/imports/named-imports.qml imported items Multiple modules can be imported into the same namespace in the same way that multiple modules can be imported into the global namespace: -\qml - import QtQuick 1.0 as Nokia - import Ovi 1.0 as Nokia -\endqml +\snippet doc/src/snippets/declarative/imports/merged-named-imports.qml imports -\section2 JavaScript files +\section2 JavaScript Files JavaScript files must always be imported with a named import: \qml - import "somescript.js" as MyScript +import "somescript.js" as MyScript - Item { - //... - Component.onCompleted: MyScript.doSomething() - } +Item { + //... + Component.onCompleted: MyScript.doSomething() +} \endqml The qualifier ("MyScript" in the above example) must be unique within the QML document. Unlike ordinary modules, multiple scripts cannot be imported into the same namespace. -\section1 Writing a qmldir file +\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 diff --git a/doc/src/declarative/mouseevents.qdoc b/doc/src/declarative/mouseevents.qdoc new file mode 100644 index 0000000..ade6760 --- /dev/null +++ b/doc/src/declarative/mouseevents.qdoc @@ -0,0 +1,120 @@ +/**************************************************************************** +** +** 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:FDL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Free Documentation License +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of this +** file. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! +\page mouseevents.html +\title QML Mouse Events +\ingroup QML Features +\previouspage {Anchor-based Layout in QML}{Layouts using Anchors} +\nextpage {QML Text Handling and Validators}{Text Handling and Validators} +\contentspage QML Features + +\tableofcontents + +\section1 Mouse Elements + +\list +\o \l{MouseArea} Element +\o \l{MouseEvent} Object +\endlist + +\section1 Mouse Event Handling + +QML uses \l{QML Signal and Handler Event System}{signals and handlers} to +deliver mouse interactions. Specifically, the \l MouseArea and \l MouseEvent +elements provide QML components with signal handlers to accept mouse events +within a defined area. + +\section1 Defining a Mouse Area + +The \l MouseArea element receives events within a defined area. One quick way +to define this area is to anchor the \c MouseArea to its parent's area using the +\c anchors.fill property. If the parent is a \l Rectangle (or any \l Item +component), then the MouseArea will fill the area defined by the parent's +dimensions. Alternatively, an area smaller or larger than the parent is +definable. +\snippet doc/src/snippets/declarative/mousearea/mousearea-snippet.qml anchor fill + +\section1 Receiving Events + +The MouseArea element provides +\l{QML Signal and Handler Event System}{signals and handlers} to detect different +mouse events. The \l MouseArea element documentation describes these +gestures in greater detail: + +\list +\o canceled +\o clicked +\o doubleClicked +\o entered +\o exited +\o positionChanged +\o pressAndHold +\o pressed +\o released +\endlist + +These signals have signal handlers that are invoked when the signals are emitted. +\snippet doc/src/snippets/declarative/mousearea/mousearea-snippet.qml mouse handlers + +\section1 Enabling Gestures +Some mouse gestures and button clicks need to be enabled before they send or +receive events. Certain \l MouseArea and \l MouseEvent properties enable these +gestures. + +To listen to (or explicitly ignore) a certain mouse button, set the appropriate +mouse button to the \l {MouseArea::acceptedButtons}{acceptedButtons} property. + +Naturally, the mouse events, such as button presses and mouse positions, are +sent during a mouse click. For example, the \c containsMouse property will only +retrieve its correct value during a mouse press. The +\l {MouseArea::hoverEnabled}{hoverEnabled} will enable mouse events and +positioning even when there are no mouse button presses. Setting the +\c hoverEnabled property to \c true, in turn will enable the \c entered, +\c exited, and \c positionChanged signal and their respective signal handlers. + +\snippet doc/src/snippets/declarative/mousearea/mousearea-snippet.qml enable handlers +Additionally, to disable the whole mouse area, set the \c MouseArea +element's \c enabled property to \c false. + +\section1 MouseEvent Object + +Signals and their handlers receive a \l MouseEvent object as a parameter. The +\c mouse object contain information about the mouse event. For example, the +mouse button that started the event is queried through the +\l {MouseEvent::button}{mouse.button} property. + +The \c MouseEvent object can also ignore a mouse event using its \c accepted +property. + +\section2 Accepting Further Signals +Many of the signals are sent multiple times to reflect various mouse events +such as double clicking. To facilitate the classification of mouse clicks, the +MouseEvent object has an \c accepted property to disable the event propagation. + +To learn more about QML's event system, please read the \l {QML Signal and Handler Event System} document. +*/ diff --git a/doc/src/declarative/network.qdoc b/doc/src/declarative/network.qdoc index 675a0aa..1b2934a 100644 --- a/doc/src/declarative/network.qdoc +++ b/doc/src/declarative/network.qdoc @@ -27,6 +27,10 @@ /*! \page qdeclarativenetwork.html +\ingroup qml-features +\previouspage {Dynamic Object Management in QML}{Dynamic Object Management} +\nextpage {QML Internationalization}{Internationalization} +\contentspage QML Features \title Network Transparency QML supports network transparency by using URLs (rather than file names) for all @@ -57,7 +61,7 @@ Network transparency is supported throughout QML, for example: Even QML types themselves can be on the network - if the \l {QML Viewer} is used to load \tt http://example.com/mystuff/Hello.qml and that content refers to a type "World", the engine will load \tt http://example.com/mystuff/qmldir and resolve the type just as it would for a local file. -For example if the qmldir file contains the line "World World.qml", it will load +For example if the qmldir file contains the line "World World.qml", it will load \tt http://example.com/mystuff/World.qml Any other resources that \tt Hello.qml referred to, usually by a relative URL, would similarly be loaded from the network. diff --git a/doc/src/declarative/positioners.qdoc b/doc/src/declarative/positioners.qdoc index 5493d4a..763bc88 100644 --- a/doc/src/declarative/positioners.qdoc +++ b/doc/src/declarative/positioners.qdoc @@ -27,9 +27,12 @@ /*! \page qml-positioners.html +\ingroup qml-features +\previouspage Property Binding +\nextpage Anchor-based Layout in QML +\contentspage QML Features \title Using QML Positioner and Repeater Items -\section1 Introduction Positioner items are container items that manage the positions and sizes of items in a declarative user interface. Positioners behave in a similar way to @@ -53,7 +56,7 @@ graphical elements: \section2 Column -\div{float-right} +\div {class="float-right"} \inlineimage qml-column.png \enddiv @@ -70,7 +73,7 @@ must be added to a parent Rectangle, if desired. \section2 Row -\div{float-right} +\div {class="float-right"} \inlineimage qml-row.png \enddiv @@ -87,7 +90,7 @@ left around the edges of the horizontally centered Row item. \section2 Grid -\div{float-right} +\div {class="float-right"} \inlineimage qml-grid-spacing.png \enddiv @@ -97,7 +100,7 @@ in a 2-by-2 grid. As with the other positioners, the spacing between items can be specified using the \l{Grid::spacing}{spacing} property. \clearfloat -\snippet doc/src/snippets/declarative/grid/grid-spacing.qml document +\snippet doc/src/snippets/declarative/grid-spacing.qml document There is no difference between horizontal and vertical spacing inserted between items, so any additional space must be added within the items @@ -108,7 +111,7 @@ at the appropriate places in the Grid definition. \section2 Flow -\div{float-right} +\div {class="float-right"} \inlineimage qml-flow-text1.png \inlineimage qml-flow-text2.png \enddiv @@ -137,7 +140,7 @@ control of spacing between items and between lines of items. \section1 Repeaters -\div{float-right} +\div {class="float-right"} \inlineimage qml-repeater-grid-index.png \enddiv diff --git a/doc/src/declarative/propertybinding.qdoc b/doc/src/declarative/propertybinding.qdoc index 379a4ec..88ec5c3 100644 --- a/doc/src/declarative/propertybinding.qdoc +++ b/doc/src/declarative/propertybinding.qdoc @@ -27,192 +27,298 @@ /*! \page propertybinding.html +\ingroup qml-features +\contentspage QML Features +\previouspage {QML Basic Types}{Data Types} +\nextpage {Using QML Positioner and Repeater Items}{Component Layouts} \title Property Binding -Property binding is a declarative way of specifying the value of a property. Binding allows -a property's value to be expressed as an JavaScript expression that defines the value relative -to other property values or data accessible in the application. The property value is -automatically kept up to date if the other properties or data values change. +\section1 Properties -Property bindings are created implicitly in QML whenever a property is assigned an JavaScript -expression. The following QML uses two property bindings to connect the size of the rectangle -to that of \c otherItem. +QML components have \e properties that can be read and modified by other objects. +In QML, properties serve many purposes but their main function is to bind to +values. Values may be a \l{QML Basic Types}{basic type}, or other QML elements. -\code -Rectangle { - width: otherItem.width - height: otherItem.height -} -\endcode +The syntax for properties is: -QML extends a standards compliant JavaScript engine, so any valid JavaScript expression can be -used as a property binding. Bindings can access object properties, make function calls and even -use builtin JavaScript objects like \e {Date} and \e {Math}. Assigning a constant value to a -property can even be thought of as a binding - after all, a constant is a valid JavaScript -expression! Here are some examples of more complex bindings: - -\code -Rectangle { - function calculateMyHeight() { - return Math.max(otherItem.height, thirdItem.height); - } - - anchors.centerIn: parent - width: Math.min(otherItem.width, 10) - height: calculateMyHeight() - color: { if (width > 10) "blue"; else "red" } -} -\endcode +\tt{[default] property <type> <name>[: defaultValue]} -While syntactically bindings can be of arbitrary complexity, if a binding starts to become -overly complex - such as involving multiple lines, or imperative loops - it may be better -to refactor the component entirely, or at least factor the binding out into a separate -function. +Elements already possess useful properties but, to create custom properties, +precede the property name with the keyword \c property. -\section1 Changing Bindings - -The \l PropertyChanges element can be used within a state change to modify the bindings on -properties. - -This example modifies the \l Rectangle's width property binding to be \c {otherItem.height} -when in the "square" state. When it returns to its default state, width's original property -binding will have been restored. - -\code -Rectangle { - id: rectangle - width: otherItem.width - height: otherItem.height - - states: State { - name: "square" - PropertyChanges { - target: rectangle - width: otherItem.height - } - } -} -\endcode +\snippet doc/src/snippets/declarative/properties.qml parent begin +\snippet doc/src/snippets/declarative/properties.qml inherited properties +\snippet doc/src/snippets/declarative/properties.qml custom properties +\snippet doc/src/snippets/declarative/properties.qml parent end +QML property rules coincide with many of JavaScript's property rules, for example, +property names must begin with a lowercase letter. +\l {JavaScript Reserved Words}{JavaScript reserved words} are not valid property +names. -\section1 Binding Properties from JavaScript +\section1 Property Binding -When working with both QML and JavaScript, it is important to differentiate between -\l {Property Binding} syntax in QML and simple \e {property assignment} in JavaScript. Take -the example below, which uses property binding to ensure the item's \c height is always twice -its \c width: - -\qml -Item { - width: 100 - height: width * 2 -} -\endqml - -On the other hand, take the following JavaScript code snippet, which \e assigns, rather -than \e binds, the value of the \c height property: - -\code -Item { - width: 100 - - Component.onCompleted: { - height = width * 2 // if width changes later, height is not updated! - } -} -\endcode +Property binding is a declarative way of specifying the value of a property. Binding allows +a property's value to be expressed as an JavaScript expression that defines the value relative +to other property values or data accessible in the application. The property value is +automatically kept up to date if the other properties or data values change. -Instead of creating a property binding, this simply sets the \c height property to the correct -value \e {at the time that} the JavaScript code is invoked. Unlike the first example, the -\c height will never change if \c width changes. +Property bindings are created in QML using the colon "\c {:}" before the value: +\snippet doc/src/snippets/declarative/properties.qml property binding +The property binding causes the width of the \c Rectangle to update whenever the +\c {parent}'s width changes. -The \e {property : value} syntax for property binding is QML-specific and cannot be used in -JavaScript. Instead, to bind a property from JavaScript, assign a \e function to the property -that returns the required value. The following code correctly sets the property binding -created in the first example, but creates the binding in JavaScript rather than QML: +QML extends a standards compliant JavaScript engine, so any valid JavaScript expression can be +used as a property binding. Bindings can access object properties, make function calls and even +use built-in JavaScript objects such as \c {Date} and \c {Math}. +\snippet doc/src/snippets/declarative/properties.qml JavaScript sample -\qml -Item { - width: 100 +While syntactically bindings can be of arbitrary complexity, if a binding starts to become +overly complex - such as involving multiple lines, or imperative loops - it may be better +to refactor the component entirely, or at least factor the binding out into a separate +function. - Component.onCompleted: { - height = (function() { return width * 2 }) - } -} -\endqml +\keyword qml-javascript-assignment +\section1 Property Assignment versus Property Binding +When working with both QML and JavaScript, it is important to differentiate between +QML property binding and JavaScript value assignment. In QML, a property +binding is created using the colon "\c {:}". +\snippet doc/src/snippets/declarative/properties.qml property binding +The property binding causes the width of the \c Rectangle to update whenever the +\c {parent}'s width changes. -\section2 Using \c this to create a binding +Assigning a property value (using the equals sign "\c {=}") does not create a +property binding. +\snippet doc/src/snippets/declarative/properties.qml property assignment -When creating a property binding from JavaScript, QML allows the use of the \c this keyword to -refer to the object to which the property binding will be assigned. This allows one to -explicitly refer to a property within an object when there may be ambiguity about the exact -property that should be used for the binding. +Instead of creating a property binding, the assignment simply sets the \c Rectangle +\c width value to a number when the \c Component.onCompleted code is invoked. -For example, the \c Component.onCompleted handler below is defined within the scope of the -\l Item, and references to \c width within this scope would refer to the \l Item's width, rather -than that of the \l Rectangle. To bind the \l Rectangle's \c height to its own \c width, the -function needs to explicitly refer to \c this.width rather than just \c width. Otherwise, the -height of the \l Rectangle would be bound to the width of the \l Item and not the \l Rectangle. +Assigning a value to a property that is already bound will remove the previous binding. +A property can only have one value at a time (a list of property is one value), +and if any code explicitly re-sets this value, the property binding is removed. -\qml -Item { - width: 500 - height: 500 +There is no way to create a property binding directly from imperative JavaScript code, +although it is possible to use the \l {Using the Binding Element}{Binding} element. - Rectangle { - id: rect - width: 100 - color: "yellow" - } +\section1 Types of Properties - Component.onCompleted: { - rect.height = (function() { return this.width * 2 }) - } -} -\endqml +Properties may bind to different types, but they are are \e type-safe. That is, +properties only allow you to assign a value that matches the property type. For +example, if a property is a real, and if you try to assign a string to it you +will get an error. -(In this case, the function could also have referred to \c rect.width rather than \c this.width.) +\badcode +property real volume: "four" //generates an error +\endcode -Note that the value of \c this is not defined outside of its use in property binding. -See \l {QML JavaScript Restrictions} for details. +Certain properties bind to more complex types such as other elements and objects. + +\keyword qml-basic-property-types +\section2 Basic Property Types +Basic types such as \l int, \l real, and other Qt structures may be bound to +properties. For a list of types, visit the \l {QML Basic Types} document. -\section2 Effects of property assignment +\keyword qml-id-property +\section2 The \c id Property + +Each QML object may be given a special unique property called an \c id. +No other object within the same QML component (see \l{QML Documents}) can have +the same \c id value. QML objects may then access an object using the \c id +property. +\snippet doc/src/snippets/declarative/properties.qml id property +A component may readily access its parent's properties by using the \c parent +property. -Note that assigning a value to a property that is currently bound will remove the binding. -A property can only have one value at a time, and if any code explicitly sets this value, the -binding is removed. In the following example, although \c width has been bound to \c height, -the binding is removed by the JavaScript code that assigns \c width to 50: +Note that an \c id must begin with a lower-case letter or an underscore. The +\c id cannot contain characters other than letters, numbers, underscores, and +\l {JavaScript Reserved Words}{JavaScript reserved words}. + +\section2 Elements and Objects as Property Values -\code -Item { - width: height * 2 - height: 100 +Many properties bind to objects. For example, the \l Item element has a +\c states property that can bind to \l State elements. This type of property +binding allows elements to carry additional non-children elements. \c Item's +\c transitions property behaves in a similar way; it can bind to \l Transition +elements. + +Care must be taken when referring to the parent of an object property binding. +Elements and components that are bound to properties are not necessarily set +as children of the properties' component. + +\snippet doc/src/snippets/declarative/properties.qml object binding +The code snippet has a \l Gradient element that attempts to print its parent's +\c width value. However, the \c Gradient element is bound to the \c gradient +property, not the \c children property of the \c Rectangle. As a result, the +\c Gradient does not have the \c Rectangle as its parent. Printing the value +of \c{parent.width} generates an error. Printing the \c Rectangle object's +first child's \c name will print \c {childrectangle} because the second +\c Rectangle is bound to the \c children property. + +For more information about the \c children property, please read the +\l {Default Properties} section. + +\keyword attached-properties +\section2 Attached Properties + +Certain objects provide additional properties by \e attaching properties to other +objects. For example, the \l Keys element have properties that can \e attach to other QML +objects to provide keyboard handling. + +\snippet doc/src/snippets/declarative/properties.qml list attached property +The element \l ListView provides the delegate, \c listdelegate, the property +\c isCurrentItem as an attached property. The \c ListView.isCurrentItem +\e{attached property} provides highlight information to the delegate. +Effectively, the \l ListView element attaches the \c ListView.isCurrentItem +property to each delegate it creates. + +\keyword attached-signalhandlers +\section2 Attached Signal Handlers + +\e {Attached signal handlers} are similar +to \l{Attached Properties}{attached properties} in that they attach to objects +to provide additional functionality to objects. Two prominent elements, +\l Component and \l Keys element provide +\l{QML Signal and Handler Event System}{signal handlers} as attached signal +handlers. +\snippet doc/src/snippets/declarative/properties.qml attached signal handler + +Read the \l{QML Signal and Handler Event System} and the \l{Keyboard Focus in QML} +articles for more information. + +\section2 List properties + +Some properties may accept a binding to a list property, where more than one +component can bind to the property. List properties allow multiple +\l {State}{States}, \l {Gradient}{Gradients}, and other components to bind to a +single property. +\snippet doc/src/snippets/declarative/properties.qml list property +The list is enclosed in square brackets, with a comma separating the +list elements. In cases where you are only assigning a single item to a +list, you may omit the square brackets. +\snippet doc/src/snippets/declarative/properties.qml single property + +To access the list, use the \c index property. +\snippet doc/src/snippets/declarative/properties.qml print list property +The snippet code simply prints the name of the first state, \c FETCH. + + See the \l{list}{list type} documentation +for more details about list properties and their available operations. + +\keyword qml-grouped-properties +\section2 Grouped Properties + +In some cases properties form a logical group and use either the \e dot notation +or \e group notation. + +Grouped properties may be written both ways: +\snippet doc/src/snippets/declarative/properties.qml grouped properties + +In the element documentation grouped properties are shown using the dot notation. + +\section2 Property Aliases + +Unlike a property definition, which allocates a new, unique storage space for +the property, a property alias connects the newly declared property, called the +\e{aliasing property} as a direct reference to an existing property, the +\e{aliased property}. Read or write operations on the aliasing property results +in a read or write operations on the aliased property, respectively. + +A property alias declaration is similar to an ordinary property definition: + +\tt{[default] property alias <name>: <alias reference>} + +As the aliasing property has the same type as the aliased property, an explicit +type is omitted, and the special \c alias keyword is before the property name. +Instead of a default value, a property alias has a compulsory alias reference. +Accessing the aliasing property is similar to accessing a regular property. In +addition, the optional \c default keyword indicates that the aliasing property +is a \l{Default Properties}{default property}. + +\snippet doc/src/snippets/declarative/Button.qml property alias +When importing the component as a \c Button, the \c buttonlabel is directly +accessible through the \c label property. +\snippet doc/src/snippets/declarative/properties.qml alias usage +In addition, the \c id property may also be aliased and referred outside the +component. +\snippet doc/src/snippets/declarative/Button.qml parent begin +\snippet doc/src/snippets/declarative/Button.qml id alias +\snippet doc/src/snippets/declarative/Button.qml parent end +The \c imagebutton component has the ability to modify the child \l Image object + and its properties. +\snippet doc/src/snippets/declarative/properties.qml image alias + +Using aliases, properties may be exposed to the +\l{qml-top-level-component}{top level component}. Exposing properties to the +top-level component allows components to have interfaces similar to Qt widgets. + +\section3 Considerations for property aliases + +Aliases are only activated once the component +\l{Component::onCompleted}{completes} its initialization. An error is generated +when an uninitialized alias is referenced. Likewise, aliasing an aliasing +property will also result in an error. + +\snippet doc/src/snippets/declarative/properties.qml alias complete + +When importing the component, however, aliasing properties appear as regular Qt +properties and consequently can be used in alias references. + +It is possible for an aliasing property to have the same name as an existing +property, effectively overwriting the existing property. For example, +the following component has a \c color alias property, named the same as the built-in +\l {Rectangle::color} property: + +\snippet doc/src/snippets/declarative/properties.qml alias overwrite + +Any object that use this component and refer to its \c color property will be +referring to the alias rather than the ordinary \l {Rectangle::color} property. +Internally, however, the \c coloredrectangle can correctly set its \c color +property and refer to the actual defined property rather than the alias. + +The \l{declarative/ui-components/tabwidget}{TabWidget} example uses +aliases to reassign children to the \l ListView, creating a tab effect. + +\keyword default-properties +\section2 Default Properties - Component.onCompleted: { - width = 50; - } -} -\endcode +When imported, QML components will bind declared children to their designated +\e{default properties}. The optional \c default attribute specifies a property +as the \e {default property}. For example, the State element's default property +is its \l{State::changes}{changes} property. \l PropertyChanges elements +may simply be placed as the \c{State}'s children and they will be bound to the +\c changes property. +\snippet doc/src/snippets/declarative/properties.qml state default + +Similarly, the \l Item element's default property is its +\l{Item::data}{data} property. The \c data property manages Item's +\c children and \c resources properties. This way, different data types may be +placed as direct children of the \c Item. +\snippet doc/src/snippets/declarative/properties.qml default property +Reassigning a default property is useful when a component is reused. For +example, the \l{declarative/ui-components/tabwidget}{TabWidget} example uses +the \c default attribute to reassign children to the \l ListView, creating +a tab effect. -\section1 The Binding Element +\section1 Using the Binding Element -The implicit binding syntax shown previously is easy to use and works perfectly for most uses -of bindings. In some advanced cases, it is necessary to create bindings explicitly using the -\l Binding element. +In some advanced cases, it may be necessary to create bindings explicitly with +the\l Binding element. -For example, to bind a property exposed from C++ (\c system.brightness) to a value -coming from QML (\c slider.value), you could use the Binding element as follows: -\qml -Binding { - target: system - property: "brightness" - value: slider.value -} -\endqml +For example, to bind a property exposed from C++ (\c system.brightness) to a +value written in QML (\c slider.value), you could use the \l Binding element as +follows: +\snippet doc/src/snippets/declarative/properties.qml binding element +\section1 Changing Property Values in States +The \l PropertyChanges element is for setting property bindings within a +\l State element to set a property binding. + +\snippet doc/src/snippets/declarative/properties.qml PropertyChanges element +The rectangle's \c color property will bind to the \c warning component's +\c color property when its \c state is set to the \c WARNING state. */ - diff --git a/doc/src/declarative/qdeclarativedocument.qdoc b/doc/src/declarative/qdeclarativedocument.qdoc index b94e32e..423d77c 100644 --- a/doc/src/declarative/qdeclarativedocument.qdoc +++ b/doc/src/declarative/qdeclarativedocument.qdoc @@ -30,8 +30,6 @@ \title QML Documents \brief A description of QML documents and the kind of content they contain. -\section1 Introduction - A QML document is a block of QML source code. QML documents generally correspond to files stored on a disk or at a location on a network, but they can also be constructed directly from text data. @@ -42,17 +40,17 @@ Here is a simple QML document: QML documents are always encoded in UTF-8 format. -A QML document always begins with one or more import statements. To prevent elements -introduced in later versions from affecting existing QML programs, the element types -available within a document are controlled by the imported QML \l {Modules}. That is, +A QML document always begins with one or more import statements. To prevent elements +introduced in later versions from affecting existing QML programs, the element types +available within a document are controlled by the imported QML \l {Modules}. That is, QML is a \e versioned language. -Syntactically a QML document is self contained; QML does \e not have a preprocessor that -modifies the document prior to presentation to the QML runtime. \c import statements -do not "include" code in the document, but instead instruct the QML runtime on how to -resolve type references found in the document. Any type reference present in a QML -document - such as \c Rectangle and \c ListView - including those made within an -\l {Inline JavaScript}{JavaScript block} or \l {Property Binding}s, are \e resolved based exclusively on the +Syntactically a QML document is self contained; QML does \e not have a preprocessor that +modifies the document prior to presentation to the QML runtime. \c import statements +do not "include" code in the document, but instead instruct the QML runtime on how to +resolve type references found in the document. Any type reference present in a QML +document - such as \c Rectangle and \c ListView - including those made within an +\l {Inline JavaScript}{JavaScript block} or \l {Property Binding}s, are \e resolved based exclusively on the import statements. QML does not import any modules by default, so at least one \c import statement must be present or no elements will be available! @@ -63,12 +61,12 @@ resolved according to the document scope. \section1 Documents as Component Definitions -A QML document defines a single, top-level \l {QDeclarativeComponent}{QML component}. A QML component -is a template that is interpreted by the QML runtime to create an object with some predefined -behaviour. As it is a template, a single QML component can be "run" multiple times to -produce several objects, each of which are said to be \e instances of the component. +A QML document defines a single, top-level \l {QDeclarativeComponent}{QML component}. A QML component +is a template that is interpreted by the QML runtime to create an object with some predefined +behaviour. As it is a template, a single QML component can be "run" multiple times to +produce several objects, each of which are said to be \e instances of the component. -Once created, instances are not dependent on the component that created them, so they can +Once created, instances are not dependent on the component that created them, so they can operate on independent data. Here is an example of a simple "Button" component (defined in a \c Button.qml file) that is instantiated four times by \c application.qml. Each instance is created with a different value for its \c text property: @@ -80,7 +78,7 @@ Each instance is created with a different value for its \c text property: \row \o \snippet doc/src/snippets/declarative/qml-documents/qmldocuments.qml document -\o +\o \qml import QtQuick 1.0 @@ -112,23 +110,23 @@ to other QML components and applications in the same directory. \section1 Inline Components In addition to the top-level component that all QML documents define, and any reusable -components placed in separate files, documents may also -include \e inline components. Inline components are declared using the -\l Component element, as can be seen in the first example above. Inline components share +components placed in separate files, documents may also +include \e inline components. Inline components are declared using the +\l Component element, as can be seen in the first example above. Inline components share all the characteristics of regular top-level components and use the same \c import list as their -containing QML document. Components are one of the most basic building blocks in QML, and are +containing QML document. Components are one of the most basic building blocks in QML, and are frequently used as "factories" by other elements. For example, the \l ListView element uses the \c delegate component as the template for instantiating list items - each list item is just a new instance of the component with the item specific data set appropriately. -Like other \l {QML Elements}, the \l Component element is an object and must be assigned to a +Like other \l {QML Elements}, the \l Component element is an object and must be assigned to a property. \l Component objects may also have an object id. In the first example on this page, -the inline component is added to the \l Rectangle's \c resources list, and then -\l {Property Binding} is used to assign the \l Component to the \l ListView's \c delegate +the inline component is added to the \l Rectangle's \c resources list, and then +\l {Property Binding} is used to assign the \l Component to the \l ListView's \c delegate property. While using property binding allows the \l Component object to be shared (for example, -if the QML document contained multiple \l ListView's with the same delegate), in this case the -\l Component could have been assigned directly to the \l ListView's \c delegate. The QML -language even contains a syntactic optimization when assigning directly to a component property +if the QML document contained multiple \l ListView's with the same delegate), in this case the +\l Component could have been assigned directly to the \l ListView's \c delegate. The QML +language even contains a syntactic optimization when assigning directly to a component property for this case where it will automatically insert the \l Component tag. These final two examples are behaviorally identical to the original document. diff --git a/doc/src/declarative/qdeclarativei18n.qdoc b/doc/src/declarative/qdeclarativei18n.qdoc index 9ca8938..bbee37c 100644 --- a/doc/src/declarative/qdeclarativei18n.qdoc +++ b/doc/src/declarative/qdeclarativei18n.qdoc @@ -27,9 +27,12 @@ /*! \page qdeclarativei18n.html +\ingroup qml-features +\contentspage QML Features +\previouspage {Network Transparency}{Loading Resources in QML} +\nextpage {QML Features} \title QML Internationalization -\section1 Overview Strings in QML can be marked for translation using the qsTr(), qsTranslate(), QT_TR_NOOP(), and QT_TRANSLATE_NOOP() functions. diff --git a/doc/src/declarative/qdeclarativemodels.qdoc b/doc/src/declarative/qdeclarativemodels.qdoc index 9409eaf..23dd390 100644 --- a/doc/src/declarative/qdeclarativemodels.qdoc +++ b/doc/src/declarative/qdeclarativemodels.qdoc @@ -27,10 +27,14 @@ /*! \page qdeclarativemodels.html +\ingroup qml-features +\contentspage QML Features +\previouspage {QML Animation and Transitions}{Animation and Transitions} +\nextpage {Presenting Data with Views} \target qmlmodels \title QML Data Models -QML items such as ListView, GridView and \l Repeater require Data Models +QML items such as ListView, GridView and \l Repeater require Data Models that provide the data to be displayed. These items typically require a \e delegate component that creates an instance for each item in the model. Models may be static, or @@ -38,7 +42,7 @@ have items modified, inserted, removed or moved dynamically. Data is provided to the delegate via named data roles which the delegate may bind to. Here is a ListModel with two roles, \e type and \e age, -and a ListView with a delegate that binds to these roles to display their +and a ListView with a delegate that binds to these roles to display their values: \snippet doc/src/snippets/declarative/qml-data-models/listmodel-listview.qml document @@ -48,7 +52,7 @@ properties, the roles can be accessed with the qualified \e model name instead. For example, if a \l Text element had \e type or \e age properties, the text in the above example would display those property values instead of the \e type and \e age values from the model item. In this case, the properties could have been referenced as -\c model.type and \c model.age instead to ensure the delegate displays the +\c model.type and \c model.age instead to ensure the delegate displays the property values from the model item. A special \e index role containing the index of the item in the model @@ -68,11 +72,13 @@ QML provides several types of data models among the built-in set of QML elements. In addition, models can be created with C++ and then made available to QML components. -The views used to access data models are described in \l{Presenting Data with QML}. +The views used to access data models are described in the +\l{Presenting Data with Views} overview. The use of positioner items to arrange items from a model is covered in \l{Using QML Positioner and Repeater Items}. +\keyword qml-data-models \section1 QML Data Models \section2 ListModel @@ -108,7 +114,7 @@ XmlListModel allows construction of a model from an XML data source. The roles are specified via the \l XmlRole element. The following model has three roles, \e title, \e link and \e description: -\code +\qml XmlListModel { id: feedModel source: "http://rss.news.yahoo.com/rss/oceania" @@ -117,7 +123,7 @@ XmlListModel { XmlRole { name: "link"; query: "link/string()" } XmlRole { name: "description"; query: "description/string()" } } -\endcode +\endqml The \l{demos/declarative/rssnews}{RSS News demo} shows how XmlListModel can be used to display an RSS feed. @@ -125,31 +131,19 @@ be used to display an RSS feed. \section2 VisualItemModel -VisualItemModel allows QML items to be provided as a model. +VisualItemModel allows QML items to be provided as a model. This model contains both the data and delegate; the child items of a -VisualItemModel provide the contents of the delegate. The model +VisualItemModel provide the contents of the delegate. The model does not provide any roles. -\code - VisualItemModel { - id: itemModel - Rectangle { height: 30; width: 80; color: "red" } - Rectangle { height: 30; width: 80; color: "green" } - Rectangle { height: 30; width: 80; color: "blue" } - } - - ListView { - anchors.fill: parent - model: itemModel - } -\endcode +\snippet doc/src/snippets/declarative/models/visual-model-and-view.qml visual model and view Note that in the above example there is no delegate required. The items of the model itself provide the visual elements that will be positioned by the view. - +\keyword qml-c++-models \section1 C++ Data Models Models can be defined in C++ and then made available to QML. This is useful @@ -165,7 +159,7 @@ models. A model may be a simple QStringList, which provides the contents of the list via the \e modelData role. -Here is a ListView with a delegate that references its model item's +Here is a ListView with a delegate that references its model item's value using the \c modelData role: \snippet examples/declarative/modelviews/stringlistmodel/view.qml 0 @@ -184,7 +178,7 @@ the model by calling QDeclarativeContext::setContextProperty() again. \section2 QObjectList-based model -A list of QObject* values can also be used as a model. A QList<QObject*> provides +A list of QObject* values can also be used as a model. A QList<QObject*> provides the properties of the objects in the list as roles. The following application creates a \c DataObject class that with @@ -205,7 +199,7 @@ the ListView delegate: \snippet examples/declarative/modelviews/objectlistmodel/view.qml 0 -Note the use of the fully qualified access to the \c color property. +Note the use of the fully qualified access to the \c color property. The properties of the object are not replicated in the \c model object, since they are easily available via the \c modelData object. @@ -221,10 +215,10 @@ the model by calling QDeclarativeContext::setContextProperty() again. A model can be defined by subclassing QAbstractItemModel. This is the best approach if you have a more complex model that cannot be supported -by the other approaches. A QAbstractItemModel can also automatically +by the other approaches. A QAbstractItemModel can also automatically notify a QML view when the model data has changed. -The roles of a QAbstractItemModel subclass can be exposed to QML by calling +The roles of a QAbstractItemModel subclass can be exposed to QML by calling QAbstractItemModel::setRoleNames(). The default role names set by Qt are: \table @@ -244,9 +238,9 @@ that has \e type and \e size roles. It calls QAbstractItemModel::setRoleNames() role names for accessing the properties via QML: \snippet examples/declarative/modelviews/abstractitemmodel/model.h 0 -\dots +\dots \snippet examples/declarative/modelviews/abstractitemmodel/model.h 1 -\dots +\dots \snippet examples/declarative/modelviews/abstractitemmodel/model.h 2 \codeline \snippet examples/declarative/modelviews/abstractitemmodel/model.cpp 0 @@ -261,14 +255,14 @@ roles: QML views are automatically updated when the model changes. Remember the model must follow the standard rules for model changes and notify the view when -the model has changed by using QAbstractItemModel::dataChanged(), +the model has changed by using QAbstractItemModel::dataChanged(), QAbstractItemModel::beginInsertRows(), etc. See the \l {Model subclassing reference} for more information. The complete example is available in Qt's \l {declarative/modelviews/abstractitemmodel}{examples/declarative/modelviews/abstractitemmodel} directory. QAbstractItemModel presents a hierarchy of tables, but the views currently provided by QML -can only display list data. +can only display list data. In order to display child lists of a hierarchical model the VisualDataModel element provides several properties and functions for use with models of type QAbstractItemModel: @@ -283,14 +277,14 @@ with models of type QAbstractItemModel: \section2 Exposing C++ Data Models to QML -The above examples use QDeclarativeContext::setContextProperty() to set -model values directly in QML components. An alternative to this is to -register the C++ model class as a QML type from a QML C++ plugin using -QDeclarativeExtensionPlugin. This would allow the model classes to be +The above examples use QDeclarativeContext::setContextProperty() to set +model values directly in QML components. An alternative to this is to +register the C++ model class as a QML type from a QML C++ plugin using +QDeclarativeExtensionPlugin. This would allow the model classes to be created directly as elements within QML: \table -\row +\row \o \code @@ -299,7 +293,7 @@ class MyModelPlugin : public QDeclarativeExtensionPlugin public: void registerTypes(const char *uri) { - qmlRegisterType<MyModel>(uri, 1, 0, + qmlRegisterType<MyModel>(uri, 1, 0, "MyModel"); } } @@ -339,7 +333,7 @@ An integer can be used to specify a model that contains a certain number of elements. In this case, the model does not have any data roles. The following example creates a ListView with five elements: -\code +\qml Item { width: 200; height: 250 @@ -355,7 +349,7 @@ Item { } } -\endcode +\endqml \section2 An Object Instance @@ -367,7 +361,7 @@ The example below creates a list with one item, showing the color of the \e myText text. Note the use of the fully qualified \e model.color property to avoid clashing with \e color property of the Text element in the delegate. -\code +\qml Rectangle { width: 200; height: 250 @@ -389,7 +383,7 @@ Rectangle { delegate: myDelegate } } -\endcode +\endqml \section1 Accessing Views and Models from Delegates @@ -408,44 +402,7 @@ In the following example, the delegate shows the property \e{language} of the model, and the color of one of the fields depends on the property \e{fruit_color} of the view. -\code -Rectangle { - width: 200; height: 200 - - ListModel { - id: fruitModel - property string language: "en" - ListElement { - name: "Apple" - cost: 2.45 - } - ListElement { - name: "Orange" - cost: 3.25 - } - ListElement { - name: "Banana" - cost: 1.95 - } - } - - Component { - id: fruitDelegate - Row { - Text { text: " Fruit: " + name; color: ListView.view.fruit_color } - Text { text: " Cost: $" + cost } - Text { text: " Language: " + ListView.view.model.language } - } - } - - ListView { - property color fruit_color: "green" - model: fruitModel - delegate: fruitDelegate - anchors.fill: parent - } -} -\endcode +\snippet doc/src/snippets/declarative/models/views-models-delegates.qml rectangle Another important case is when some action (e.g. mouse click) in the delegate should update data in the model. In this case you can define @@ -457,92 +414,11 @@ a function in the model, e.g.: ...and call it from the delegate using: -\code +\js ListView.view.model.setData(index, field, value) -\endcode +\endjs ...assuming that \e{field} holds the name of the field which should be updated, and that \e{value} holds the new value. */ - -/*! -\page qml-presenting-data.html -\title Presenting Data with QML - -\section1 Introduction - -Qt Quick contains a set of standard items that can be used to present data in a -number of different ways. For simple user interfaces, -\l{Using QML Positioner and Repeater Items#Repeaters}{Repeaters} can be used -in combination with -\l{Using QML Positioner and Repeater Items#Positioners}{Positioners} -to obtain pieces of data and arrange them in a user interface. However, when -large quantities of data are involved, it is often better to use models with -the standard views since these contain many built-in display and navigation -features. - -\section1 Views - -Views are scrolling containers for collections of items. They are feature-rich, -supporting many of the use cases found in typical applications, and can be -customized to meet requirements on style and behavior. - -A set of standard views are provided in the basic set of Qt Quick -graphical elements: - -\list -\o \l{#ListView}{ListView} arranges items in a horizontal or vertical list -\o \l{#GridView}{GridView} arranges items in a grid within the available space -\o \l{#PathView}{PathView} arranges items on a path -\endlist - -Unlike these items, \l WebView is not a fully-featured view item, and needs -to be combined with a \l Flickable item to create a view that performs like -a Web browser. - -\section2 ListView - -\l ListView shows a classic list of items with horizontal or vertical placing -of items. - -\div{float-right} -\inlineimage qml-listview-snippet.png -\enddiv - -The following example shows a minimal ListView displaying a sequence of -numbers (using an \l{QML Data Models#An Integer}{integer as a model}). -A simple delegate is used to define an items for each piece of data in the -model. - -\clearfloat -\snippet doc/src/snippets/declarative/listview/listview-snippet.qml document - - - -\section2 GridView - -\l GridView displays items in a grid like an file manager's icon view. - -\section2 PathView - -\l PathView displays items on a path, where the selection remains in -the same place and the items move around it. - -\section1 Decorating Views - -\section2 Headers and Footers - -\section2 Sections - -\section2 Navigation - -In traditional user interfaces, views can be scrolled using standard -controls, such as scroll bars and arrow buttons. In some situations, it -is also possible to drag the view directly by pressing and holding a -mouse button while moving the cursor. In touch-based user interfaces, -this dragging action is often complemented with a flicking action, where -scrolling continues after the user has stopped touching the view. - -\section1 Further Reading -*/ diff --git a/doc/src/declarative/qdeclarativestates.qdoc b/doc/src/declarative/qdeclarativestates.qdoc index 6d5aebc..655b647 100644 --- a/doc/src/declarative/qdeclarativestates.qdoc +++ b/doc/src/declarative/qdeclarativestates.qdoc @@ -27,197 +27,110 @@ /*! \page qdeclarativestates.html +\ingroup qml-features +\contentspage QML Features +\previouspage {Importing Reusable Components} +\nextpage {QML Animation and Transitions}{Animation and Transitions} \target qmlstates \title QML States -\section1 Overview - -User interfaces are designed to present different interface configurations in -different scenarios, or to modify their appearances in response to user -interaction. Often, there are a set of changes that are made concurrently, such -that the interface could be seen to be internally changing from one \e state to -another. +\section1 States Elements +\list +\o \l State +\o \l PropertyChanges +\o \l StateGroup +\o \l StateChangeScript +\o \l ParentChange +\o \l AnchorChanges +\endlist -This applies generally to interface elements regardless of their complexity. -A photo viewer may initially present images in a grid, and when an image is -clicked, change to a "detailed" state where the individual image is expanded -and the interface is changed to present new options for image editing. On the -other end of the scale, when a simple button is pressed, it may change to a -"pressed" state in which its color and position is modified to give a pressed -appearance. +Many user interface designs are \e state driven; interfaces have configurations +that differ depending on the current state. For example, a traffic signal will +configure its flags or lights depending on its state. While in the signal's +\c stop state, a red light will turn on while the yellow and the green lights +will turn off. In the \c caution state, the yellow light is on while the other +lights are turned off. -In QML, any object can change between different \e states to apply sets of -changes that modify the properties of relevant items. Each \e state could -present a different configuration that could, for example: +In QML, \e states are a set of property configurations defined in a \l State +element. Different configurations could, for example: \list \o Show some UI elements and hide others \o Present different available actions to the user -\o Start, stop or pause animations +\o Start, stop, or pause animations \o Execute some script required in the new state \o Change a property value for a particular item -\o Show a different view or "screen" +\o Show a different view or screen \endlist -Changes between states can be animated using \l {Transitions}{transitions}, as -discussed further below. - -All \l {Item}-based objects have a \e {default state}, and can specify additional -states by adding new \l State objects to the item's \l {Item::}{states} -property. Each state has a \e name that is unique for all states within that -item; the default state's name is an empty string. To change the current state +All \l {Item}-based objects have a \c state property, and can specify additional +states by adding new \c State objects to the item's \l {Item::}{states} +property. Each state within a component has a unique \c name, an empty string +being the default. To change the current state of an item, set the \l {Item::}{state} property to the name of the state. -Non-Item objects can use states through the StateGroup element. - +Non-Item objects may use states through the \l StateGroup element. \section1 Creating States To create a state, add a \l State object to the item's \l {Item::}{states} property, which holds a list of states for that item. -Following is an example. Here, the \l Rectangle is initially placed in the -default (0, 0) position. It has defined an additional state named "moved", in -which a PropertyChanges object repositions the rectangle to (50, 50). Clicking -within the MouseArea changes the state to the "moved" state, thus moving the \l -Rectangle. - -\snippet doc/src/snippets/declarative/states.qml 0 - -The \l State item defines all the changes to be made in the new state. It -could specify additional properties to be changed, or create additional -PropertyChanges for other objects. It can also modify the properties of other -objects, not just the object that owns the state. For example: - -\qml -Rectangle { - // ... - states: [ - State { - name: "moved" - PropertyChanges { target: myRect; x: 50; y: 50; color: "blue" } - PropertyChanges { target: someOtherItem; width: 1000 } - } - ] -} -\endqml - -As a convenience, if an item only has one state, its \l {Item::}{states} -property can be defined as a single \l State, without the square-brace list -syntax: - -\snippet doc/src/snippets/declarative/propertyanimation.qml single state - -A \l State is not limited to performing modifications on property values. It -can also: - +A warning \c signal component may have two states, the \c NORMAL and the +\c CRITICAL state. Suppose that in the \c NORMAL state, the \c color of the +signal should be \c green and the warning \c flag is down. Meanwhile, in the +\c CRITICAL state, the \c color should be \c red and the flag is \c up. We may +model the states using the \c State element and the color and flag +configurations with the \c PropertyChanges element. +\snippet doc/src/snippets/declarative/states.qml signal states +The \l PropertyChanges element will change the values of object properties. +Objects are referenced through their \l {qml-id-property}{id}. Objects outside +the component are also referenced using the \c id property, exemplified by the +property change to the external \c flag object. + +Further, the state may change by assigning the \c state property with the +appropriate signal state. A state switch could be in a \l MouseArea element, +assigning a different state whenever the signal receives a mouse click. +\snippet doc/src/snippets/declarative/states.qml switch states + +The State element is not limited to performing modifications on property values. +It can also: \list -\o Run some script using StateChangeScript -\o Override an existing signal handler for an object using PropertyChanges -\o Re-parent an \l Item using ParentChanges -\o Modify anchor values using AnchorChanges +\o Run some script using \l StateChangeScript +\o Override an existing signal handler for an object using \l PropertyChanges +\o Re-parent an \l Item using \l ParentChange +\o Modify anchor values using \l AnchorChanges \endlist -The \l {declarative/animation/states}{States and Transitions example} -demonstrates how to declare a basic set of states and apply animated -transitions between them. - - \section1 The Default State -Of course, the \l Rectangle in the example above could have simply been moved -by setting its position to (50, 50) in the mouse area's \c onClicked handler. -However, aside from enabling batched property changes, one of the features of -QML states is the ability of an item to revert to its \e {default state}. -The default state contains all of an item's initial property values before -they were modified in a state change. - -For example, suppose the \l Rectangle should move to (50,50) when the mouse is -pressed, and then move back to its original position when the mouse is -released. This can be achieved by using the \l {State::}{when} property, -like this: - -\qml -Rectangle { - // ... - - MouseArea { - id: mouseArea - anchors.fill: parent - } - - states: State { - name: "moved" - when: mouseArea.pressed - // ... - } -} -\endqml - -The \l {State::}{when} property is set to an expression that evaluates to -\c true when the item should be set to that state. When the mouse is pressed, -the state is changed to \e moved. When it is released, the item reverts to its -\e default state, which defines all of the item's original property values. - -Alternatively, an item can be explicitly set to its default state by setting its -\l {Item::}{state} property to an empty string (""). For example, instead of -using the \l {State::}{when} property, the above code could be changed to: - -\qml -Rectangle { - // ... - - MouseArea { - anchors.fill: parent - onPressed: myRect.state = 'moved'; - onReleased: myRect.state = ''; - } - - states: State { - name: "moved" - // ... - } -} -\endqml - -Obviously it makes sense to use the \l {State::}{when} property when possible -as it provides a simpler (and a better, more declarative) solution than -assigning the state from signal handlers. - - -\section1 Animating State Changes +Every \l Item based component has a \c state property and a \e{default state}. +The default state is the empty string (\c{""}) and contains all of an item's +initial property values. The default state is useful for managing property +values before state changes. Setting the \c state property to an empty string +will load the default state. +\section1 The \c when Property -State changes can be easily animated through \l {Transitions}{transitions}. A -\l Transition defines the animations that should be applied when an item -changes from one state to another. +For convenience, the \l State element has a \c when property that can bind to +expressions to change the state whenever the bound expression evaluates to +\c true. The \c when property will revert the state back to the +\l {The Default State}{default state} when the expression evaluates to false. -If the above example was modified to include the following \l Transition, the -movement of the \l Rectangle would be animated: +\snippet doc/src/snippets/declarative/states.qml when property +The \c bell component will change to the \c RINGING state whenever the +\c signal.state is \c CRITICAL. -\qml -Rectangle { - // ... - - MouseArea { - // Handle mouse events... - } +\section1 Animating State Changes - states: [ - // States are defined here... - ] - - transitions: [ - Transition { - NumberAnimation { properties: "x,y"; duration: 500 } - } - ] - } -\endqml +State changes induce abrupt value changes. The \l Transition element allow +smoother changes during state changes. In transitions, animations and +interpolation behaviors are definable. The +\l {QML Animation and Transitions}{Animation and Transitions} article has more +information about creating state animations. -This \l Transition defines that if any \c x or \c y properties have changed -during a state change within this item, their values should be animated over 500 -milliseconds. +The \l {declarative/animation/states}{States and Transitions example} +demonstrates how to declare a basic set of states and apply animated +transitions between them. -See the \l Transitions documentation for more information. */ diff --git a/doc/src/declarative/qml-intro.qdoc b/doc/src/declarative/qml-intro.qdoc deleted file mode 100644 index 3f3e0e4..0000000 --- a/doc/src/declarative/qml-intro.qdoc +++ /dev/null @@ -1,616 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 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:FDL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of this -** file. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - - - -/*! -\page qml-intro.html -\title Intro to Qt Quick - -\section1 Overview - -QML is a high level, scripted language. Its commands, more correctly \e elements, -leverage the power and efficiency of the Qt libraries to make easy to use -commands that perform intuitive functions. Draw a rectangle, display an image at -a position and so on. Behind these elements are complex C++ libraries that -efficiently perform the action. As with any graphical application, always -consider that this ability to easily build graphically rich applications means -that some care may be needed to prevent performance problems. - -The language also allows more flexibility of these commands by using -Javascript rather than C++ to add new layers of logic to your application. -Javascript is easier to learn than C++ and can be embedded into the QML -files or imported from a separate file. - -\bold{In QML the types of various 'objects' are referred to as \l {QML -Elements}{elements}}. - -An element usually has various \e properties that help define the element. For -example, if we created an element called Circle then the radius of the circle -would be a property. - - -\section1 A First Look - -The basic syntax of an \l{QML Elements}{element} is - -\qml -SomeElement { - id: myObject - // ... some other things here ... -} -\endqml - -Here we are defining a new object. We specify its 'type' first as SomeElement. -Then within matching braces { ... } we specify the various parts of our -element. - -The \c id is a unique identifier for the element, it must start with a lower -case letter and only contain letters, numbers and underscores. It is this -particular object's name. If this SomeElement \l {QML Elements}{element} was -a Rectangle instead and it was one of many then the \e optional unique id -would allow us to manipulate each element individually. - -Each visual element is ultimately based on, or inherits from, an element -called \l Item. \l Item has certain properties and actions that may be -useful. The properties have default values so you need only specify the -ones you will need. - -Take a simple element such as a \l Rectangle. It has an \c id, we will call -it \e myRectangle, it has a \c width and a \c height. Imagine that we -want a rectangle that is 500 pixels by 400 pixels in the x and y directions -(horizontal by vertical). - -We can implement this \l Rectangle with these properties this way - -\snippet doc/src/snippets/declarative/qml-intro/rectangle.qml document - -This is a valid QML script. To run it, copy it and save it to a file, say -myexample.qml, and on the command line run the following command: - -\code -qmlviewer myexample.qml -\endcode - -On Mac OS X, open the "QMLViewer" application instead and open the -\c myexample.qml file, or run it from the command line: - -\code -QMLViewer.app/Contents/MacOS/QMLViewer myexample.qml -\endcode - -It will create a very boring rectangle in its own window. - - -\section1 Hello World! - -We can now add some color and text to make a Hello World QML program. - -\l Rectangle has the property \l{Rectangle::color}{color} to produce a -background color. - -Text is handled by a different element called \l Text. We need to create a -\l Text object inside the \l Rectangle and set its \l{Text::}{text} -property to "Hello World!". So to set the text to "Hello world" and the -background colour to light gray, - -\snippet doc/src/snippets/declarative/qml-intro/hello-world1.qml document - - -\section1 Hello World Again - -From now on we will not always show the import statement for Qt but it -should still be there when you create your QML scripts. - -To make our Hello World example a little nicer set the position of the text -to be at pixel position x = 100, y = 100 within the displayed window. This -position belongs to the \l Text element so we set the position inside its -definition. Note that we separate different QML statements on the same line -with a semi-colon, or we could have simply put each statement on a new line - -\snippet doc/src/snippets/declarative/qml-intro/hello-world2.qml updated text - -Not only did we reposition the text, but the text was altered by adding -HTML tags to change the font size. The text color was also changed from the -default black to dark green by using a standard string for the color's SVG -name. - -We could also have used a hexadecimal string for the RGB (red-green-blue, as -#rrggbb) values of the color similar to the method used in HTML. For -example, mostly blue with a green tint, - -\snippet doc/src/snippets/declarative/qml-intro/hello-world3.qml updated text - -All of these changes occurred within the \l Text object which is the scope -of these property changes. - -Other objects may use the information but it belongs to the element where -the property has been defined. - - -\section1 Images - -To add an image to our little application we use the \l Image element. An -\l Image uses a path to an image file, and has properties to control -the aspect ratio, the image size, to tile the area amongst others. The -source of the image, the path to the file, is a URL. Therefore the file can -be local: \e {mydir/myimage1.png}. Or it can be remote: -\e {"http://www.example.com/images/myimage1.png"}. - -\snippet doc/src/snippets/declarative/qml-intro/hello-world4.qml added an image - -This displays the image, as we would expect, at the top left of the window. -The position of the default x = 0, y = 0 coordinate. The example here uses -a PNG file, but it could have been one of various supported formats, -including JPG and GIF. - -Let us reposition the image and enlarge it. Place it at the same 'x' offset -as the "Hello world again" text, but put it another 50 pixels below the -text, also make it 150 by 150 pixels in size, - -\snippet doc/src/snippets/declarative/qml-intro/hello-world5.qml positioning the image - -Adding the Hello World example, with the text and the image example we can -write a simple piece of QML that starts to look a bit better. - -\snippet doc/src/snippets/declarative/qml-intro/hello-world5.qml document - -The result is still quite simple - -\image qml-intro-helloa.png - - -\section1 Anchors: Aligning Elements - -Using absolute positioning, such as saying x = 100 and y = 150, works well -until the user or developer stretches or increases the size of the window. -Then the positions need to be recalculated. What would be nice would be a -relative means of positioning of objects in a window or rectangle. For -example, we want to place an image at the bottom of a rectangle, we would -like to specify the image's location as the 'bottom of the window', not a -specific coordinate. We can do this with the anchors property, which -objects inherit from Item. - -The anchors property is really a property group. It is a collection of -related properties. It has properties within it which can be used by means -of the dot notation. - -The dot notation uses object \c{id}s and property names to use a particular -object or property. Say I have a rectangle r1, which contains a rectangle -r2, which contains an Item item1, which has an 'x' property I want to -change. I just use the dot notation to identify it: r1.r2.item1.x - -If we want to position an image at the bottom of the rectangle it is -inside. I have to specify that the bottom of the image is also at the -bottom of the rectangle - -\snippet doc/src/snippets/declarative/qml-intro/anchors1.qml document - -This places the logo at the bottom left of the window. - -\image qml-intro-anchors1.png "A simple anchor" - -We would like it centered and not touching the bottom of the window, for -aesthetic reasons. For the centering we use the horizontalCenter property, -and to prevent the touching of the image to the bottom of the rectangle, -the bottomMargin property is used. So the new actions for the script are - - \list - \o set the bottom of the image (anchors.bottom) to be the bottom of the window - \o move the image to be in the horizontal center of the window - \o set a margin of 10 pixels so that the image does not touch the bottom window border - \endlist - -Encoded into QML the script becomes - -\snippet doc/src/snippets/declarative/qml-intro/anchors2.qml document - -Run this and resize the window. You will see that now the position of the -image adjusts during the resize. - -\image qml-intro-anchors2.png "Image Centered at the Bottom" - -You can also add another object say a block of descriptive text and place -it above or below the image or to the side. This code places some text just -above the image - -\snippet doc/src/snippets/declarative/qml-intro/anchors3.qml adding some text - -\image qml-intro-anchors3.png - -\note \e anchors is a property group, to be used within the object. When -referencing these properties from another object we use the property -directly, instead of saying: - -\qml -Item { - anchors.bottom: myRectangle.anchors.top // Wrong -} -\endqml - -we use - -\qml -Item { - anchors.bottom: myRectangle.top // Correct -} -\endqml - - -\section1 Transformations - -We can transform a graphical object to get additional effects. Rotate a -piece of text by 180 degrees to display upside-down text. Rotate an image -by 90 degrees to lay it on its side. These transformations require -additional information. - -For rotation, the additional information includes: the origin relative to -the object being rotated, the axis of rotation, and the angle in degrees to -rotate the image through in a clockwise direction. The axis does not have -to be the z-axis, the line between your eyes and the image, it could be -along the vertical y-axis or the horizontal x-axis. We have three -dimensions to play with. For simplicity in this example we will rotate -about the z-axis by 90 degrees in a negative direction, anti-clockwise. - -Rotation of text was also suggested. It could also be useful to scale the -text. We can do both. The \l {Item::transform}{transform} property is a -\e list of \l Transform elements, so using the list syntax -\c{myList: [ listElement1, listElement2, ... } ]} -we can produce a list of transformations. - -The text will be rotated by 45 degrees anti-clockwise and scaled -vertically by a factor of 1.5 and by 1.2 horizontally. - -Using the example above as the basis for this we have, - -\snippet doc/src/snippets/declarative/qml-intro/transformations1.qml document - -The code block in \c image1 starting with \c transform specifies that the -\l {Item::transform}{transform} property will be a Rotation through -90 -degrees, which is anti-clockwise, about the z-axis running through the -center of the image at (75,75), since the image is 150 x 150 pixels. - -The other transformation available is \l Translate. This produces a change -in position of the item. - -\note In a list of transformations the order of the transformations is -important. In the above example try swapping around the Scale transform with -the Rotation transform, remember to remove or add the comma. The results are -acceptable for our little test but not the same. - - -\section1 Animations - -Animation in QML is done by animating properties of objects. Properties -that are numbers, colors, Rectangles, points and directions. In QML these -are \l {QML Basic Types} named as real, int, color, rect, point, size, and -vector3d. There are a number of different ways to do animation. Here we -will look at a few of them. - -\section2 Number Animation - -Previously we have used a rotation transformation to change the orientation -of an image. We could easily animate this rotation so that instead of a -straight rotation counter-clockwise of 90 degrees we could rotate the image -through a full 360 degrees in an animation. The axis of rotation wont -change, the position of the center of the image will not change, only the -angle will change. Therefore, a NumberAnimation of a rotation's angle should -be enough for the task. If we wish for a simple rotation about the center -of the image then we can use the \c rotation property that is inherited -from \l Item. The rotation property is a real number that specifies the -angle in a clockwise direction for the rotation of the object. Here is the -code for our animated rotating image. - -\snippet doc/src/snippets/declarative/qml-intro/number-animation1.qml document - -The \c {transformOrigin: Item.Center} is redundant since this is the default -axis of rotation anyway. But if you change \c Center to \c BottomRight you -will see an interesting variation. - -Also if instead the \l Rotation transformation had been used then we would have -more control over the various parameters. We could vary the axis, to be not -just a different offset from the z-axis but along the y-axis, x-axis or -combination. For example, if the task had been to animate the rotation -about the y-axis passing through the center of the image then the following -code would do it. - -\snippet doc/src/snippets/declarative/qml-intro/number-animation2.qml document - -Here there is a rectangle 600 by 400 pixels. Placed within that rectangle -is an image 100 by 100 pixels. It is rotated about the center of the image -about the y-axis so that it looks as if it is rotating about an invisible -vertical string holding it up. The time it takes to complete the rotation is 3 -seconds (3,000 milliseconds). The NumberAnimation is applied to the angle -taking it from 0 (no change) to 360 degrees, back where it started. -Strictly speaking it isn't necessary to go from 0 to 360 since the same -location is duplicated, but it makes it easier to read in this example and -it has no visible effect on the animation. The number of loops that the -animation will execute is set to \c {Animation.Infinite} which means that the -animation is in an endless loop. - -To see an interesting variation. Change the axis to \c {axis { x:1; y:1; z:1 -}}. This is a line coming from the center of the image downwards to the -right and out of the screen. Although the change is simple the rotation -seems complex. - -\section2 Sequential Animation - -For a more complex animation we will need two images. The first image will -be placed at the center of a window (Rectangle) and the second image will -be at the upper left of the window. The animation will move the second -image from the top left of the window to the bottom right. In doing so we -will be animating the position and the size of the image. - -First create two images - -\snippet doc/src/snippets/declarative/qml-intro/sequential-animation1.qml document - -We will add to 'image1' a SequentialAnimation from x = 20 to the target of -x = 450. The 'from' values will be used because we will be repeating the -animation, so the object needs to know where the original position is, both -x and y. The SequentialAnimation of x will set it to repeat by indicating -that the number of animation loops is infinite, meaning that the 'loop' -counter will be set to a value Animation.Infinite that indicates an endless -cycle. Also there will be a NumberAnimation to vary the numeric property -between the x values and over a given duration. After the NumberAnimation -there will be a PauseAnimation that will pause the animation for 500 -milliseconds (half a second) simply for the visual effect. - -\snippet doc/src/snippets/declarative/qml-intro/sequential-animation2.qml adding a sequential animation - -A similar block of code is written for the animation of the 'y' value of -the position. - -We will also animate the scale of the object, so as it goes from top left -to bottom right of the window it will become smaller until about midway, -and then become larger. To complete the animation we will set the 'z' -values of the images. 'z' is the stacking order, the z-axis effectively -points out from the screen to your eyes with the default value of 'z' being -0. So if we set the Rectangle to have z with value zero, just to be sure, -and image1 to 1 and image2 to 2 then image2 will be in the foreground and -image1 in the background. When image1 passes image2 it will pass behind it. -The completed code looks like - -\snippet doc/src/snippets/declarative/qml-intro/sequential-animation3.qml document - -The \c {easing.type} has many options, expressed as a string. It specifies the -kind of equation that describes the acceleration of the property value, not -necessarily position, over time. - -For example, \e InOutQuad means that at the start and the end of the animation the -'velocity' is low but the acceleration or deceleration is high. Much like a car -accelerating from stop, and decelerating to stop at the end of a journey, -with the maximum speed being in the middle. Examine the \l {PropertyAnimation::easing.type} -{easing} documentation and the various graphs that show the effect. The horizontal -axis, 'progress', can be thought of as time. The vertical axis is the value -of the particular property. - -In discussing animation we need to describe three objects: State, MouseArea -and Signals. Although independent of the animation elements, animation -delivers some of the best examples that illustrate these new elements. - - - -\section2 Animation Summary - -\table - \header - \o Name - \o Description - \row - \o PropertyAnimation - \o a property value on a target object is varied to a specified value over a given time. - - \row - \o NumberAnimation - \o animate a numeric property from one value to another over a given time. - - \row - \o PauseAnimation - \o results in the task waiting for the specified duration, in milliseconds. - - \row - \o SequentialAnimation - \o allows us to list in order the animation events we want to occur, first A then B then C and so on. - - \row - \o ParallelAnimation - \o enables us to run different animations at the same time instead of sequentially. - -\endtable - - -\section1 Using States - -A state is a defined set of values in the configuration of an object and -often depends on the previous state. For example, a glass could be in a -state we call 'HalfFull' if it is being filled with a liquid and has -reached half of its total capacity. We could also have a state called -HalfEmpty which is the state that occurs when the amount of liquid drops to -half of the glass's capacity. Both states represent the same amount of -liquid, but we consider them different. Likewise, states in a program -represent not just values but may include how the current values were -reached. - -When a state changes a \e transition occurs. This is an opportunity to make -changes or take actions that depend on the movement to the new state. For -example, if we had a scene in the country where the state variable has two -states "daylight" and "night". Then when the state changes to "night" at -this transition the sky would be made dark, stars would be shown, the -countryside would be darkened. And when the state changes to "daylight" the -opposite changes would be made: the sky is now blue, the scenery is green, -there is a sun in the sky. - -Here is a simple QML program that shows the change of state in the above -example. We have two rectangles, the top one is the 'sky' and the bottom -one is the 'ground'. We will animate the change from daylight to night. -There will be two states, but we only need to define one since 'daylight' -will be the default state. We will just go to 'night' by clicking and -holding the left mouse button down, releasing the mouse button will reverse -the process - -\snippet doc/src/snippets/declarative/qml-intro/states1.qml document - -Several new things appear in this sample. Firstly, we use a \l MouseArea -element to detect mouse clicks in the \e mainRectangle. Secondly, we use -the list notation [ thing1 , thing2, ... ] to build a list of states and a -list of transitions. - -\l MouseArea defines a region that will respond to mouse clicks. In this case -we are only concerned with when the mouse is pressed or not pressed, not -the particular button or other details. The area of the MouseArea is the -entire main window, mainRectangle, so that clicking anywhere in this region -will start the animation. Since we are using the 'pressed' mouse state, -then the animation will move from 'daylight' to 'night' only while the mouse -button remains pressed. - -When the button is released the 'daylight' state is entered and the -transition from 'night' to 'daylight' is triggered causing the animation to -run. The transition specifies the duration in milliseconds of the -ColorAnimation, while the state specifies the color of the new state. - -The PropertyChanges command is the way that we nominate which properties -will change in a change of state, and what new value the property will -take. Since, for example, we want the 'sky' region to turn to dark blue and -the 'ground' region to turn to black for the 'night' state, then the -rectangles for those regions are the 'target' and the property in the target -is 'color'. - - -\section1 Signals - -Signals are simply events that can be hooked up to actions we want performed. -In QML they are usually preceded by the word 'on', for example in the animation -using a MouseArea the signal was \l {MouseArea::onPressed}{onPressed}. If -you look at the C++ documentation you will see a lot of talk about -\l {Signals & Slots}{Signals and Slots}. Signals are connected to Slots. The -signal represents an event and the Slot is the function that does something -based on that event. You can also have Signals connected to other Signals, so -that one Signal (event) triggers another Signal (event), and so forth. It is -nice to know this is what happens beneath the QML layer but not essential for -using QML. - -Most elements do not have Signals associated with them. However, a few like -the \l Audio element have many signals. Some of the \l Audio signals are -used to represent events such as when the audio is stopped, play is pressed, -paused, and reaching the end of the media. They allow the developer to connect, - for example, the press of a user interface button (perhaps a MouseArea) to - some QML that will handle this event. - - -\section1 Analyzing An Example: Dial Control - -In the Qt \e {examples/declarative/ui-components} folder you will find a folder -\e {dialcontrol} which contains the \e dialcontrol example. - -\image qml-dial.png "QML Dial example with Slider" - -In essence this small application has a sliding bar that you can slide using -a mouse, and a graphical dial that responds to the position of the slider. - -The code for the example is in two parts: Dial.qml and dialcontrol.qml. - -\e {Dial.qml} can be found in the \e content sub-directory. It defines a \c Dial -component similar to an odometer. Eventually, the example will hook up a slider -component so that moving the slider will change the position of a needle on the -dial. - -The code for the \c Dial, identified by the name of the file, contains four images -in overlapping order: the background (numbers and divisions), the shadow of the -needle, the needle itself, and finally the 'glass' overlay (containing -transparent layers). - -The \c needle_shadow.png image has a \l Rotation assigned to the \e transform -attribute of the \l Image. The rotation is set to match the angle of the needle -image angle value \e {needleRotation.angle}. Both the needle and the -needle_shadow have the same default \e x and \e y values but the rotation origin -for the needle is slightly different so that a shadow will be evident as the -needle moves. - -\snippet examples/declarative/ui-components/dialcontrol/content/Dial.qml needle_shadow - -And the needle - -\snippet examples/declarative/ui-components/dialcontrol/content/Dial.qml needle - -The final image is the overlay which simply has a position defined. - -\snippet examples/declarative/ui-components/dialcontrol/content/Dial.qml overlay - -\e {dialcontrol.qml} in the \e {examples/declarative/ui-components/dialcontrol} directory is the -main file of the example. It defines the visual environment that the Dial -will fit into. Because the \e Dial component and the images live in the \e -content sub-directory we will have to import this into \e dialcontrol.qml. So the -start of the file looks like - -\snippet examples/declarative/ui-components/dialcontrol/dialcontrol.qml imports - -The visual space is bound by a 300 by 300 pixel \l Rectangle which is given -a gray color. Inside this rectangle is our component \e Dial and a \l Rectangle. -Inside the rectangle called 'container' is another rectangle with the -interesting name 'slider'. - -\snippet examples/declarative/ui-components/dialcontrol/dialcontrol.qml 0 - -The Dial component, named 'dial, is \e anchored to the center of the main -rectangle. The \c value attribute of 'dial' is set to a value based on the -'slider' horizontal position and the 'container' width. So changes to the -'slider' position will change the Dial \c value which is used in Dial to compute -the rotation of the needle image. Notice this piece of code in Dial where -the change in \c value modifies the position of the needle. - -\snippet examples/declarative/ui-components/dialcontrol/content/Dial.qml needle angle - -This is part of the \c needleRotation that rotates the needle and causes the -rotation of its shadow. \l SpringAnimation is an element that modifies the value -of that rotation \e angle and mimics the oscillatory behavior of a spring, -with the appropriate \e spring constant to control the acceleration and the \e -damping to control how quickly the effect dies away. - -The 'container' is light gray with a color gradient defined using -\l GradientStop. The gradient is applied vertically. If you need a horizontal -gradient then you could apply the vertical gradient and then rotate the item -by 90 degrees. - -The 'slider' is dark gray and also has a vertical color gradient. The most -important thing about the 'slider' is that it has a MouseArea defined, which -specifies a \c {drag.target} on itself along the X-axis. With minimum -and maximum values on the X-axis defined. So we can click on the 'slider' and -drag it left and right within the confines of the 'container'. The motion of -the 'slider' will then change the \c value attribute in \e Dial as discussed -already. - -Also notice the use of a \c radius value for a rectangle. This produces rounded -corners. That is how the 'container' and 'slider' are displayed with a -pleasant rounded look. - - - -*/ - - - diff --git a/doc/src/declarative/qmlevents.qdoc b/doc/src/declarative/qmlevents.qdoc new file mode 100644 index 0000000..566f71c --- /dev/null +++ b/doc/src/declarative/qmlevents.qdoc @@ -0,0 +1,127 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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:FDL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Free Documentation License +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of this +** file. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! +\page qmlevents.html +\ingroup qml-features +\contentspage QML Features +\previouspage {Keyboard Focus in QML}{Keyboard Focus} +\nextpage Importing Reusable Components + +\title QML Signal and Handler Event System + +QML utilizes Qt's \l{The Meta-Object System}{meta-object} and +\l{Signals & Slots}{signals} systems. Signals and slots created using Qt in C++ +are inheritely valid in QML. + +\keyword qml-signals-and-handlers +\section1 Signals and Handlers + +Signals provide a way to notify other objects when an event has occurred. For +example, the MouseArea \c clicked signal notifies other objects that the mouse +has been clicked within the area. + +The syntax for defining a new signal is: + +\tt{signal <name>[([<type> <parameter name>[, ...]])]} + +Attempting to declare two signals or methods with the same name in the same type +block generates an error. However, a new signal may reuse the name of an existing signal on the type. (This should be done with caution, as the existing signal may be hidden and become inaccessible.) + +Here are various examples of signal declarations: +\snippet doc/src/snippets/declarative/events.qml parent begin +\snippet doc/src/snippets/declarative/events.qml signal declaration +\snippet doc/src/snippets/declarative/events.qml parent end + +If the signal has no parameters, the "\c{()}" brackets are optional. If +parameters are used, the parameter types must be declared, as for the \c string +and \c variant arguments of the \c perform signal. + +Adding a signal to an item automatically adds a \e{signal handler} as well. The +signal hander is named \c on<SignalName>, with the first letter of the signal in +uppercase. The previous signals have the following signal handlers: +\snippet doc/src/snippets/declarative/events.qml signal handler declaration + +Further, each QML properties have a \c{<property_name>Changed} signal and its +corresponding \c{on<property_name>Changed} signal handler. As a result, property +changes may notify other components for any changes. +\snippet doc/src/snippets/declarative/events.qml automatic signals + +To emit a signal, invoke it as a method. The signal handler binding is similar +to a property binding and it is invoked when the signal is emitted. Use the +defined argument names to access the respective arguments. +\snippet doc/src/snippets/declarative/events.qml signal emit +Note that the \c Component.onCompleted is an +\l{attached-signalhandlers}{attached signal handler}; it is invoked when the +\l Component initialization is complete. + +\keyword qml-connect-signals-to-method +\section2 Connecting Signals to Methods and Signals + +Signal objects have a \c connect() method to a connect a signal either to a +method or another signal. When a signal is connected to a method, the method is +automatically invoked whenever the signal is emitted. (In Qt terminology, the +method is a \e slot that is connected to the \e signal; all methods defined in +QML are created as \l{Signals & Slots}{Qt slots}.) This enables a signal +to be received by a method instead of a \l {Signal Handlers}{signal handler}. + +\snippet doc/src/snippets/declarative/events.qml connect method +The \c {connect()} method is appropriate when connecting a JavaScript method to +a signal. + +There is a corresponding \c disconnect() method for removing connected +signals. + +\section3 Signal to Signal Connect + +By connecting signals to other signals, the \c connect() method can form different +signal chains. +\snippet doc/src/snippets/declarative/events.qml forward signal + + +Whenever the \l MouseArea \c clicked signal is emitted, the \c send +signal will automatically be emitted as well. + +\code +output: + MouseArea clicked + Send clicked +\endcode + +\section1 C++ Additions + +Because QML uses Qt, a signal defined in C++ also works as a QML signal. The +signal may be emitted in QML code or called as a method. In addition, the QML +runtime automatically creates signal handlers for the C++ signals. For more +signal control, the \c connect() method and the \l Connections element may connect +a C++ signal to another signal or method. + +For complete information on how to call C++ functions in QML, read the +\l{Extending QML - Signal Support Example}. + + +*/ diff --git a/doc/src/declarative/qmlreusablecomponents.qdoc b/doc/src/declarative/qmlreusablecomponents.qdoc new file mode 100644 index 0000000..ee360eb --- /dev/null +++ b/doc/src/declarative/qmlreusablecomponents.qdoc @@ -0,0 +1,143 @@ +/**************************************************************************** +** +** 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:FDL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Free Documentation License +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of this +** file. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! +\page qmlreusablecomponents.html +\ingroup qml-features +\previouspage {QML Signal and Handler Event System}{Signal and Handler Event System} +\nextpage {QML States}{States} +\contentspage QML Features + +\title Importing Reusable Components + +A \e component is an instantiable QML definition, typically contained in a +\c .qml file. For instance, a Button \e component may be defined in +\c Button.qml. The QML runtime may instantiate this Button component to create +Button \e objects. Alternatively, a component may be defined inside a +\l Component element. + +Moreover, the Button definition may also contain other components. A Button +component could use a Text element for its label and other components to +implement its functions. Compounding components to form new components +(and effectively new interfaces) is the emphasis in QML. + +\keyword qml-define-components +\section1 Defining New Components + +Any snippet of QML code may become a component, by placing the code in a QML +file (extension is \c .qml). A complete Button component that responds to user +input may be in a Button.qml file. +\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml document + +Alternatively, a \l Component element may encapsulate a QML object to form a +component. +\snippet doc/src/snippets/declarative/reusablecomponents/component.qml parent begin +\snippet doc/src/snippets/declarative/reusablecomponents/component.qml define inline component +\snippet doc/src/snippets/declarative/reusablecomponents/component.qml parent end + +\keyword qml-loading-components +\section1 Loading a Component + +The initialization of inline components is different from loading a component +from a \c .qml file. + +\section2 Importing a Component + +A component defined in a \c .qml file is directly usable by declaring the name +of the component. For example, a button defined in \c Button.qml is created by +declaring a \c Button. The button is defined in the +\l {qml-define-components}{Defining New Components} section. +\snippet doc/src/snippets/declarative/reusablecomponents/application.qml document + +Note that the component name, \c Button, matches the QML filename, \c Button.qml. +Also, the first character is in upper case. Matching the names allow +components in the same directory to be in the direct import path of the +application. + +For flexibility, a \c qmldir file is for dictating which additional components, +plugins, or directories should be imported. By using a \c qmldir file, +component names do not need to match the filenames. The \c qmldir file should, +however, be in an imported path. +\snippet doc/src/snippets/declarative/reusablecomponents/qmldir document + +\section2 Loading an Inline Component + +A consequence of inline components is that initialization may be deferred or +delayed. A component may be created during a MouseArea event or by using a +\l Loader element. The component can create an object, which is addressable in a +similar way as an \l {qml-id-property}{id property}. Thus, the created object may +have its bindings set and read like a normal QML object. +\snippet doc/src/snippets/declarative/reusablecomponents/component.qml define inline component +\snippet doc/src/snippets/declarative/reusablecomponents/component.qml create inline component + +\keyword qml-component-properties +\section1 Component Properties + +Initializing a component, either from a .qml file or initializing an inline +component, have several properties to facilitate component execution. +Specifically, there are \l{attached-properties}{attached properties} and +\l{attached-signalhandlers}{attached signal handlers} for setting properties +during the lifetime of a component. + +The \c{Component.onCompleted} attached signal handler is called when the +component completes initialization. It is useful for executing any commands +after component initialization. Similarly, the \c{Component.onDestruction} +signal handler executes when the component finishes destruction. + +\keyword qml-top-level +\section1 Top-Level Component + +Choosing the \e{top-level} or the \e{root} object of components is an important +design aspect because the top-level object dictates which properties are +accessible outside the component. Some elements are not visual elements and +will not have visual properties exposed outside the component. Likewise, some +elements add functionality that are not available to visual elements. + +Consider the Button component from the +\l{qml-define-components}{Defining New Components} section; it's top-level +object is a \l Rectangle. When imported, the Button component will possess the +Rectangle's properties, methods, signals, and any custom properties. + +\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml parent begin +\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml ellipses +\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml properties +\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml ellipses +\snippet doc/src/snippets/declarative/reusablecomponents/Button.qml parent end + +The Button's \c text alias is accessible from outside the component as well as +the Rectangle's visual properties and signals such as \c x, \c y, \c anchors, +and \c states. + +Alternatively, we may choose a \l {Keyboard Focus in QML}{FocusScope} as our +top-level object. The \l FocusScope element manage keyboard focus for its +children which is beneficial for certain types of interfaces. However, since +\c FocusScopes are not visual elements, the visual properties of its child need +to be exposed. + +\snippet doc/src/snippets/declarative/reusablecomponents/focusbutton.qml document +*/ + diff --git a/doc/src/declarative/qmlruntime.qdoc b/doc/src/declarative/qmlruntime.qdoc index f6604fb..a1f3f96 100644 --- a/doc/src/declarative/qmlruntime.qdoc +++ b/doc/src/declarative/qmlruntime.qdoc @@ -29,13 +29,13 @@ \page qmlruntime.html \title Qt Declarative UI Runtime -QML documents are loaded and executed by the QML runtime. This includes the +QML documents are loaded and executed by the QML runtime. This includes the Declarative UI engine along with the built-in QML elements and plugin modules, and it also provides access to third-party QML elements and modules. -Applications that use QML need to invoke the QML runtime in order to -execute QML documents. This can be done by creating a QDeclarativeView -or a QDeclarativeEngine, as described below. In addition, the Declarative UI +Applications that use QML need to invoke the QML runtime in order to +execute QML documents. This can be done by creating a QDeclarativeView +or a QDeclarativeEngine, as described below. In addition, the Declarative UI package includes the \QQV tool, which loads \c .qml files. This tool is useful for developing and testing QML code without the need to write a C++ application to load the QML runtime. @@ -44,7 +44,7 @@ a C++ application to load the QML runtime. \section1 Deploying QML-based applications -To deploy an application that uses QML, the QML runtime must be invoked by +To deploy an application that uses QML, the QML runtime must be invoked by the application. This is done by writing a Qt C++ application that loads the QDeclarativeEngine by either: @@ -61,12 +61,12 @@ For example, if there is a QML file, \c application.qml, like this: \qml import QtQuick 1.0 - + Rectangle { width: 100; height: 100; color: "red" } \endqml It can be loaded in a Qt application's \c main.cpp file like this: - + \code #include <QApplication> #include <QDeclarativeView> @@ -82,10 +82,10 @@ It can be loaded in a Qt application's \c main.cpp file like this: return app.exec(); } \endcode - -This creates a QWidget-based view that displays the contents of + +This creates a QWidget-based view that displays the contents of \c application.qml. - + The application's \c .pro \l{qmake Project Files}{project file} must specify the \c declarative module for the \c QT variable. For example: @@ -97,36 +97,36 @@ the \c declarative module for the \c QT variable. For example: \section2 Creating a QDeclarativeEngine directly - -If \c application.qml does not have any graphical components, or if it is + +If \c application.qml does not have any graphical components, or if it is preferred to avoid QDeclarativeView for other reasons, the QDeclarativeEngine can be constructed directly instead. In this case, \c application.qml is loaded as a QDeclarativeComponent instance rather than placed into a view: \code #include <QApplication> - #include <QDeclarativeEngine> + #include <QDeclarativeEngine> #include <QDeclarativeContext> #include <QDeclarativeComponent> int main(int argc, char *argv[]) { QApplication app(argc, argv); - + QDeclarativeEngine engine; QDeclarativeContext *objectContext = new QDeclarativeContext(engine.rootContext()); - + QDeclarativeComponent component(&engine, "application.qml"); QObject *object = component.create(objectContext); - + // ... delete object and objectContext when necessary - + return app.exec(); } \endcode -See \l {Using QML in C++ Applications} for more information about using -QDeclarativeEngine, QDeclarativeContext and QDeclarativeComponent, as well +See \l {Using QML Bindings in C++ Applications} for more information about using +QDeclarativeEngine, QDeclarativeContext and QDeclarativeComponent, as well as details on including QML files through \l{The Qt Resource System}{Qt's Resource system}. @@ -135,8 +135,8 @@ as details on including QML files through \l{The Qt Resource System}{Qt's Resour The Declarative UI package includes a QML runtime tool, the \QQV, which loads and displays QML documents. This is useful during the application development -phase for prototyping QML-based applications without writing your own C++ -applications to invoke the QML runtime. +phase for prototyping QML-based applications without writing your own C++ +applications to invoke the QML runtime. See the \l{QML Viewer} documentation for more details. diff --git a/doc/src/declarative/qmlsyntax.qdoc b/doc/src/declarative/qmlsyntax.qdoc new file mode 100644 index 0000000..fc25bce --- /dev/null +++ b/doc/src/declarative/qmlsyntax.qdoc @@ -0,0 +1,155 @@ +/**************************************************************************** +** +** 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:FDL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Free Documentation License +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of this +** file. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! +\page qmlsyntax.html +\title QML Syntax +\ingroup QML Reference +\contentspage QML Reference + +\tableofcontents + +QML is a declarative language designed to describe the user interface of a +program: both what it looks like, and how it behaves. In QML, a user +interface is specified as a tree of objects with properties. + +JavaScript is used as a scripting language in QML, so you may want +to learn a bit more about it (\l{Javascript Guide}) before diving +deeper into QML. + +\section1 Basic QML Syntax + +QML looks like this: + +\code +import QtQuick 1.0 + +Rectangle { + width: 200 + height: 200 + color: "blue" + + Image { + source: "pics/logo.png" + anchors.centerIn: parent + } +} +\endcode + +Objects are specified by their type, followed by a pair of braces. Object +types always begin with a capital letter. In the above example, there are +two objects, a \l Rectangle, and an \l Image. Between the braces, we can specify +information about the object, such as its properties. + +Properties are specified as \c {propertyname: value}. In the above example, we +can see the Image has a property named \c source, which has been assigned the +value \c "pics/logo.png". The property and its value are separated by a colon. + +Properties can be specified one-per-line: + +\code +Rectangle { + width: 100 + height: 100 +} +\endcode + +or you can put multiple properties on a single line: + +\code +Rectangle { width: 100; height: 100 } +\endcode + +When multiple property/value pairs are specified on a single line, they +must be separated by a semicolon. + +The \c import statement imports the \c Qt \l{QML Modules}{module}, which contains all of the +standard \l {QML Elements}. Without this import statement, the \l Rectangle +and \l Image elements would not be available. + +\section1 Expressions + +In addition to assigning values to properties, you can also assign +expressions written in JavaScript. + +\code +Rotation { + angle: 360 * 3 +} +\endcode + +These expressions can include references to other objects and properties, in which case +a \e binding is established: when the value of the expression changes, the property the +expression has been assigned to is automatically updated to that value. + +\code +Item { + Text { + id: text1 + text: "Hello World" + } + Text { + id: text2 + text: text1.text + } +} +\endcode + +In the example above, the \c text2 object will display the same text as \c text1. If \c text1 is changed, +\c text2 is automatically changed to the same value. + +Note that to refer to other objects, we use their \e id values. (See below for more +information on the \e id property.) + +\section1 QML Comments + +Commenting in QML is similar to JavaScript. +\list +\o Single line comments start with // and finish at the end of the line. +\o Multiline comments start with /* and finish with *\/ +\endlist + +\snippet doc/src/snippets/declarative/comments.qml 0 + +Comments are ignored by the engine. They are useful for explaining what you +are doing; for referring back to at a later date, or for others reading +your QML files. + +Comments can also be used to prevent the execution of code, which is +sometimes useful for tracking down problems. + +\code +Text { + text: "Hello world!" + //opacity: 0.5 +} +\endcode + +In the above example, the Text object will have normal opacity, since the +line opacity: 0.5 has been turned into a comment. + +*/ diff --git a/doc/src/declarative/qmltexthandling.qdoc b/doc/src/declarative/qmltexthandling.qdoc new file mode 100644 index 0000000..7906193 --- /dev/null +++ b/doc/src/declarative/qmltexthandling.qdoc @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** 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:FDL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Free Documentation License +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of this +** file. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! +\page texthandling.html +\title QML Text Handling and Validators +\ingroup QML Features +\previouspage {QML Mouse Events}{Mouse Events} +\nextpage {Keyboard Focus in QML}{Keyboard Focus} +\contentspage QML Features + +\tableofcontents + +\section1 Text Elements + +\list +\o \l{Text} +\o \l{TextInput} +\o \l{TextEdit} +\endlist + +\section1 Validators +\list +\o \l{IntValidator} +\o \l{DoubleValidator} +\o \l{RegExpValidator} +\endlist + +\section1 Displaying Text in QML +QML provides several elements to display text onto the screen. The \l Text +element will display formatted text onto the screen, the \l TextEdit element +will place a multiline line edit onto the screen, and the \l TextInput will +place a single editable line field onto the screen. + +To learn more about their specific features and properties, visit their +respective element documentation. + +\section1 Validating Input Text +The \l {Validators}{validator} elements enforce the type and format of +\l TextInput objects. + +\snippet doc/src/snippets/declarative/texthandling.qml int validator +The validator elements bind to \c {TextInput}'s \c validator property. + +\snippet doc/src/snippets/declarative/texthandling.qml regexp validator +The regular expression in the snippet will only allow the inputted text to be +\c {fruit basket}. + +Note that QML parses JavaScript regular expressions, while Qt's +\l {QRegExp} class' regular expressions are based on Perl regular expressions. + +*/ diff --git a/doc/src/declarative/qmlviewer.qdoc b/doc/src/declarative/qmlviewer.qdoc index 585b402..2e3cdc7 100644 --- a/doc/src/declarative/qmlviewer.qdoc +++ b/doc/src/declarative/qmlviewer.qdoc @@ -31,34 +31,34 @@ \title QML Viewer \ingroup qttools -The Declarative UI package includes \QQV, a tool for loading QML documents that -makes it easy to quickly develop and debug QML applications. It invokes the QML -runtime to load QML documents and also includes additional features useful for +The Declarative UI package includes \QQV, a tool for loading QML documents that +makes it easy to quickly develop and debug QML applications. It invokes the QML +runtime to load QML documents and also includes additional features useful for the development of QML-based applications. -The QML Viewer is a tool for testing and developing QML applications. It is -\e not intended for use in a production environment and should not be used for the +The QML Viewer is a tool for testing and developing QML applications. It is +\e not intended for use in a production environment and should not be used for the deployment of QML applications. In those cases, the QML runtime should be invoked from a Qt application instead; see \l {Qt Declarative UI Runtime} for more information. The viewer is located at \c QTDIR/bin/qmlviewer. To load a \c .qml file -with the viewer, run the viewer and select the file to be opened, or provide the +with the viewer, run the viewer and select the file to be opened, or provide the file path on the command line: \code qmlviewer myqmlfile.qml \endcode - + On Mac OS X, the QML Viewer application is named "QMLViewer" instead. You -can launch the viewer by opening the QMLViewer application from the Finder, or +can launch the viewer by opening the QMLViewer application from the Finder, or from the command line: \code QMLViewer.app/Contents/MacOS/QMLViewer myqmlfile.qml \endcode -The QML Viewer has a number of configuration options involving features such as +The QML Viewer has a number of configuration options involving features such as fullscreen display, module import path configurations, video recording of QML animations, and OpenGL support. @@ -68,7 +68,7 @@ To see the configuration options, run \c qmlviewer with the \c -help argument. \section1 Adding module import paths Additional module import paths can be provided using the \c -I flag. -For example, the \l{declarative/cppextensions/plugins}{QML plugins example} creates +For example, the \l{declarative/cppextensions/plugins}{QML plugins example} creates a C++ plugin identified as \c com.nokia.TimeExample. Since this has a namespaced identifier, the viewer has to be run with the \c -I flag from the example's base directory: @@ -87,16 +87,16 @@ the path is explicitly added. \section1 Loading translation files -When the QML Viewer loads a QML file, it installs a translation file from a -"i18n" subdirectory relative to that initial file. This directory should contain +When the QML Viewer loads a QML file, it installs a translation file from a +"i18n" subdirectory relative to that initial file. This directory should contain translation files named "qml_<language>.qm", where <language> is a two-letter ISO 639 language, such as "qml_fr.qm", optionally followed by an underscore and an uppercase two-letter ISO 3166 country code, such as "qml_fr_FR.qm" or -"qml_fr_CA.qm". +"qml_fr_CA.qm". Such files can be created using \l {Qt Linguist}. -The actual translation file that is loaded depends on the system locale. +The actual translation file that is loaded depends on the system locale. Additionally, the viewer will load any translation files specified on the command line via the \c -translation option. @@ -110,7 +110,7 @@ shows how JavaScript code in QML files can be made to use translatable strings. Often, QML applications are prototyped with fake data that is later replaced by real data sources from C++ plugins. QML Viewer assists in this aspect by loading fake data into the application context: it looks for a directory named -"dummydata" in the same directory as the target QML file, and any \c .qml +"dummydata" in the same directory as the target QML file, and any \c .qml files in that directory are loaded as QML objects and bound to the root context as properties named after the files. @@ -124,7 +124,7 @@ ListView { width: 200; height: 300 model: lottoNumbers delegate: Text { text: number } -} +} \endqml If within the document's directory, there is a "dummydata" directory which @@ -146,30 +146,30 @@ Child properties are included when loaded from dummy data. The following documen refers to a \c clock.time property: \qml -import QtQuick 1.0 +import QtQuick 1.0 Text { text: clock.time } \endqml - + The text value could be filled by a \c dummydata/clock.qml file with a \c time property in the root context: \qml -import QtQuick 1.0 +import QtQuick 1.0 QtObject { property int time: 54321 } \endqml To replace this with real data, you can simply bind the real data object to the root context in C++ using QDeclarativeContext::setContextProperty(). This -is detailed in \l {Using QML in C++ Applications}. +is detailed in \l {Using QML Bindings in C++ Applications}. \section1 Using the \c runtime object QML applications that are loaded with the QML Viewer have access to a special -\c runtime property on the root context. This property provides additional +\c runtime property on the root context. This property provides additional information about the application's runtime environment through the following properties: \table -\row +\row \o \c runtime.isActiveWindow @@ -177,9 +177,9 @@ information about the application's runtime environment through the following pr window on the system. It is useful for "pausing" an application, particularly animations, when the QML Viewer loses focus or moves to the background. -For example, the following animation is only played when the QML Viewer is +For example, the following animation is only played when the QML Viewer is the active window: - + \qml Rectangle { width: 200; height: 200 @@ -200,9 +200,9 @@ through the \c active property of the \l {QML:Qt::application}{Qt.application} o \o \c runtime.orientation \o This property indicates the current orientation of the QML Viewer. On the -N900 platform and most S60 5.0-based or newer Symbian devices, this property -automatically updates to reflect the device's actual orientation; on other platforms, -this indicates the orientation currently selected in the QML Viewer's +N900 platform and most S60 5.0-based or newer Symbian devices, this property +automatically updates to reflect the device's actual orientation; on other platforms, +this indicates the orientation currently selected in the QML Viewer's \e {Settings -> Properties} menu. The \c orientation value can be one of the following: \list @@ -213,7 +213,7 @@ this indicates the orientation currently selected in the QML Viewer's \endlist When the viewer's orientation changes, the appearance of the loaded QML document -does not change unless it has been set to respond to changes in +does not change unless it has been set to respond to changes in \c runtime.orientation. For example, the following Rectangle changes its aspect ratio depending on the orientation of the QML Viewer: @@ -221,12 +221,12 @@ aspect ratio depending on the orientation of the QML Viewer: Rectangle { id: window width: 640; height: 480 - + states: State { name: "landscape" PropertyChanges { target: window; width: 480; height: 640 } } - state: (runtime.orientation == Orientation.Landscape + state: (runtime.orientation == Orientation.Landscape || runtime.orientation == Orientation.LandscapeInverted) ? 'landscape' : '' } \endqml diff --git a/doc/src/declarative/qmlviews.qdoc b/doc/src/declarative/qmlviews.qdoc new file mode 100644 index 0000000..53ce4b9 --- /dev/null +++ b/doc/src/declarative/qmlviews.qdoc @@ -0,0 +1,114 @@ +/**************************************************************************** +** +** 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:FDL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Free Documentation License +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of this +** file. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! +\page qml-views.html +\ingroup qml-features +\contentspage QML Features +\previouspage {QML Data Models}{Structuring Data with Models} +\nextpage {Extending QML Functionalities using C++} +\title Presenting Data with Views + +Views are containers for collections of items. They are feature-rich and can be +customizable to meet style or behavior requirements. + +\keyword qml-view-elements +A set of standard views are provided in the basic set of Qt Quick +graphical elements: + +\list +\o \l{ListView} arranges items in a horizontal or vertical list +\o \l{GridView} arranges items in a grid within the available space +\o \l{PathView} arranges items on a path +\o \l{WebView}{WebView} - available from the \l {QtWebKit QML Module}. +\endlist +Unlike other views, \l WebView is not a fully-featured view item, and needs +to be combined with a \l Flickable item to create a view that performs like +a Web browser. + +These elements have properties and behaviors exclusive to each element. Visit +their respective documentation for more information. + +\section1 Models + +Views display \l{qml-data-models}{models} onto the screen. A model could be a simple list of \l{QML Data Models#An Integer}{integer} or a \l{qml-c++-models}{C++ model}. + +To assign a model to a view, bind the view's \c model property to a model. +\snippet doc/src/snippets/declarative/listview.qml model +\snippet doc/src/snippets/declarative/listview.qml model + +For more information, consult the \l {QML Data Models} article. + +\keyword qml-view-delegate +\section1 View Delegates + +Views need a \e delegate to visually represent an item in a list. A view will +visualize each item list according to the template defined by the delegate. +Items in a model are accessible through the \c index property as well as the +item's properties. +\snippet doc/src/snippets/declarative/listview.qml delegate +\image listview-setup.png + +\section1 Decorating Views + +Views allow visual customization through \e decoration properties such as the \c header, \c footer, and \c section properties. By binding an object, usually +another visual object, to these properties, the views are decoratable. A footer +may include a \l Rectangle element showcasing borders or a header that displays +a logo on top of the list. + +Suppose that a specific club wants to decorate its members list with its brand +colors. A member list is in a \c model and the \c delegate will display the +model's content. +\snippet doc/src/snippets/declarative/listview-decorations.qml model +\snippet doc/src/snippets/declarative/listview-decorations.qml delegate + +The club may decorate the members list by binding visual objects to the +\c header and \c footer properties. The visual object may be defined inline, in another file, or in a +\l {Component} element. +\snippet doc/src/snippets/declarative/listview-decorations.qml decorations +\image listview-decorations.png + +\section1 ListView Sections + +\l {ListView} contents may be grouped into \e sections, where related list items +are labeled according to their sections. Further, the sections may be decorated +with \l{qml-view-delegate}{delegates}. + +A list may contain a list indicating people's names and the team on which team +the person belongs. +\snippet doc/src/snippets/declarative/listview-sections.qml model +\snippet doc/src/snippets/declarative/listview-sections.qml delegate + +The ListView element has the \c section +\l{Property Binding#Attached Properties}{attached property} that can combine +adjacent and related elements into a section. The section's \c property +property is for selecting which list element property to use as sections. +The \c criteria can dictate how the section names are displayed and the +\c delegate is similar to the views' \l {qml-view-delegate}{delegate} property. +\snippet doc/src/snippets/declarative/listview-sections.qml section +\image listview-section.png +*/ diff --git a/doc/src/declarative/qmlwebkit.qdoc b/doc/src/declarative/qmlwebkit.qdoc new file mode 100644 index 0000000..840f24d --- /dev/null +++ b/doc/src/declarative/qmlwebkit.qdoc @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** 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:FDL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Free Documentation License +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of this +** file. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! +\page qmlwebkit.html + +\title QtWebKit QML Module + +Qt WebKit QML + +\section1 WebKit QML Elements +\list +\o \l WebView +\endlist + +\section1 QtWebKit Module +The QtWebKit Module has a QML element, \l{WebView} for displaying web content +from a \c URL. + +Import the QtWebKit module before declaring a \c WebView element: +\snippet doc/src/snippets/declarative/webview/webview.qml import + +\section1 Simple Usage +\snippet doc/src/snippets/declarative/webview/webview.qml document +\image webview.png + +\sa {Models and Views: WebView Example}{WebView Example}, {QML Web Browser} +*/ diff --git a/doc/src/declarative/qtbinding.qdoc b/doc/src/declarative/qtbinding.qdoc index 03290aa..d11825e 100644 --- a/doc/src/declarative/qtbinding.qdoc +++ b/doc/src/declarative/qtbinding.qdoc @@ -27,10 +27,13 @@ /*! \page qtbinding.html -\target qtbinding -\title Using QML in C++ Applications +\ingroup qml-features +\previouspage {Extending QML Functionalities using C++} +\nextpage {Integrating QML Code with Existing Qt UI Code} +\contentspage QML Features +\title Using QML Bindings in C++ Applications -QML is designed to be easily extensible from C++. The classes in the +QML is designed to be easily extensible to and from C++. The classes in the Qt Declarative module allow QML components to be loaded and manipulated from C++, and through Qt's \l{The Meta-Object System}{meta-object system}, QML and C++ objects can easily communicate through Qt signals and slots. In addition, QML plugins can be written to create @@ -85,7 +88,7 @@ delete rectangleInstance; QML documents can also be loaded using QDeclarativeView. This class provides a convenient QWidget-based view for embedding QML components into QGraphicsView-based applications. (For other -methods of integrating QML into QWidget-based applications, see \l {Integrating QML with existing Qt +methods of integrating QML into QWidget-based applications, see \l {Integrating QML Code with existing Qt UI code}.) @@ -262,8 +265,8 @@ Note that custom C++ types do not have to inherit from QDeclarativeItem; this is a displayable item. If the item is not displayable, it can simply inherit from QObject. For more information on defining new QML elements, see the \l {Tutorial: Writing QML extensions with C++} -{Writing QML extensions with C++} tutorial and the \l {Extending QML in C++} reference -documentation. +{Writing QML extensions with C++} tutorial and the +\l {Extending QML Functionalities using C++} reference documentation. @@ -496,7 +499,8 @@ can be registered using qmlRegisterUncreatableType(). To be accessible from QML must begin with a capital letter. See the \l {Tutorial: Writing QML extensions with C++}{Writing QML extensions with C++} tutorial and -the \l {Extending QML in C++} reference documentation for more information. +the \l {Extending QML Functionalities using C++} reference documentation for +more information. \section2 Automatic type conversion from strings diff --git a/doc/src/declarative/qtprogrammers.qdoc b/doc/src/declarative/qtprogrammers.qdoc index b7d09a1..e48dc9a 100644 --- a/doc/src/declarative/qtprogrammers.qdoc +++ b/doc/src/declarative/qtprogrammers.qdoc @@ -30,8 +30,6 @@ \target qtprogrammers \title QML for Qt Programmers -\section1 Overview - While QML does not require Qt knowledge to use, if you \e are already familiar with Qt, much of your knowledge is directly relevant to learning and using QML. Of course, an application with a UI defined in QML also uses Qt for all the non-UI logic. @@ -48,7 +46,8 @@ QML provides direct access to the following concepts from Qt: \o Qt models - used directly in data binding (QAbstractItemModel) \endlist -Qt knowledge is \e required for \l {Extending QML in C++}, and also for \l{Integrating QML with existing Qt UI code}. +Qt knowledge is \e required for \l {Extending QML Functionalities using C++}, +and also for \l{Integrating QML Code with existing Qt UI code}. \section1 QML Items compared with QWidgets diff --git a/doc/src/declarative/qtquick-intro.qdoc b/doc/src/declarative/qtquick-intro.qdoc new file mode 100644 index 0000000..75236e6 --- /dev/null +++ b/doc/src/declarative/qtquick-intro.qdoc @@ -0,0 +1,124 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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:FDL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Free Documentation License +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of this +** file. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! +\page qml-intro.html +\title Intro to Qt Quick + +Qt Quick is a collection of technologies that are designed to help developers +create the kind of intuitive, modern, and fluid user interfaces that are +increasingly used on mobile phones, media players, set-top boxes, and other +portable devices. Qt Quick consists of a rich set of user interface +\l{QML Elements}{elements}, a \l{QML Syntax}{declarative} language for +describing user interfaces, and a language \l{QtDeclarative Module}{runtime}. A +collection of C++ APIs is used to integrate these high level features with +classic Qt applications. Version 2.1 of the Qt Creator integrated development +environment (IDE) introduces tools for developing Qt Quick applications. + +\image qml-clocks-example.png + +\section1 The QML Language + +QML is a high level, scripted language. Its commands, more correctly +\e elements, leverage the power and efficiency of the Qt libraries to make easy +to use commands that perform intuitive functions. Drawing a rectangle, +displaying an image, and application events -- all are possible with declarative +programming. + +The language also allows more flexibility of these commands by using +\l{About JavaScript}{JavaScript} to implement the high level user interface +logic. + +A QML element usually has various \e properties that help define the element. +For example, if we created an element called Circle then the radius of the +circle would be a property. Building user interfaces by importing these elements +is one of the great feature of QML and Qt Quick. +\image qml-texteditor5_newfile.png + +\section1 QtDeclarative Module + +To make Qt Quick possible, Qt introduces the \l {QtDeclarative} module. The +module creates a JavaScript runtime that QML runs under with a Qt based backend. +Because QtDeclarative and QML are built upon Qt, they inherit many of Qt's +technology, namely the \l{Signals and Slots}{signals and slots} mechanism and +the \l{The Meta-Object System}{meta-object} system. Data created using C++ are +directly accessible from QML and QML objects are also accessible from C++ code. + +In conjunction with the QML language, the QtDeclarative module separates the +interface logic in QML from the application logic in C++. + +\section1 Creator Tools + +Qt Creator is a complete integrated development environment (IDE) for creating +applications with Qt Quick and the Qt application framework. + +\image qmldesigner-visual-editor.png + +The main goal for Qt Creator is meeting the development needs of Qt Quick +developers who are looking for simplicity, usability, productivity, +extendibility and openness, while aiming to lower the barrier of entry for +newcomers to Qt Quick and Qt. The key features of Qt Creator allow UI designers +and developers to accomplish the following tasks: +\list +\o Get started with Qt Quick application development quickly and easily with +examples, tutorials, and project wizards. +\o Design application user interface with the integrated editor, Qt Quick +Designer, or use graphics software to design the user interface and use scripts +to export the design to Qt Quick Designer. +\o Develop applications with the advanced code editor that provides new powerful +features for completing code snippets, refactoring code, and viewing the element +hierarchy of QML files. +\o Build and deploy Qt Quick applications that target multiple desktop and +mobile platforms, such as Microsoft Windows, Mac OS X, Linux, Symbian, and +Maemo. +\o Debug JavaScript functions and execute JavaScript expressions in the current +context, and inspect QML at runtime to explore the object structure, debug +animations, and inspect colors. +\o Deploy applications to mobile devices and create application installation +packages for Symbian and Maemo devices that can be published in the Ovi Store +and other channels. +\o Easily access information with the integrated context-sensitive Qt Help +system. +\endlist + +\image qtcreator-target-selector.png + +\section1 Where to Go from Here + +The \l {Qt Quick} page has links to various Qt Quick topics such as QML +features, addons, and tools. + +The \l {QML Examples and Demos} page has a gallery of QML applications. + +\section1 License Information +\list +\o \l{Qt Quick Licensing Information} +\endlist +*/ + + + diff --git a/doc/src/declarative/scope.qdoc b/doc/src/declarative/scope.qdoc index 3317037..9a9934a 100644 --- a/doc/src/declarative/scope.qdoc +++ b/doc/src/declarative/scope.qdoc @@ -24,41 +24,17 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ - -/* - - - -and requires extension to -fit naturally with QML. - - -JavaScript has only b -JavaScript has a very simple built in scope is very simple - -script, and the precede d - -and \l {Integrating JavaScript}{JavaScript} are executed in a scope chain -automatically established by QML when a component instance is constructed. QML is a \e {dynamically scoped} -language. Different object instances instantiated from the same component can exist in -different scope chains. - -\image qml-scope.png - - -*/ - /*! \page qdeclarativescope.html \title QML Scope \tableofcontents -QML property bindings, inline functions and imported JavaScript files all -run in a JavaScript scope. Scope controls which variables an expression can +QML property bindings, inline functions and imported JavaScript files all +run in a JavaScript scope. Scope controls which variables an expression can access, and which variable takes precedence when two or more names conflict. -As JavaScript's built-in scope mechanism is very simple, QML enhances it to fit +As JavaScript's built-in scope mechanism is very simple, QML enhances it to fit more naturally with the QML language extensions. \section1 JavaScript Scope @@ -67,8 +43,8 @@ QML's scope extensions do not interfere with JavaScript's natural scoping. JavaScript programmers can reuse their existing knowledge when programming functions, property bindings or imported JavaScript files in QML. -In the following example, the \c {addConstant()} method will add 13 to the -parameter passed just as the programmer would expect irrespective of the +In the following example, the \c {addConstant()} method will add 13 to the +parameter passed just as the programmer would expect irrespective of the value of the QML object's \c a and \c b properties. \code @@ -83,8 +59,8 @@ QtObject { } \endcode -That QML respects JavaScript's normal scoping rules even applies in bindings. -This totally evil, abomination of a binding will assign 12 to the QML object's +That QML respects JavaScript's normal scoping rules even applies in bindings. +This totally evil, abomination of a binding will assign 12 to the QML object's \c a property. \code @@ -101,13 +77,13 @@ with local variables declared in another. \section1 Element Names and Imported JavaScript Files -\l {QML Document}s include import statements that define the element names -and JavaScript files visible to the document. In addition to their use in the -QML declaration itself, element names are used by JavaScript code when accessing -\l {Attached Properties} and enumeration values. +\l {QML Document}s include import statements that define the element names +and JavaScript files visible to the document. In addition to their use in the +QML declaration itself, element names are used by JavaScript code when accessing +\l {Attached Properties} and enumeration values. -The effect of an import applies to every property binding, and JavaScript -function in the QML document, even those in nested inline components. The +The effect of an import applies to every property binding, and JavaScript +function in the QML document, even those in nested inline components. The following example shows a simple QML file that accesses some enumeration values and calls an imported JavaScript function. @@ -130,10 +106,10 @@ ListView { \section1 Binding Scope Object -Property bindings are the most common use of JavaScript in QML. Property +Property bindings are the most common use of JavaScript in QML. Property bindings associate the result of a JavaScript expression with a property of an -object. The object to which the bound property belongs is known as the binding's -scope object. In this QML simple declaration the \l Item object is the +object. The object to which the bound property belongs is known as the binding's +scope object. In this QML simple declaration the \l Item object is the binding's scope object. \code @@ -144,21 +120,21 @@ Item { Bindings have access to the scope object's properties without qualification. In the previous example, the binding accesses the \l Item's \c parent property -directly, without needing any form of object prefix. QML introduces a more -structured, object-oriented approach to JavaScript, and consequently does not +directly, without needing any form of object prefix. QML introduces a more +structured, object-oriented approach to JavaScript, and consequently does not require the use of the JavaScript \c this property. Care must be used when accessing \l {Attached Properties} from bindings due to their interaction with the scope object. Conceptually attached properties exist on \e all objects, even if they only have an effect on a subset of those. -Consequently unqualified attached property reads will always resolve to an -attached property on the scope object, which is not always what the programmer +Consequently unqualified attached property reads will always resolve to an +attached property on the scope object, which is not always what the programmer intended. -For example, the \l PathView element attaches interpolated value properties to +For example, the \l PathView element attaches interpolated value properties to its delegates depending on their position in the path. As PathView only -meaningfully attaches these properties to the root element in the delegate, any -sub-element that accesses them must explicitly qualify the root object, as shown +meaningfully attaches these properties to the root element in the delegate, any +sub-element that accesses them must explicitly qualify the root object, as shown below. \code @@ -181,7 +157,7 @@ the unset \c {PathView.scale} attached property on itself. Each QML component in a QML document defines a logical scope. Each document has at least one root component, but can also have other inline sub-components. -The component scope is the union of the object ids within the component and the +The component scope is the union of the object ids within the component and the component's root element's properties. \code @@ -195,7 +171,7 @@ Item { anchors.top: parent.top } - Text { + Text { text: titleElement.text font.pixelSize: 18 anchors.bottom: parent.bottom @@ -203,7 +179,7 @@ Item { } \endcode -The example above shows a simple QML component that displays a rich text title +The example above shows a simple QML component that displays a rich text title string at the top, and a smaller copy of the same text at the bottom. The first \c Text element directly accesses the component's \c title property when forming the text to display. That the root element's properties are directly @@ -211,18 +187,18 @@ accessible makes it trivial to distribute data throughout the component. The second \c Text element uses an id to access the first's text directly. IDs are specified explicitly by the QML programmer so they always take precedence -over other property names (except for those in the \l {JavaScript Scope}). For -example, in the unlikely event that the binding's \l {Binding Scope Object}{scope -object} had a \c titleElement property in the previous example, the \c titleElement +over other property names (except for those in the \l {JavaScript Scope}). For +example, in the unlikely event that the binding's \l {Binding Scope Object}{scope +object} had a \c titleElement property in the previous example, the \c titleElement id would still take precedence. \section1 Component Instance Hierarchy -In QML, component instances connect their component scopes together to form a -scope hierarchy. Component instances can directly access the component scopes of +In QML, component instances connect their component scopes together to form a +scope hierarchy. Component instances can directly access the component scopes of their ancestors. -The easiest way to demonstrate this is with inline sub-components whose component +The easiest way to demonstrate this is with inline sub-components whose component scopes are implicitly scoped as children of the outer component. \code @@ -239,16 +215,16 @@ Item { } \endcode -The component instance hierarchy allows instances of the delegate component +The component instance hierarchy allows instances of the delegate component to access the \c defaultColor property of the \c Item element. Of course, -had the delegate component had a property called \c defaultColor that would -have taken precedence. +had the delegate component had a property called \c defaultColor that would +have taken precedence. The component instance scope hierarchy extends to out-of-line components, too. -In the following example, the \c TitlePage.qml component creates two -\c TitleText instances. Even though the \c TitleText element is in a separate -file, it still has access to the \c title property when it is used from within -the \c TitlePage. QML is a dynamically scoped language - depending on where it +In the following example, the \c TitlePage.qml component creates two +\c TitleText instances. Even though the \c TitleText element is in a separate +file, it still has access to the \c title property when it is used from within +the \c TitlePage. QML is a dynamically scoped language - depending on where it is used, the \c title property may resolve differently. \code @@ -256,13 +232,13 @@ is used, the \c title property may resolve differently. import QtQuick 1.0 Item { property string title - - TitleText { + + TitleText { size: 22 anchors.top: parent.top } - TitleText { + TitleText { size: 18 anchors.bottom: parent.bottom } @@ -277,10 +253,10 @@ Text { } \endcode -Dynamic scoping is very powerful, but it must be used cautiously to prevent +Dynamic scoping is very powerful, but it must be used cautiously to prevent the behavior of QML code from becoming difficult to predict. In general it -should only be used in cases where the two components are already tightly -coupled in another way. When building reusable components, it is preferable +should only be used in cases where the two components are already tightly +coupled in another way. When building reusable components, it is preferable to use property interfaces, like this: \code @@ -289,14 +265,14 @@ import QtQuick 1.0 Item { id: root property string title - - TitleText { + + TitleText { title: root.title size: 22 anchors.top: parent.top } - TitleText { + TitleText { title: root.title size: 18 anchors.bottom: parent.bottom @@ -322,7 +298,7 @@ QML specific tasks a little easier. These extensions are described in the \l {QML Global Object} documentation. QML disallows element, id and property names that conflict with the properties -on the global object to prevent any confusion. Programmers can be confident +on the global object to prevent any confusion. Programmers can be confident that \c Math.min(10, 9) will always work as expected! */ diff --git a/doc/src/declarative/tutorial.qdoc b/doc/src/declarative/tutorial.qdoc index 1ee5e61..dc08ba0 100644 --- a/doc/src/declarative/tutorial.qdoc +++ b/doc/src/declarative/tutorial.qdoc @@ -144,7 +144,7 @@ An \l Item is the most basic visual element in QML and is often used as a contai We declare a \c cellColor property. This property is accessible from \e outside our component, this allows us to instantiate the cells with different colors. -This property is just an alias to an existing property - the color of the rectangle that compose the cell (see \l{Adding Properties}). +This property is just an alias to an existing property - the color of the rectangle that compose the cell (see \l{Property Binding}). \snippet examples/declarative/tutorials/helloworld/Cell.qml 5 diff --git a/doc/src/deployment/deployment-plugins.qdoc b/doc/src/deployment/deployment-plugins.qdoc index 12a3b0c..03685e5 100644 --- a/doc/src/deployment/deployment-plugins.qdoc +++ b/doc/src/deployment/deployment-plugins.qdoc @@ -104,7 +104,7 @@ plugins to be built in release mode, add the following line to the plugin's project file: - \snippet doc/src/snippets/code/doc_src_plugins-howto.qdoc 3 + \snippet doc/src/snippets/code/doc_src_plugins-howto.pro 3 This will ensure that the plugin is compatible with the version of the library used in the application. diff --git a/doc/src/deployment/deployment.qdoc b/doc/src/deployment/deployment.qdoc index bc80ed3..50f873f 100644 --- a/doc/src/deployment/deployment.qdoc +++ b/doc/src/deployment/deployment.qdoc @@ -336,7 +336,7 @@ are many ways to solve this: \list - + \o You can install the Qt libraries in one of the system library paths (e.g. \c /usr/lib on most systems). @@ -345,7 +345,7 @@ linker to look in this directory when starting your application. \o You can write a startup script for your application, where you - modify the dynamic linker configuration (e.g. adding your + modify the dynamic linker configuration (e.g., adding your application's directory to the \c LD_LIBRARY_PATH environment variable. \note If your application will be running with "Set user ID on execution," and if it will be owned by root, then @@ -375,7 +375,7 @@ \c plugins directory, or you can set the \c DESTDIR in the plugins' project files: - \snippet doc/src/snippets/code/doc_src_deployment.qdoc 8 + \snippet doc/src/snippets/code/doc_src_deployment.pro 8 An archive distributing all the Qt libraries, and all the plugins, required to run the \l {tools/plugandpaint}{Plug & Paint} @@ -422,7 +422,7 @@ application using QApplication::addLibraryPath() or QApplication::setLibraryPaths(). - \snippet doc/src/snippets/code/doc_src_deployment.qdoc 9 + \snippet doc/src/snippets/code/doc_src_deployment.cpp 9 \section1 Application Dependencies @@ -718,7 +718,7 @@ using QApplication::addLibraryPath() or QApplication::setLibraryPaths(). - \snippet doc/src/snippets/code/doc_src_deployment.qdoc 19 + \snippet doc/src/snippets/code/doc_src_deployment.cpp 19 One benefit of using plugins is that they can easily be made available to a whole family of applications. @@ -753,7 +753,7 @@ To use the options, add - \snippet doc/src/snippets/code/doc_src_deployment.qdoc 21 + \snippet doc/src/snippets/code/doc_src_deployment.pro 21 to your .pro file. The \c embed_manifest_dll option is enabled by default. The \c embed_manifest_exe option is NOT enabled by default. @@ -965,7 +965,7 @@ command line application on Unix and Windows. You probably don't want to run it in a bundle: Add this to your application's .pro: - \snippet doc/src/snippets/code/doc_src_deployment.qdoc 26 + \snippet doc/src/snippets/code/doc_src_deployment.pro 26 This will tell \c qmake not to put the executable inside a bundle. Please refer to the \l{Deploying an Application on @@ -1249,7 +1249,7 @@ to look for the new plugins. After constructing the QApplication, we add the following code: - \snippet doc/src/snippets/code/doc_src_deployment.qdoc 49 + \snippet doc/src/snippets/code/doc_src_deployment.cpp 49 First, we tell the application to only look for plugins in this directory. In our case, this is what we want since we only want to @@ -1366,7 +1366,7 @@ variable to get \e{weak linking} to work for your application. You can add: - \snippet doc/src/snippets/code/doc_src_deployment.qdoc 51 + \snippet doc/src/snippets/code/doc_src_deployment.pro 51 to your .pro file, and qmake will take care of this for you. @@ -1416,7 +1416,7 @@ add both to the \c CONFIG line. PowerPC users also need an SDK. For example: - \snippet doc/src/snippets/code/doc_src_deployment.qdoc 53 + \snippet doc/src/snippets/code/doc_src_deployment.pro 53 Besides \c lipo, you can also check your binaries with the \c file(1) command line tool or the Finder. @@ -1513,12 +1513,12 @@ First, we will change the vendor statement to something more meaningful. The application vendor is visible to end-user during the installation. - \snippet doc/src/snippets/code/doc_src_deployment.qdoc 56 + \snippet doc/src/snippets/code/doc_src_deployment.pro 56 Second we will tell the Symbian application installer that this application supports only S60 5.0 based devices: - \snippet doc/src/snippets/code/doc_src_deployment.qdoc 57 + \snippet doc/src/snippets/code/doc_src_deployment.pro 57 You can find a list of platform and device indentification codes from \l {http://wiki.forum.nokia.com/index.php/S60_Platform_and_device_identification_codes}{Forum Nokia Wiki}. diff --git a/doc/src/development/activeqt-dumpcpp.qdoc b/doc/src/development/activeqt-dumpcpp.qdoc index 504b3b4..54581e1 100644 --- a/doc/src/development/activeqt-dumpcpp.qdoc +++ b/doc/src/development/activeqt-dumpcpp.qdoc @@ -83,24 +83,24 @@ as \c noncreatable) have a default constructor; this is typically a single class of type \c Application. - \snippet doc/src/snippets/code/doc_src_activeqt-dumpcpp.qdoc 0 + \snippet doc/src/snippets/code/doc_src_activeqt-dumpcpp.cpp 0 All other classes can only be created by passing an IDispatch interface pointer to the constructor; those classes should however not be created explicitly. Instead, use the appropriate API of already created objects. - \snippet doc/src/snippets/code/doc_src_activeqt-dumpcpp.qdoc 1 + \snippet doc/src/snippets/code/doc_src_activeqt-dumpcpp.cpp 1 All coclass wrappers also have one constructors taking an interface wrapper class for each interface implemented. - \snippet doc/src/snippets/code/doc_src_activeqt-dumpcpp.qdoc 2 + \snippet doc/src/snippets/code/doc_src_activeqt-dumpcpp.cpp 2 You have to create coclasses to be able to connect to signals of the subobject. Note that the constructor deletes the interface object, so the following will cause a segmentation fault: - \snippet doc/src/snippets/code/doc_src_activeqt-dumpcpp.qdoc 3 + \snippet doc/src/snippets/code/doc_src_activeqt-dumpcpp.cpp 3 If the return type is of a coclass or interface type declared in another type library you have to include the namespace header for that other type library @@ -115,7 +115,7 @@ In this case, create the correct wrapper class explicitly: - \snippet doc/src/snippets/code/doc_src_activeqt-dumpcpp.qdoc 4 + \snippet doc/src/snippets/code/doc_src_activeqt-dumpcpp.cpp 4 You can of course use the IDispatch* returned directly, in which case you have to call \c Release() when finished with the interface. diff --git a/doc/src/development/debug.qdoc b/doc/src/development/debug.qdoc index 044ad0d..1669b00 100644 --- a/doc/src/development/debug.qdoc +++ b/doc/src/development/debug.qdoc @@ -142,7 +142,7 @@ If you include the <QtDebug> header file, the \c qDebug() function can also be used as an output stream. For example: - \snippet doc/src/snippets/code/doc_src_debug.qdoc 0 + \snippet doc/src/snippets/code/doc_src_debug.cpp 0 The Qt implementation of these functions prints the text to the \c stderr output under Unix/X11 and Mac OS X. With Windows, if it @@ -199,14 +199,14 @@ These macros are useful for detecting program errors, e.g. like this: - \snippet doc/src/snippets/code/doc_src_debug.qdoc 1 + \snippet doc/src/snippets/code/doc_src_debug.cpp 1 Q_ASSERT(), Q_ASSERT_X(), and Q_CHECK_PTR() expand to nothing if \c QT_NO_DEBUG is defined during compilation. For this reason, the arguments to these macro should not have any side-effects. Here is an incorrect usage of Q_CHECK_PTR(): - \snippet doc/src/snippets/code/doc_src_debug.qdoc 2 + \snippet doc/src/snippets/code/doc_src_debug.cpp 2 If this code is compiled with \c QT_NO_DEBUG defined, the code in the Q_CHECK_PTR() expression is not executed and \e alloc returns diff --git a/doc/src/development/designer-manual.qdoc b/doc/src/development/designer-manual.qdoc index 9a6220f..0f38c61 100644 --- a/doc/src/development/designer-manual.qdoc +++ b/doc/src/development/designer-manual.qdoc @@ -1385,17 +1385,13 @@ \target CreatingAMenu - \raw HTML - <div style="float: left; margin-right: 2em"> - \endraw + \div {class="float-left"} \inlineimage designer-creating-menu1.png \inlineimage designer-creating-menu2.png \br \inlineimage designer-creating-menu3.png \inlineimage designer-creating-menu4.png - \raw HTML - </div> - \endraw + \enddiv \section2 Creating a Menu @@ -1410,9 +1406,8 @@ \key Escape to reject it. You can undo the editing operation later if required. - \raw HTML - <div style="clear: both" /> - \endraw + \div {class="clear-both"} + \enddiv Menus can also be rearranged in the menu bar simply by dragging and dropping them in the preferred location. A vertical red line indicates the @@ -1423,17 +1418,13 @@ navigating the menu structure in the usual way. \target CreatingAMenuEntry - \raw HTML - <div style="float: right; margin-left: 2em"> - \endraw + \div {class="float-right"} \inlineimage designer-creating-menu-entry1.png \inlineimage designer-creating-menu-entry2.png \br \inlineimage designer-creating-menu-entry3.png \inlineimage designer-creating-menu-entry4.png - \raw HTML - </div> - \endraw + \enddiv \section2 Creating a Menu Entry @@ -1453,9 +1444,8 @@ be accessible via the \l{#TheActionEditor}{Action Editor}, and any associated keyboard shortcut can be set there. - \raw HTML - <div style="clear: both" /> - \endraw + \div {class="clear-both"} + \enddiv Just like with menus, entries can be moved around simply by dragging and dropping them in the preferred location. When an entry is dragged over a @@ -1465,13 +1455,9 @@ \section1 Toolbars - \raw HTML - <div style="float: left; margin-right: 2em"> - \endraw + \div {class="float-left"} \inlineimage designer-creating-toolbar.png - \raw HTML - </div> - \endraw + \enddiv \section2 Creating and Removing a Toolbar @@ -1483,9 +1469,8 @@ Toolbars are removed from the form via an entry in the toolbar's context menu. - \raw HTML - <div style="clear: both" /> - \endraw + \div {class="clear-both"} + \enddiv \section2 Adding and Removing Toolbar Buttons @@ -1494,14 +1479,10 @@ Since actions can be represented by menu entries and toolbar buttons, they can be moved between menus and toolbars. - \raw HTML - <div style="float: right; margin-left: 2em"> - \endraw + \div {class="float-right"} \inlineimage designer-adding-toolbar-action.png \inlineimage designer-removing-toolbar-action.png - \raw HTML - </div> - \endraw + \enddiv To share an action between a menu and a toolbar, drag its icon from the action editor to the toolbar rather than from the menu where its entry is @@ -1510,9 +1491,8 @@ Toolbar buttons are removed via the toolbar's context menu. - \raw HTML - <div style="clear: both" /> - \endraw + \div {class="clear-both"} + \enddiv \section1 Actions @@ -1521,13 +1501,9 @@ action editor window, simplifying the creation and management of actions. \target TheActionEditor - \raw HTML - <div style="float: left; margin-right: 2em"> - \endraw + \div {class="float-left"} \inlineimage designer-action-editor.png - \raw HTML - </div> - \endraw + \enddiv \section2 The Action Editor @@ -1543,9 +1519,8 @@ \gui{Detailed View}. You can also copy and paste actions between menus, toolbars and forms. - \raw HTML - <div style="clear: both" /> - \endraw + \div {class="clear-both"} + \enddiv \section2 Creating an Action @@ -1560,19 +1535,14 @@ Once the action is created, it can be used wherever actions are applicable. - \raw HTML - <div style="clear: left" /> - \endraw + \div {class="clear-left"} + \enddiv \target AddingAnAction - \raw HTML - <div style="float: right; margin-left: 2em"> - \endraw + \div {class="float-right"} \inlineimage designer-adding-menu-action.png \inlineimage designer-adding-toolbar-action.png - \raw HTML - </div> - \endraw + \enddiv \section2 Adding an Action @@ -1584,9 +1554,8 @@ will be added. Release the mouse button to add the action when you have found the right spot. - \raw HTML - <div style="clear: right" /> - \endraw + \div {class="clear-right"} + \enddiv \section1 Dock Widgets @@ -1598,13 +1567,9 @@ \target AddingADockWidget - \raw HTML - <div style="float: left; margin-right: 2em"> - \endraw + \div {class="float-left"} \inlineimage designer-adding-dockwidget.png - \raw HTML - </div> - \endraw + \enddiv \section2 Adding a Dock Widget @@ -1623,9 +1588,8 @@ \l{QDockWidget::}{windowTitle} property. This also helps to identify them on the form. - \raw HTML - <div style="clear: both" /> - \endraw + \div {class="clear-both"} + \enddiv */ @@ -2044,7 +2008,7 @@ pixmap property in the property editor. project file, ensuring that the application is compiled and linked appropriately. - \snippet doc/src/snippets/code/doc_src_designer-manual.qdoc 0 + \snippet doc/src/snippets/code/doc_src_designer-manual.pro 0 The QUiLoader class provides a form loader object to construct the user interface. This user interface can be retrieved from any QIODevice, e.g., @@ -2054,7 +2018,7 @@ pixmap property in the property editor. The QtUiTools module classes can be included using the following directive: - \snippet doc/src/snippets/code/doc_src_designer-manual.qdoc 1 + \snippet doc/src/snippets/code/doc_src_designer-manual.cpp 1 The QUiLoader::load() function is invoked as shown in this code from the \l{Text Finder Example}{Text Finder} example: @@ -2126,7 +2090,7 @@ pixmap property in the property editor. \c setupUi() function to do this, so we only need to declare and implement a slot with a name that follows a standard convention: - \snippet doc/src/snippets/code/doc_src_designer-manual.qdoc 2 + \snippet doc/src/snippets/code/doc_src_designer-manual.cpp 2 Using this convention, we can define and implement a slot that responds to mouse clicks on the \gui OK button: @@ -2588,7 +2552,7 @@ pixmap property in the property editor. plugins are also built in release mode. To do this, include the following declaration in the plugin's \c{.pro} file: - \snippet doc/src/snippets/code/doc_src_designer-manual.qdoc 3 + \snippet doc/src/snippets/code/doc_src_designer-manual.pro 3 If plugins are built in a mode that is incompatible with \QD, they will not be loaded and installed. For more information about plugins, see the @@ -2597,7 +2561,7 @@ pixmap property in the property editor. It is also necessary to ensure that the plugin is installed together with other \QD widget plugins: - \snippet doc/src/snippets/code/doc_src_designer-manual.qdoc 4 + \snippet doc/src/snippets/code/doc_src_designer-manual.pro 4 The \c $[QT_INSTALL_PLUGINS] variable is a placeholder to the location of the installed Qt plugins. You can configure \QD to look for plugins in @@ -2756,7 +2720,7 @@ pixmap property in the property editor. using the Q_INTERFACES() macro in the extension class's definition. For example: - \snippet doc/src/snippets/code/doc_src_designer-manual.qdoc 7 + \snippet doc/src/snippets/code/doc_src_designer-manual.cpp 7 This enables \QD to use the qobject_cast() function to query for supported interfaces using a QObject pointer only. @@ -2791,13 +2755,13 @@ pixmap property in the property editor. You can either create a new QExtensionFactory and reimplement the QExtensionFactory::createExtension() function: - \snippet doc/src/snippets/code/doc_src_designer-manual.qdoc 8 + \snippet doc/src/snippets/code/doc_src_designer-manual.cpp 8 or you can use an existing factory, expanding the QExtensionFactory::createExtension() function to enable the factory to create your custom extension as well: - \snippet doc/src/snippets/code/doc_src_designer-manual.qdoc 9 + \snippet doc/src/snippets/code/doc_src_designer-manual.cpp 9 \section2 Accessing Qt Designer's Extension Manager @@ -2809,7 +2773,7 @@ pixmap property in the property editor. an extension factory is typically made in the QDesignerCustomWidgetInterface::initialize() function: - \snippet doc/src/snippets/code/doc_src_designer-manual.qdoc 10 + \snippet doc/src/snippets/code/doc_src_designer-manual.cpp 10 The \c formEditor parameter in the QDesignerCustomWidgetInterface::initialize() function is a pointer to \QD's diff --git a/doc/src/development/moc.qdoc b/doc/src/development/moc.qdoc index fc0165b..5d524b2 100644 --- a/doc/src/development/moc.qdoc +++ b/doc/src/development/moc.qdoc @@ -136,7 +136,7 @@ This guarantees that make will run the moc before it compiles \c foo.cpp. You can then put - \snippet doc/src/snippets/code/doc_src_moc.qdoc 3 + \snippet doc/src/snippets/code/doc_src_moc.cpp 3 at the end of \c foo.cpp, where all the classes declared in that file are fully known. @@ -223,7 +223,7 @@ file. \c moc defines the preprocessor symbol \c Q_MOC_RUN. Any code surrounded by - \snippet doc/src/snippets/code/doc_src_moc.qdoc 4 + \snippet doc/src/snippets/code/doc_src_moc.cpp 4 is skipped by the \c moc. @@ -245,7 +245,7 @@ \c moc does not handle all of C++. The main problem is that class templates cannot have signals or slots. Here is an example: - \snippet doc/src/snippets/code/doc_src_moc.qdoc 5 + \snippet doc/src/snippets/code/doc_src_moc.cpp 5 Another limitation is that moc does not expand macros, so you for example cannot use a macro to declare a signal/slot @@ -261,7 +261,7 @@ first inherited class is a subclass of QObject. Also, be sure that only the first inherited class is a QObject. - \snippet doc/src/snippets/code/doc_src_moc.qdoc 6 + \snippet doc/src/snippets/code/doc_src_moc.cpp 6 Virtual inheritance with QObject is \e not supported. @@ -271,11 +271,11 @@ signal or slot parameters, we think inheritance is a better alternative. Here is an example of illegal syntax: - \snippet doc/src/snippets/code/doc_src_moc.qdoc 7 + \snippet doc/src/snippets/code/doc_src_moc.cpp 7 You can work around this restriction like this: - \snippet doc/src/snippets/code/doc_src_moc.qdoc 8 + \snippet doc/src/snippets/code/doc_src_moc.cpp 8 It may sometimes be even better to replace the function pointer with inheritance and virtual functions. @@ -289,7 +289,7 @@ fully qualify the data types when declaring signals and slots, and when establishing connections. For example: - \snippet doc/src/snippets/code/doc_src_moc.qdoc 9 + \snippet doc/src/snippets/code/doc_src_moc.cpp 9 \section2 Type Macros Cannot Be Used for Signal and Slot Parameters @@ -297,7 +297,7 @@ an argument will not work in signals and slots. Here is an illegal example: - \snippet doc/src/snippets/code/doc_src_moc.qdoc 10 + \snippet doc/src/snippets/code/doc_src_moc.cpp 10 A macro without parameters will work. @@ -305,7 +305,7 @@ Here's an example of the offending construct: - \snippet doc/src/snippets/code/doc_src_moc.qdoc 11 + \snippet doc/src/snippets/code/doc_src_moc.cpp 11 \section2 Signal/Slot return types cannot be references diff --git a/doc/src/development/qmake-manual.qdoc b/doc/src/development/qmake-manual.qdoc index 1c5d903..2bc8a34 100644 --- a/doc/src/development/qmake-manual.qdoc +++ b/doc/src/development/qmake-manual.qdoc @@ -34,26 +34,26 @@ \ingroup qttools \keyword qmake - \l {qmake}{ \c qmake} is a tool that helps simplify the build - process for development project across different platforms. \l {qmake}{ \c qmake} + \l{qmake}{\c qmake} is a tool that helps simplify the build process for + development project across different platforms. \l{qmake}{\c qmake} automates the generation of Makefiles so that only a few lines of - information are needed to create each Makefile. \l {qmake}{ \c qmake} can be used for - any software project, whether it is written in Qt or not. - - \l {qmake}{ \c qmake} generates a Makefile based on the information in a project - file. Project files are created by the developer, and are usually - simple, but more sophisticated project files can be created for - complex projects. - \l {qmake}{ \c qmake} contains additional features to support development with Qt, - automatically including build rules for \l{moc.html}{moc} + information are needed to create each Makefile. \l{qmake}{\c qmake} can be + used for any software project, whether it is written in Qt or not. + + \l{qmake}{\c qmake} generates a Makefile based on the information in a + project file. Project files are created by the developer, and are usually + simple, but more sophisticated project files can be created for complex + projects. + \l{qmake}{\c qmake} contains additional features to support development + with Qt, automatically including build rules for \l{moc.html}{moc} and \l{uic.html}{uic}. - \l {qmake}{ \c qmake} can also generate projects for Microsoft Visual studio + \l{qmake}{\c qmake} can also generate projects for Microsoft Visual studio without requiring the developer to change the project file. \section1 Getting Started The \l{qmake Tutorial} and guide to \l{qmake Common Projects} provide overviews - that aim to help new users get started with \l {qmake}{ \c qmake}. + that aim to help new users get started with \l{qmake}{\c qmake}. \list \o \l{qmake Tutorial} @@ -98,23 +98,24 @@ \previouspage qmake Manual \nextpage qmake Project Files - \l {qmake}{ \c qmake} provides a project-oriented system for managing the build - process for applications, libraries, and other components. This - approach gives developers control over the source files used, and + \l{qmake Manual#qmake}{\c qmake} provides a project-oriented system for + managing the buildprocess for applications, libraries, and other components. + This approach gives developers control over the source files used, and allows each of the steps in the process to be described concisely, - typically within a single file. \l {qmake}{ \c qmake} expands the information in - each project file to a Makefile that executes the necessary commands - for compiling and linking. + typically within a single file. \l{qmake Manual#qmake}{\c qmake} expands + the information in each project file to a Makefile that executes the necessary + commands for compiling and linking. In this document, we provide a basic introduction to project files, - describe some of the main features of \l {qmake}{ \c qmake}, and show how to use - \l {qmake}{ \c qmake} on the command line. + describe some of the main features of \l{qmake Manual#qmake}{\c qmake}, + and show how to use \l{qmake Manual#qmake}{\c qmake} on the command line. \section1 Describing a Project Projects are described by the contents of project (\c .pro) files. - The information within these is used by \l {qmake}{ \c qmake} to generate a Makefile - containing all the commands that are needed to build each project. + The information within these is used by \l{qmake Manual#qmake}{\c qmake} + to generate a Makefile containing all the commands that are needed to + build each project. Project files typically contain a list of source and header files, general configuration information, and any application-specific details, such as a list of extra libraries to link against, or a list of extra @@ -134,13 +135,14 @@ \section1 Building a Project - For simple projects, you only need to run \l {qmake}{ \c qmake} in the top - level directory of your project. By default, \l {qmake}{ \c qmake} generates a - Makefile that you then use to build the project, and you can then - run your platform's \c make tool to build the project. + For simple projects, you only need to run \l{qmake Manual#qmake}{\c qmake} + in the top level directory of your project. By default, + \l{qmake Manual#qmake}{\c qmake} generates a Makefile that you then use + to build the project, and you can then run your platform's \c make tool + to build the project. - \l {qmake}{ \c qmake} can also be used to generate project files. A full - description of \c{qmake}'s command line options can be found in the + \l{qmake Manual#qmake}{\c qmake} can also be used to generate project files. + A full description of \c{qmake}'s command line options can be found in the \l{Running qmake} chapter of this manual. \section1 Using Precompiled Headers @@ -157,38 +159,40 @@ \previouspage Using qmake \nextpage Running qmake - Project files contain all the information required by \l {qmake}{ \c qmake} to build - your application, library, or plugin. The resources used by your project - are generally specified using a series of declarations, but support for - simple programming constructs allow you to describe different build - processes for different platforms and environments. + Project files contain all the information required by + \l{qmake Manual#qmake}{\c qmake} to build your application, library, + or plugin. The resources used by your project are generally specified + using a series of declarations, but support for simple programming + constructs allow you to describe different build processes for different + platforms and environments. \tableofcontents \section1 Project File Elements - The project file format used by \l {qmake}{ \c qmake} can be used to support both - simple and fairly complex build systems. Simple project files will - use a straightforward declarative style, defining standard variables - to indicate the source and header files that are used in the project. - Complex projects may use the control flow structures to fine-tune the - build process. + The project file format used by \l{qmake Manual#qmake}{\c qmake} can be + used to support both simple and fairly complex build systems. + Simple project files will use a straightforward declarative style, + defining standard variables to indicate the source and header files + that are used in the project. Complex projects may use the control flow + structures to fine-tune the build process. The following sections describe the different types of elements used in project files. \section2 Variables - In a project file, variables are used to hold lists of strings. - In the simplest projects, these variables inform \l {qmake}{ \c qmake} about the - configuration options to use, or supply filenames and paths to use - in the build process. + In a project file, variables are used to hold lists of strings. In the + simplest projects, these variables inform \l{qmake Manual#qmake}{\c qmake} + about the configuration options to use, or supply filenames and paths to + use in the build process. - \l {qmake}{ \c qmake} looks for certain variables in each project file, and it - uses the contents of these to determine what it should write to a - Makefile. For example, the list of values in the \c HEADERS and - \c SOURCES variables are used to tell \l {qmake}{ \c qmake} about header and - source files in the same directory as the project file. + \l{qmake Manual#qmake}{\c qmake} looks for certain variables in each + project file, and it uses the contents of these to determine what it + should write to a Makefile. For example, the list of values in the + \c HEADERS and \c SOURCES variables are used to tell + \l{qmake Manual#qmake}{\c qmake} about header and source files in the + same directory as the project file. Variables can also be used internally to store temporary lists of values, and existing lists of values can be overwritten or extended with new @@ -206,14 +210,15 @@ \snippet doc/src/snippets/qmake/variables.pro 1 - The \c CONFIG variable is another special variable that \l {qmake}{ \c qmake} - uses when generating a Makefile. It is discussed in the section on + The \c CONFIG variable is another special variable that + \l{qmake Manual#qmake}{\c qmake} uses when generating a Makefile. + It is discussed in the section on \l{#GeneralConfiguration}{general configuration} later in this chapter. In the above line, \c qt is added to the list of existing values contained in \c CONFIG. - The following table lists the variables that \l {qmake}{ \c qmake} recognizes, and - describes what they should contain. + The following table lists the variables that \l{qmake Manual#qmake}{\c qmake} + recognizes, and describes what they should contain. \table \header \o Variable \o Contents @@ -273,8 +278,9 @@ \section2 Built-in Functions and Control Flow - \l {qmake}{ \c qmake} provides a number of built-in functions to allow the contents - of variables to be processed. The most commonly used function in simple + \l{qmake Manual#qmake}{\c qmake} provides a number of built-in functions + to allow the contents of variables to be processed. + The most commonly used function in simple project files is the \c include function which takes a filename as an argument. The contents of the given file are included in the project file at the place where the \c include function is used. @@ -292,7 +298,8 @@ The assignments inside the braces are only made if the condition is true. In this case, the special \c win32 variable must be set; this happens automatically on Windows, but this can also be specified on - other platforms by running \l {qmake}{ \c qmake} with the \c{-win32} command line + other platforms by running \l{qmake Manual#qmake}{\c qmake} + with the \c{-win32} command line option (see \l{Running qmake} for more information). The opening brace must stand on the same line as the condition. @@ -313,15 +320,17 @@ \section1 Project Templates The \c TEMPLATE variable is used to define the type of project that will - be built. If this is not declared in the project file, \l {qmake}{ \c qmake} assumes - that an application should be built, and will generate an appropriate - Makefile (or equivalent file) for the purpose. + be built. If this is not declared in the project file, + \l{qmake Manual#qmake}{\c qmake} assumes that an application should be + built, and will generate an appropriate Makefile (or equivalent file) + for the purpose. The types of project available are listed in the following table with - information about the files that \l {qmake}{ \c qmake} will generate for each of them: + information about the files that \l{qmake Manual#qmake}{\c qmake} + will generate for each of them: \table - \header \o Template \o Description of \l {qmake}{ \c qmake}output + \header \o Template \o Description of \l{qmake Manual#qmake}{\c qmake} output \row \o app (default) \o Creates a Makefile to build an application. \row \o lib \o Creates a Makefile to build a library. \row \o subdirs \o Creates a Makefile containing rules for the @@ -336,9 +345,10 @@ See the \l{qmake Tutorial} for advice on writing project files for projects that use the \c app and \c lib templates. - When the \c subdirs template is used, \l {qmake}{ \c qmake} generates a Makefile - to examine each specified subdirectory, process any project file it finds - there, and run the platform's \c make tool on the newly-created Makefile. + When the \c subdirs template is used, \l{qmake Manual#qmake}{\c qmake} + generates a Makefile to examine each specified subdirectory, + process any project file it finds there, and run the platform's + \c make tool on the newly-created Makefile. The \l{qmake Variable Reference#SUBDIRS}{SUBDIRS} variable is used to contain a list of all the subdirectories to be processed. @@ -348,7 +358,8 @@ The \l{qmake Variable Reference#CONFIG}{CONFIG variable} specifies the options and features that the compiler should use and the libraries that should be linked against. Anything can be added to the \c CONFIG variable, - but the options covered below are recognized by \l {qmake}{ \c qmake} internally. + but the options covered below are recognized by + \l{qmake Manual#qmake}{\c qmake} internally. The following options control the compiler flags that are used to build the project: @@ -360,11 +371,11 @@ \row \o debug \o The project is to be built in debug mode. \row \o debug_and_release \o The project is built in \e both debug and release modes. - \row \o debug_and_release_target \o The project is built in \e both debug + \row \o debug_and_release_target \o The project is built in \e both debug and release modes. TARGET is built into \e both the debug and release directories. \row \o build_all \o If \c debug_and_release is specified, the project is built in both debug and release modes by default. - \row \o autogen_precompile_source \o Automatically generates a \c .cpp file that includes + \row \o autogen_precompile_source \o Automatically generates a \c .cpp file that includes the precompiled header file specified in the .pro file. \row \o ordered \o When using the \c subdirs template, this option specifies that the directories listed should be processed in the @@ -372,15 +383,15 @@ \row \o warn_on \o The compiler should output as many warnings as possible. This is ignored if \c warn_off is specified. \row \o warn_off \o The compiler should output as few warnings as possible. - \row \o copy_dir_files \o Enables the install rule to also copy directories, not just files. + \row \o copy_dir_files \o Enables the install rule to also copy directories, not just files. \endtable The \c debug_and_release option is special in that it enables \e both debug and release versions of a project to be built. In such a case, the Makefile that - \l {qmake}{ \c qmake} generates includes a rule that builds both versions, and this can be - invoked in the following way: + \l{qmake Manual#qmake}{\c qmake} generates includes a rule that builds both versions, + and this can be invoked in the following way: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 0 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 0 Adding the \c build_all option to the \c CONFIG variable makes this rule the default when building the project, and installation targets will be @@ -423,10 +434,11 @@ build it as a multi-threaded application in \c debug mode, your project file will contain the following line: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 1 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 1 - Note, that you must use "+=", not "=", or \l {qmake}{ \c qmake} will not be able to - use Qt's configuration to determine the settings needed for your project. + Note, that you must use "+=", not "=", or \l{qmake Manual#qmake}{\c qmake} + will not be able to use Qt's configuration to determine the settings + needed for your project. \section1 Declaring Qt Libraries @@ -436,21 +448,21 @@ variable which can be used to declare the required extension modules. For example, we can enable the XML and network modules in the following way: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 2 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 2 Note that \c QT includes the \c core and \c gui modules by default, so the above declaration \e adds the network and XML modules to this default list. The following assignment \e omits the default modules, and will lead to errors when the application's source code is being compiled: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 3 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 3 If you want to build a project \e without the \c gui module, you need to exclude it with the "-=" operator. By default, \c QT contains both \c core and \c gui, so the following line will result in a minimal Qt project being built: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 4 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 4 The table below shows the options that can be used with the \c QT variable and the features that are associated with each of them: @@ -475,18 +487,18 @@ \section1 Configuration Features - \l {qmake}{ \c qmake} can be set up with extra configuration features that are specified - in feature (.prf) files. These extra features often provide support for - custom tools that are used during the build process. To add a feature to - the build process, append the feature name (the stem of the feature filename) - to the \c CONFIG variable. + \l{qmake Manual#qmake}{\c qmake} can be set up with extra configuration + features that are specified in feature (.prf) files. These extra features + often provide support for custom tools that are used during the build + process. To add a feature to the build process, append the feature name + (the stem of the feature filename) to the \c CONFIG variable. - For example, \l {qmake}{ \c qmake} can configure the build process to take advantage - of external libraries that are supported by + For example, \l{qmake Manual#qmake}{\c qmake} can configure the build + process to take advantage of external libraries that are supported by \l{http://www.freedesktop.org/wiki/Software_2fpkgconfig}{pkg-config}, such as the D-Bus and ogg libraries, with the following lines: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 5 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 5 More information about features can be found in the \l{qmake Advanced Usage#Adding New Configuration Features} @@ -498,15 +510,15 @@ If you are using other libraries in your project in addition to those supplied with Qt, you need to specify them in your project file. - The paths that \l {qmake}{ \c qmake} searches for libraries and the specific libraries - to link against can be added to the list of values in the + The paths that \l{qmake Manual#qmake}{\c qmake} searches for libraries + and the specific libraries to link against can be added to the list of values in the \l{qmake Variable Reference#LIBS}{LIBS} variable. The paths to the libraries themselves can be given, or the familiar Unix-style notation for specifying libraries and paths can be used if preferred. For example, the following lines show how a library can be specified: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 6 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 6 The paths containing header files can also be specified in a similar way using the \l{qmake Variable Reference#INCLUDEPATH}{INCLUDEPATH} variable. @@ -514,7 +526,7 @@ For example, it is possible to add several paths to be searched for header files: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 7 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 7 */ /*! @@ -524,8 +536,8 @@ \previouspage qmake Project Files \nextpage qmake Platform Notes - The behavior of \l {qmake}{ \c qmake} can be customized when it is run by - specifying various options on the command line. These allow the + The behavior of \l{qmake Manual#qmake}{\c qmake} can be customized when it + is run by specifying various options on the command line. These allow the build process to be fine-tuned, provide useful diagnostic information, and can be used to specify the target platform for your project. @@ -537,21 +549,23 @@ \section2 Syntax - The syntax used to run \l {qmake}{ \c qmake} takes the following simple form: + The syntax used to run \l{qmake Manual#qmake}{\c qmake} takes the + following simple form: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 8 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 8 - \l {qmake}{ \c qmake} supports two different modes of operation: In the default mode, - \l {qmake}{ \c qmake} will use the description in a project file to generate a Makefile, - but it is also possible to use \l {qmake}{ \c qmake} to generate project files. + \l{qmake Manual#qmake}{\c qmake} supports two different modes of operation: + In the default mode,\l{qmake Manual#qmake}{\c qmake} will use the + description in a project file to generate a Makefile, but it is also + possible to use \l{qmake Manual#qmake}{\c qmake} to generate project files. If you want to explicitly set the mode, you must specify it before all other options. The \c mode can be either of the following two values: \list \o \c -makefile \BR - \c qmake output will be a Makefile. + \l{qmake Manual#qmake}{\c qmake} output will be a Makefile. \o \c -project \BR - \c qmake output will be a project file. \BR + \l{qmake Manual#qmake}{\c qmake} output will be a project file. \BR \bold{Note:} It is likely that the created file will need to be edited; for example, adding the \c QT variable to suit what modules are required for the project. \endlist @@ -567,42 +581,48 @@ \section2 Options - A wide range of options can be specified on the command line to \l {qmake}{ \c qmake} in - order to customize the build process, and to override default settings for - your platform. The following basic options provide usage information, specify - where \l {qmake}{ \c qmake} writes the output file, and control the level of debugging - information that will be written to the console: + A wide range of options can be specified on the command line to + \l{qmake Manual#qmake}{\c qmake} in order to customize the build process, + and to override default settings for your platform. The following basic + options provide usage information, specify where + \l{qmake Manual#qmake}{\c qmake} writes the output file, and control the + level of debugging information that will be written to the console: \list \o \c -help \BR - \c qmake will go over these features and give some useful help. + \l{qmake Manual#qmake}{\c qmake} will go over these features and give some + useful help. \o \c -o file \BR - \c qmake output will be directed to \e file. If this option - is not specified, \c qmake will try to use a suitable file name for its - output, depending on the mode it is running in.\BR + \l{qmake Manual#qmake}{\c qmake} output will be directed to \e file. If + this option is not specified, \l{qmake Manual#qmake}{\c qmake} will try + to use a suitable file name for its output, depending on the mode it is + running in.\BR If '-' is specified, output is directed to stdout. \o \c -d \BR - \c qmake will output debugging information. + \l{qmake Manual#qmake}{\c qmake} will output debugging information. \endlist - For projects that need to be built differently on each target platform, with - many subdirectories, you can run \l {qmake}{ \c qmake} with each of the following - options to set the corresponding platform-specific variable in each - project file: + For projects that need to be built differently on each target platform, + with many subdirectories, you can run \l{qmake Manual#qmake}{\c qmake} with + each of the following options to set the corresponding platform-specific + variable in each project file: \list \o \c -unix \BR - \c qmake will run in unix mode. In this mode, Unix file - naming and path conventions will be used, additionally testing for \c unix - (as a scope) will succeed. This is the default mode on all Unices. + \l{qmake Manual#qmake}{\c qmake} will run in unix mode. In this mode, + Unix file naming and path conventions will be used, additionally + testing for \c unix (as a scope) will succeed. This is the default + mode on all Unices. \o \c -macx \BR - \c qmake will run in Mac OS X mode. In this mode, Unix file - naming and path conventions will be used, additionally testing for \c macx - (as a scope) will succeed. This is the default mode on Mac OS X. + \l{qmake Manual#qmake}{\c qmake} will run in Mac OS X mode. In this + mode, Unix file naming and path conventions will be used, additionally + testing for \c macx (as a scope) will succeed. This is the default mode + on Mac OS X. \o \c -win32 \BR - \c qmake will run in win32 mode. In this mode, Windows file naming and path - conventions will be used, additionally testing for \c win32 (as a scope) - will succeed. This is the default mode on Windows. + \l{qmake Manual#qmake}{\c qmake} will run in win32 mode. In this mode, + Windows file naming and path conventions will be used, additionally + testing for \c win32 (as a scope) will succeed. This is the default + mode on Windows. \endlist The template used for the project is usually specified by the \c TEMPLATE @@ -611,10 +631,11 @@ \list \o \c -t tmpl \BR - \c qmake will override any set \c TEMPLATE variables with tmpl, but only - \e after the .pro file has been processed. + \l{qmake Manual#qmake}{\c qmake} will override any set \c TEMPLATE + variables with tmpl, but only \e after the .pro file has been processed. \o \c -tp prefix \BR - \c qmake will add the prefix to the \c TEMPLATE variable. + \l{qmake Manual#qmake}{\c qmake} will add the prefix to the \c TEMPLATE + variable. \endlist The level of warning information can be fine-tuned to help you find problems in @@ -622,54 +643,59 @@ \list \o \c -Wall \BR - \c qmake will report all known warnings. + \l{qmake Manual#qmake}{\c qmake} will report all known warnings. \o \c -Wnone \BR - No warning information will be generated by \c qmake. + No warning information will be generated by \ + l{qmake Manual#qmake}{\c qmake}. \o \c -Wparser \BR - \c qmake will only generate parser warnings. This will alert - you to common pitfalls and potential problems in the parsing of your - project files. + \l{qmake Manual#qmake}{\c qmake} will only generate parser warnings. + This will alert you to common pitfalls and potential problems in the + parsing of your project files. \o \c -Wlogic \BR - \c qmake will warn of common pitfalls and potential problems in your - project file. For example, \c qmake will report whether a file is placed - into a list of files multiple times, or if a file cannot be found. + \l{qmake Manual#qmake}{\c qmake} will warn of common pitfalls and + potential problems in your project file. For example, + \l{qmake Manual#qmake}{\c qmake} will report whether a file is placed + into a list of files multiple times, or if a file cannot be found. \endlist \target MakefileMode \section2 Makefile Mode Options - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 9 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 9 - In Makefile mode, \l {qmake}{ \c qmake} will generate a Makefile that is used to build the - project. Additionally, the following options may be used in this mode to - influence the way the project file is generated: + In Makefile mode, \l{qmake Manual#qmake}{\c qmake} will generate a Makefile + that is used to build the project. Additionally, the following options may + be used in this mode to influence the way the project file is generated: \list \o \c -after \BR - \c qmake will process assignments given on the command line after - the specified files. + \l{qmake Manual#qmake}{\c qmake} will process assignments given on the + command line after the specified files. \o \c -nocache \BR - \c qmake will ignore the .qmake.cache file. + \l{qmake Manual#qmake}{\c qmake} will ignore the .qmake.cache file. \o \c -nodepend \BR - \c qmake will not generate any dependency information. + \l{qmake Manual#qmake}{\c qmake} will not generate any dependency + information. \o \c -cache file \BR - \c qmake will use \e file as the cache file, ignoring any other - .qmake.cache files found. + \l{qmake Manual#qmake}{\c qmake} will use \e file as the cache file, + ignoring any other .qmake.cache files found. \o \c -spec spec \BR - \c qmake will use \e spec as a path to platform and compiler information, - and the value of \c QMAKESPEC will be ignored. + \l{qmake Manual#qmake}{\c qmake} will use \e spec as a path to + platform and compiler information, and the value of \c QMAKESPEC will + be ignored. \endlist - You may also pass \l {qmake}{ \c qmake} assignments on the command line; - they will be processed before all of the files specified. For example: + You may also pass \l{qmake Manual#qmake}{\c qmake} assignments on the + command line; they will be processed before all of the files specified. + For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 10 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 10 This will generate a Makefile, from test.pro with Unix pathnames. However many of the specified options aren't necessary as they are the default. Therefore, the line can be simplified on Unix to: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 11 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 11 If you are certain you want your variables processed after the files specified, then you may pass the \c -after option. When this @@ -679,17 +705,18 @@ \target ProjectMode \section2 Project Mode Options - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 12 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 12 - In project mode, \l {qmake}{ \c qmake} will generate a project file. Additionally, you - may supply the following options in this mode: + In project mode, \l{qmake Manual#qmake}{\c qmake} will generate a project + file. Additionally, you may supply the following options in this mode: \list \o \c -r \BR - \c qmake will look through supplied directories recursively + \l{qmake Manual#qmake}{\c qmake} will look through supplied directories + recursively \o \c -nopwd \BR - \c qmake will not look in your current working directory for - source code and only use the specified \c files + \l{qmake Manual#qmake}{\c qmake} will not look in your current working + directory for source code and only use the specified \c files \endlist In this mode, the \c files argument can be a list of files or directories. @@ -712,9 +739,10 @@ Many cross-platform projects can be handled by the \c{qmake}'s basic configuration features. On some platforms, it is sometimes useful, or even - necessary, to take advantage of platform-specific features. \l {qmake}{ \c qmake} knows - about many of these features, and these can be accessed via specific - variables that only have an effect on the platforms where they are relevant. + necessary, to take advantage of platform-specific features. + \l{qmake Manual#qmake}{\c qmake} knows about many of these features, and + these can be accessed via specific variables that only have an effect on + the platforms where they are relevant. \tableofcontents @@ -725,38 +753,39 @@ \section2 Source and Binary Packages - The version of \l {qmake}{ \c qmake} supplied in source packages is configured slightly - differently to that supplied in binary packages in that it uses a different - feature specification. Where the source package typically uses the - \c macx-g++ specification, the binary package is typically configured to - use the \c macx-xcode specification. + The version of \l{qmake Manual#qmake}{\c qmake} supplied in source packages + is configured slightly differently to that supplied in binary packages in + that it uses a different feature specification. Where the source package + typically uses the \c macx-g++ specification, the binary package is + typically configured to use the \c macx-xcode specification. - Users of each package can override this configuration by invoking \l {qmake}{ \c qmake} - with the \c -spec option (see \l{Running qmake} for more information). This - makes it possible, for example, to use \l {qmake}{ \c qmake} from a binary package to + Users of each package can override this configuration by invoking + \l{qmake Manual#qmake}{\c qmake} with the \c -spec option (see + \l{Running qmake} for more information). This makes it possible, for + example, to use \l{qmake Manual#qmake}{\c qmake} from a binary package to create a Makefile in a project directory with the following command line invocation: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 13 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 13 \section2 Using Frameworks - \l {qmake}{ \c qmake} is able to automatically generate build rules for linking against - frameworks in the standard framework directory on Mac OS X, located at - \c{/Library/Frameworks/}. + \l{qmake Manual#qmake}{\c qmake} is able to automatically generate build + rules for linking against frameworks in the standard framework directory on + Mac OS X, located at \c{/Library/Frameworks/}. Directories other than the standard framework directory need to be specified to the build system, and this is achieved by appending linker options to the \l{qmake Variable Reference#QMAKE_LFLAGS}{QMAKE_LFLAGS} variable, as shown in the following example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 14 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 14 The framework itself is linked in by appending the \c{-framework} options and the name of the framework to the \l{qmake Variable Reference#LIBS}{LIBS} variable: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 15 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 15 \section2 Creating Frameworks @@ -768,7 +797,7 @@ \c lib_bundle option to the \l{qmake Variable Reference#CONFIG}{CONFIG} variable: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 16 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 16 The data associated with the library is specified using the \l{qmake Variable Reference#QMAKE_BUNDLE_DATA}{QMAKE_BUNDLE_DATA} @@ -776,7 +805,7 @@ bundle, and is often used to specify a collection of header files, as in the following example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 17 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 17 Here, the \c FRAMEWORK_HEADERS variable is a user-defined variable that is used to define the headers required to use a particular framework. @@ -801,10 +830,11 @@ The architectures to be supported in the binary are specified with the \l{qmake Variable Reference#CONFIG}{CONFIG} variable. For example, the - following assignment causes \l {qmake}{ \c qmake} to generate build rules to create - a universal binary for both PowerPC and x86 architectures: + following assignment causes \l{qmake Manual#qmake}{\c qmake} to generate + build rules to create a universal binary for both PowerPC and x86 + architectures: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 18 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 18 Additionally, developers using a PowerPC-based platform need to set the \l{qmake Variable Reference#QMAKE_MAC_SDK}{QMAKE_MAC_SDK} variable. @@ -816,13 +846,15 @@ Developers on Mac OS X can take advantage of \c{qmake}'s support for Xcode project files, as described in \l{Qt is Mac OS X Native#Development Tools}{Qt is Mac OS X Native}, - by running \l {qmake}{ \c qmake} to generate an Xcode project from an existing \l {qmake}{ \c qmake} - project files. For example: + by running \l{qmake Manual#qmake}{\c qmake} to generate an Xcode project + from an existing \l{qmake Manual#qmake}{\c qmake} project files. For + example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 19 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 19 - Note that, if a project is later moved on the disk, \l {qmake}{ \c qmake} must be run - again to process the project file and create a new Xcode project file. + Note that, if a project is later moved on the disk, + \l{qmake Manual#qmake}{\c qmake} must be run again to process the project + file and create a new Xcode project file. \section2 On supporting two build targets simultaneously @@ -860,24 +892,27 @@ \l{Qt Commercial Edition} and do not need to worry about how project dependencies are managed. - However, some developers may need to import an existing \l {qmake}{ \c qmake} project - into Visual Studio. \l {qmake}{ \c qmake} is able to take a project file and create a - Visual Studio project that contains all the necessary information required - by the development environment. This is achieved by setting the \c qmake + However, some developers may need to import an existing + \l{qmake Manual#qmake}{\c qmake} project into Visual Studio. + \l{qmake Manual#qmake}{\c qmake} is able to take a project file and create + a Visual Studio project that contains all the necessary information + required by the development environment. This is achieved by setting the + \l{qmake Manual#qmake}{\c qmake} \l{qmake Variable Reference#TEMPLATE}{project template} to either \c vcapp (for application projects) or \c vclib (for library projects). This can also be set using a command line option, for example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 20 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 20 It is possible to recursively generate \c{.vcproj} files in subdirectories and a \c{.sln} file in the main directory, by typing: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 21 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 21 - Each time you update the project file, you need to run \l {qmake}{ \c qmake} to generate - an updated Visual Studio project. + Each time you update the project file, you need to run + \l{qmake Manual#qmake}{\c qmake} to generate an updated Visual Studio + project. \note If you are using the Visual Studio Add-in, you can import \c .pro files via the \gui{Qt->Import from .pro file} menu item. @@ -893,25 +928,25 @@ the following assignment to the \l{qmake Variable Reference#CONFIG} {CONFIG} variable: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 22 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 22 Also, the manifest embedding for DLLs can be removed with the following assignment to the \l{qmake Variable Reference#CONFIG}{CONFIG} variable: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 23 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 23 This is discussed in more detail in the \l{Deploying an Application on Windows#Visual Studio 2005 Onwards} {deployment guide for Windows}. - \section1 Symbian platform + \section1 Symbian Platform Features specific to this platform include handling of static data, capabilities, stack and heap size, compiler specific options, and unique identifiers for the application or library. - \section2 Handling of static data + \section2 Handling of Static Data If the application uses any static data, the build system needs to be informed about it. This is because Symbian tries to save memory if no @@ -919,11 +954,11 @@ To specify that static data support is desired, add this to the project file: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 129 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 129 The default value is zero. - \section2 Stack and heap size + \section2 Stack and Heap Size The Symbian platform uses predefined sizes for stacks and heaps. If an application exceeds either limit, it may crash or fail to complete its @@ -935,13 +970,13 @@ prevents the application from starting if that amount of memory is not available. The minimum and maximum values are separated by a space. For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 130 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 130 The default values depend on the version of the Symbian SDK you're using, - however, the Qt toolchain sets this to the maximum possible value and this - should not be changed. + however, the Qt toolchain sets this to the maximum possible value and this + should not be changed. - \section2 Compiler specific options + \section2 Compiler-Specific Options General compiler options can as usual be set using \c QMAKE_CFLAGS and \c QMAKE_CXXFLAGS. In order to set specific compiler options, \c QMAKE_CFLAGS.<compiler> and @@ -951,9 +986,9 @@ Here is an example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 131 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 131 - \section2 Unique identifiers + \section2 Unique Identifiers Symbian applications may have unique identifiers attached to them. Here is how to define them in a project file: @@ -961,37 +996,38 @@ There are four available types of IDs supported: \c UID2, \c UID3, \c SID, and \c VID. They are specified like this: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 132 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 132 If \c SID is not specified, it defaults to the same value as \c UID3. If \c UID3 is not specified, qmake will automatically generate a \c UID3 suitable for development and debugging. This value should be manually - specified for applications that are to be released. In order to obtain - an official UID, please contact \l{Symbian}{http:\\www.symbiansigned.com}. - Both \c SID and \c VID default to empty values. + specified for applications that are to be released. See the + \l{Symbian Signed} Web site for information about obtaining an official + UID. Both \c SID and \c VID default to empty values. There exists one UID1 too, but this should not be touched by any application. - - The UID2 has a specific value for different types of files - e.g. apps/exes - are always 0x100039CE. The toolchain will set this for value for the most common file types like, - EXE/APP and shared library DLL. - - For more information about unique identifiers and their meaning for Symbian applications, - please refer to the \l{Symbian SDK documentation}{http://developer.symbian.org/main/documentation/reference/s3/pdk/GUID-380A8C4F-3EB6-5E1C-BCFB-ED5B866136D9.html} - + + The UID2 has a specific value for different types of files; e.g. apps/exes + are always 0x100039CE. The toolchain will set this for value for the most common file types like, + EXE/APP and shared library DLL. + + For more information about unique identifiers and their meaning for + Symbian applications, please refer to the \l{UID Q&As (Symbian Signed)} + page in the \l{Forum Nokia Wiki} for more information. + \section2 Capabilities Capabilities define extra privileges for the application, such as the ability to list all files on the file system. Capabilities are defined in the project file like this: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 133 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 133 It is also possible to specify which capabilities \e not to have, by first specifying \c ALL and then list the unwanted capabilities with a minus in front of them, like this: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 134 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 134 For more information about capabilities, please refer to the Symbian SDK documentation. */ @@ -1003,14 +1039,14 @@ \previouspage Using Precompiled Headers \nextpage qmake Variable Reference - This reference is a detailed index of all the variables and function - that are available for use in \c qmake project files. + This reference is a detailed index of all the variables and function that + are available for use in \l{qmake Manual#qmake}{\c qmake} project files. \section1 Variable Reference The \l{qmake Variable Reference} describes the variables that are - recognized by \l {qmake}{ \c qmake}when configuring the build process for - projects. + recognized by \l{qmake Manual#qmake}{\c qmake}when configuring the build + process for projects. \section1 Function Reference @@ -1059,8 +1095,8 @@ \section1 Environment Variables and Configuration The \l{Configuring qmake's Environment} chapter of this manual - describes the environment variables that \l {qmake}{ \c qmake} uses when - configuring the build process. + describes the environment variables that \l{qmake Manual#qmake}{\c qmake} + uses when configuring the build process. */ /*! @@ -1089,23 +1125,23 @@ \e {This is only used on the Symbian platform.} - Generic \c bld.inf file content can be specified with \c BLD_INF_RULES variables. - The section of \c bld.inf file where each rule goes is appended to + Generic \c bld.inf file content can be specified with \c BLD_INF_RULES variables. + The section of \c bld.inf file where each rule goes is appended to \c BLD_INF_RULES with a dot. For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 152 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 152 - This will add the specified statements to the \c prj_exports section of the + This will add the specified statements to the \c prj_exports section of the generated \c bld.inf file. It is also possible to add multiple rows in a single block. Each double quoted string will be placed on a new row in the generated \c bld.inf file. - For example: + For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 143 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 143 Any rules you define will be added after automatically generated rules in each section. @@ -1115,7 +1151,7 @@ The \c CONFIG variable specifies project configuration and compiler options. The values will be recognized internally by - \l {qmake}{ \c qmake} and have special meaning. They are as follows. + \l{qmake Manual#qmake}{\c qmake} and have special meaning. They are as follows. These \c CONFIG values control compilation flags: @@ -1151,25 +1187,28 @@ defined in the \c CONFIG variable, it is necessary to use the \c debug_and_release option if you want to allow both debug and release versions of a project to be built. In such a case, the Makefile that - \l {qmake}{ \c qmake} generates includes a rule that builds both versions, and this can - be invoked in the following way: + \l{qmake Manual#qmake}{\c qmake} generates includes a rule that builds both + versions, and this can be invoked in the following way: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 24 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 24 - When linking a library, \l {qmake}{ \c qmake} relies on the underlying platform to know - what other libraries this library links against. However, if linking - statically, \l {qmake}{ \c qmake} will not get this information unless we use the following - \c CONFIG options: + When linking a library, \l{qmake Manual#qmake}{\c qmake} relies on the + underlying platform to know what other libraries this library links + against. However, if linking statically, \l{qmake Manual#qmake}{\c qmake} + will not get this information unless we use the following \c CONFIG + options: \table 95% \header \o Option \o Description - \row \o create_prl \o This option enables \l {qmake}{ \c qmake} to track these - dependencies. When this option is enabled, \l {qmake}{ \c qmake} will create a file + \row \o create_prl \o This option enables + \l{qmake Manual#qmake}{\c qmake} to track these dependencies. When this + option is enabled, \l{qmake Manual#qmake}{\c qmake} will create a file ending in \c .prl which will save meta-information about the library (see \l{LibDepend}{Library Dependencies} for more info). - \row \o link_prl \o When this is enabled, \l {qmake}{ \c qmake} will process all - libraries linked to by the application and find their meta-information - (see \l{LibDepend}{Library Dependencies} for more info). + \row \o link_prl \o When this is enabled, + \l{qmake Manual#qmake}{\c qmake} will process all libraries linked to + by the application and find their meta-information(see + \l{LibDepend}{Library Dependencies} for more info). \endtable Please note that \c create_prl is required when \e {building} a @@ -1189,7 +1228,7 @@ will be set for each of these mode, and you can test for this to perform build-specific tasks. For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 25 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 25 As a result, it may be useful to define mode-specific variables, such as \l{#QMAKE_LFLAGS_RELEASE}{QMAKE_LFLAGS_RELEASE}, instead of general @@ -1287,7 +1326,7 @@ \row \o stdbinary \o Builds an Open C binary (i.e. STDDLL, STDEXE, or STDLIB, depending on the target binary type.) \row \o no_icon \o Doesn't generate resources needed for displaying an icon - for executable in application menu (app only). + for executable in application menu (app only). \row \o symbian_test \o Places mmp files and extension makefiles under test sections in generated bld.inf instead of their regular sections. Note that this only affects automatically generated bld.inf content; @@ -1316,17 +1355,17 @@ For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 26 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 26 \target DEFINES \section1 DEFINES - \l {qmake}{ \c qmake} adds the values of this variable as compiler C - preprocessor macros (-D option). + \l{qmake Manual#qmake}{\c qmake} adds the values of this variable as + compiler C preprocessor macros (-D option). For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 27 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 27 \target DEF_FILE \section1 DEF_FILE @@ -1360,7 +1399,7 @@ For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 28 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 28 This will upload all PNG images in \c path to the same directory your build target will be deployed to. @@ -1376,7 +1415,7 @@ For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 29 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 29 \note In Windows CE all linked Qt libraries will be deployed to the path specified by \c{myFiles.path}. On Symbian platform all libraries and executables @@ -1387,7 +1426,7 @@ dynamically loadable libraries need special handling. When deploying extra executables or dynamically loadable libraries, the target path must specify \\sys\\bin. For plugins, the target path must specify the - location where the plugin stub will be deployed to (see the + location where the plugin stub will be deployed to (see the \l{How to Create Qt Plugins} document for more information about plugins). If the binary cannot be found from the indicated source path, the directory Symbian build process moves the executables to is @@ -1395,10 +1434,10 @@ For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 128 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 128 On the Symbian platform, generic PKG file content can also be specified with this - variable. You can use either \c pkg_prerules or \c pkg_postrules to + variable. You can use either \c pkg_prerules or \c pkg_postrules to pass raw data to PKG file. The strings in \c pkg_prerules are added before package-body and \c pkg_postrules after. \c pkg_prerules is used for defining vendor information, dependencies, custom package headers, and the @@ -1411,7 +1450,7 @@ For example, to deploy DLL and add a new dependency: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 140 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 140 Please note that \c pkg_prerules can also replace default statements in pkg file. If no pkg_prerules is defined, qmake makes sure that PKG file @@ -1445,7 +1484,7 @@ targeted to only one of above files by appending listed rules suffix to the variable name: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 153 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 153 On the Symbian platform, the \c default_deployment item specifies default platform and package dependencies. Those dependencies can be @@ -1462,7 +1501,7 @@ For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 141 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 141 On the Symbian platform, a default deployment is generated for all application projects. You can modify the autogenerated default @@ -1476,7 +1515,7 @@ For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 154 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 154 This will entirely remove the default application deployment. @@ -1486,7 +1525,7 @@ For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 155 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 155 This will show a message box that gives user an option to cancel the installation and then automatically runs the application after @@ -1502,19 +1541,19 @@ Often the default is not optimal for displaying to end user. To set a better display name for these purposes, use \c{DEPLOYMENT.display_name} variable: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 156 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 156 On the Symbian platform, you can use \c{DEPLOYMENT.installer_header} variable to generate smart installer wrapper for your application. If you specify just UID of the installer package as the value, then installer package name and version will be autogenerated: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 146 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 146 If autogenerated values are not suitable, you can also specify the sis header yourself using this variable: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 147 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 147 \target DEPLOYMENT_PLUGIN \section1 DEPLOYMENT_PLUGIN @@ -1525,8 +1564,8 @@ available in Qt can be explicitly deployed to the device. See \l{Static Plugins}{Static Plugins} for a complete list. - \note In Windows CE, No plugins will be deployed automatically. - If the application depends on plugins, these plugins have to be specified + \note In Windows CE, No plugins will be deployed automatically. + If the application depends on plugins, these plugins have to be specified manually. \note On the Symbian platform, all plugins supported by this variable @@ -1535,7 +1574,7 @@ For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 142 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 142 This will upload the jpeg imageformat plugin to the plugins directory on the Windows CE device. @@ -1547,15 +1586,16 @@ For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 30 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 30 \target DESTDIR_TARGET \section1 DESTDIR_TARGET - This variable is set internally by \l {qmake}{ \c qmake}, which is basically the - \c DESTDIR variable with the \c TARGET variable appened at the end. - The value of this variable is typically handled by \l {qmake}{ \c qmake} or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable is set internally by \l{qmake Manual#qmake}{\c qmake}, which + is basically the \c DESTDIR variable with the \c TARGET variable appened at + the end. The value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \target DLLDESTDIR \section1 DLLDESTDIR @@ -1570,15 +1610,16 @@ For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 31 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 31 \target DSP_TEMPLATE \section1 DSP_TEMPLATE - This variable is set internally by \l {qmake}{ \c qmake}, which specifies where the - dsp template file for basing generated dsp files is stored. The value - of this variable is typically handled by \l {qmake}{ \c qmake} or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable is set internally by \l{qmake Manual#qmake}{\c qmake}, which + specifies where the dsp template file for basing generated dsp files is + stored. The value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \target FORMS \section1 FORMS @@ -1590,7 +1631,7 @@ For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 32 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 32 If FORMS3 is defined in your project, then this variable must contain forms for uic, and not uic3. If CONFIG contains uic3, and FORMS3 is not @@ -1606,7 +1647,7 @@ For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 33 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 33 \target GUID \section1 GUID @@ -1623,16 +1664,16 @@ Defines the header files for the project. - \l {qmake}{ \c qmake} will generate dependency information (unless \c -nodepend - is specified on the \l{Running qmake#Commands}{command line}) - for the specified headers. \l {qmake}{ \c qmake} will also automatically detect if - \c moc is required by the classes in these headers, and add the - appropriate dependencies and files to the project for generating and - linking the moc files. + \l{qmake Manual#qmake}{\c qmake} will generate dependency information (unless + \c -nodepend is specified on the \l{Running qmake#Commands}{command line}) + for the specified headers. \l{qmake Manual#qmake}{\c qmake} will also + automatically detect if \c moc is required by the classes in these headers, + and add the appropriate dependencies and files to the project for generating + and linking the moc files. For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 34 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 34 See also \l{#SOURCES}{SOURCES}. @@ -1651,7 +1692,7 @@ For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 35 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 35 To specify a path containing spaces, quote the path using the technique mentioned in the \l{qmake Project Files#Whitespace}{qmake Project Files} @@ -1671,24 +1712,25 @@ build target will be installed, and the \c INSTALLS assignment adds the build target to the list of existing resources to be installed: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 36 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 36 - Note that \l {qmake}{ \c qmake} will skip files that are executable. If you need to install - executable files, you can unset the files' executable flags. + Note that \l{qmake Manual#qmake}{\c qmake} will skip files that are + executable. If you need to install executable files, you can unset the + files' executable flags. \target LEXIMPLS \section1 LEXIMPLS This variable contains a list of lex implementation files. The value - of this variable is typically handled by \l {qmake}{ \c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely - needs to be modified. + of this variable is typically handled by \l{qmake Manual#qmake}{\c qmake} or + \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. \target LEXOBJECTS \section1 LEXOBJECTS This variable contains the names of intermediate lex object files.The value of this variable is typically handled by - \l {qmake}{ \c qmake} and rarely needs to be modified. + \l{qmake Manual#qmake}{\c qmake} and rarely needs to be modified. \target LEXSOURCES \section1 LEXSOURCES @@ -1699,7 +1741,7 @@ For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 37 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 37 \target LIBS \section1 LIBS @@ -1713,7 +1755,7 @@ For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 38 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 38 To specify a path containing spaces, quote the path using the technique mentioned in the \l{qmake Project Files#Whitespace}{qmake Project Files} @@ -1741,7 +1783,7 @@ unique names before it is used. To change this behavior, add the \c no_lflags_merge option to the \c CONFIG variable: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 39 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 39 \target LITERAL_HASH \section1 LITERAL_HASH @@ -1761,9 +1803,10 @@ \section1 MAKEFILE This variable specifies the name of the Makefile which - \l {qmake}{ \c qmake} should use when outputting the dependency information - for building a project. The value of this variable is typically - handled by \l {qmake}{ \c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + \l{qmake Manual#qmake}{\c qmake} should use when outputting the dependency + information for building a project. The value of this variable is + typically handled by \l{qmake Manual#qmake}{\c qmake} or + \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. \bold{Note:} On the Symbian platform, this variable is ignored. @@ -1772,44 +1815,45 @@ This variable contains the name of the Makefile generator to use when generating a Makefile. The value of this variable is typically - handled internally by \l {qmake}{ \c qmake} and rarely needs to be modified. + handled internally by \l{qmake Manual#qmake}{\c qmake} and rarely needs to + be modified. \target MMP_RULES \section1 MMP_RULES \e {This is only used on the Symbian platform.} - Generic MMP file content can be specified with this variable. + Generic MMP file content can be specified with this variable. For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 137 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 137 This will add the specified statement to the end of the generated MMP file. It is also possible to add multiple rows in a single block. Each double quoted string will be placed on a new row in the generated MMP file. - For example: + For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 138 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 138 If you need to include a hash (\c{#}) character inside the - \c MMP_RULES statement, it can be done with the variable + \c MMP_RULES statement, it can be done with the variable \c LITERAL_HASH as follows: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 139 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 139 There is also a convenience function for adding conditional rules called \c{addMMPRules}. Suppose you need certain functionality to require different library depending on architecture. This can be specified with \c{addMMPRules} as follows: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 148 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 148 \note You should not use this variable to add MMP statements that are explicitly supported by their own variables, such as - \c TARGET.EPOCSTACKSIZE. + \c TARGET.EPOCSTACKSIZE. Doing so could result in duplicate statements in the MMP file. \target MOC_DIR @@ -1820,7 +1864,7 @@ For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 40 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 40 \target OBJECTS \section1 OBJECTS @@ -1828,8 +1872,8 @@ This variable is generated from the \link #SOURCES SOURCES \endlink variable. The extension of each source file will have been replaced by .o (Unix) or .obj (Win32). The value of this variable is - typically handled by \l {qmake}{ \c qmake} or \l{#QMAKESPEC}{qmake.conf} and - rarely needs to be modified. + typically handled by \l {qmake Manual#qmake}{\c qmake} or + \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. \target OBJECTS_DIR \section1 OBJECTS_DIR @@ -1839,16 +1883,16 @@ For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 41 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 41 \target OBJMOC \section1 OBJMOC - This variable is set by \l {qmake}{ \c qmake} if files can be found that - contain the Q_OBJECT macro. \c OBJMOC contains the - name of all intermediate moc object files. The value of this variable - is typically handled by \l {qmake}{ \c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be - modified. + This variable is set by \l{qmake Manual#qmake}{\c qmake} if files can be + found that contain the Q_OBJECT macro. \c OBJMOC contains the name of all + intermediate moc object files. The value of this variable is typically + handled by \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} + and rarely needs to be modified. \target POST_TARGETDEPS \section1 POST_TARGETDEPS @@ -1887,8 +1931,8 @@ This variable contains a list of header files that require some sort of pre-compilation step (such as with moc). The value of this - variable is typically handled by \l {qmake}{ \c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be - modified. + variable is typically handled by \l{qmake Manual#qmake}{\c qmake} or + \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. \target PWD \section1 PWD @@ -1909,54 +1953,58 @@ \section1 OUT_PWD This variable contains the full path leading to the directory where - \l {qmake}{ \c qmake} places the generated Makefile. + \l{qmake Manual#qmake}{\c qmake} places the generated Makefile. \target QMAKE_systemvariable \section1 QMAKE - This variable contains the name of the \l {qmake}{ \c qmake} program - itself and is placed in generated Makefiles. The value of this - variable is typically handled by \l {qmake}{ \c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be - modified. + This variable contains the name of the \l{qmake Manual#qmake}{\c qmake} + program itself and is placed in generated Makefiles. The value of this + variable is typically handled by \l{qmake Manual#qmake}{\c qmake} or + \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. \target QMAKESPEC_systemvariable \section1 QMAKESPEC - This variable contains the name of the \l {qmake}{ \c qmake} - configuration to use when generating Makefiles. The value of this - variable is typically handled by \l {qmake}{ \c qmake} and rarely needs to be modified. + This variable contains the name of the \l{qmake Manual#qmake}{\c qmake} + configuration to use when generating Makefiles. The value of this variable + is typically handled by \l{qmake Manual#qmake}{\c qmake} and rarely needs + to be modified. - Use the \c{QMAKESPEC} environment variable to override the \l {qmake}{ \c qmake} configuration. - Note that, due to the way \l {qmake}{ \c qmake} reads project files, setting the \c{QMAKESPEC} - environment variable from within a project file will have no effect. + Use the \c{QMAKESPEC} environment variable to override the + \l{qmake Manual#qmake}{\c qmake} configuration. Note that, due to the way + \l{qmake Manual#qmake}{\c qmake} reads project files, setting the + \c{QMAKESPEC} environment variable from within a project file will have no + effect. \target QMAKE_APP_FLAG \section1 QMAKE_APP_FLAG This variable is empty unless the \c app \l{#TEMPLATE}{TEMPLATE} is specified. The value of this - variable is typically handled by \l {qmake}{ \c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be - modified. Use the following instead: + variable is typically handled by \l{qmake Manual#qmake}{\c qmake} or + \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. Use the + following instead: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 42 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 42 \target QMAKE_APP_OR_DLL \section1 QMAKE_APP_OR_DLL - This variable is empty unless the \c app or \c dll - \l{#TEMPLATE}{TEMPLATE} is specified. The value of this - variable is typically handled by \l {qmake}{ \c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be - modified. + This variable is empty unless the \c app or \c dll \l{#TEMPLATE}{TEMPLATE} + is specified. The value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \target QMAKE_AR_CMD \section1 QMAKE_AR_CMD \e {This is used on Unix platforms only.} - This variable contains the command for invoking the program which - creates, modifies and extracts archives. The value of this variable is - typically handled by \l {qmake}{ \c qmake} or \l{#QMAKESPEC}{qmake.conf} - and rarely needs to be modified. + This variable contains the command for invoking the program which creates, + modifies and extracts archives. The value of this variable is typically + handled by \l{qmake Manual#qmake}{\c qmake} or + \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. \target QMAKE_BUNDLE_DATA \section1 QMAKE_BUNDLE_DATA @@ -1968,7 +2016,7 @@ and \c path/to/header_two.h to a group containing information about the headers supplied with the framework: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 43 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 43 The last line adds the information about the headers to the collection of resources that will be installed with the library bundle. @@ -1990,7 +2038,7 @@ For example, the following definition will result in a framework with the \c{.myframework} extension: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 44 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 44 \e{This is used on Mac OS X only.} @@ -2004,9 +2052,10 @@ \target QMAKE_CFLAGS_DEBUG \section1 QMAKE_CFLAGS_DEBUG - This variable contains the flags for the C compiler in debug mode.The value of this variable is - typically handled by \l {qmake}{ \c qmake} or \l{#QMAKESPEC}{qmake.conf} - and rarely needs to be modified. + This variable contains the flags for the C compiler in debug mode. The + value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \target QMAKE_CFLAGS_MT \section1 QMAKE_CFLAGS_MT @@ -2014,7 +2063,7 @@ This variable contains the compiler flags for creating a multi-threaded application or when the version of Qt that you link against is a multi-threaded statically linked library. The value of - this variable is typically handled by \l {qmake}{ \c qmake} or + this variable is typically handled by \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. \target QMAKE_CFLAGS_MT_DBG @@ -2023,8 +2072,9 @@ This variable contains the compiler flags for creating a debuggable multi-threaded application or when the version of Qt that you link against is a debuggable multi-threaded statically linked library. The - value of this variable is typically handled by \l {qmake}{ \c qmake} or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \target QMAKE_CFLAGS_MT_DLL \section1 QMAKE_CFLAGS_MT_DLL @@ -2034,8 +2084,8 @@ This variable contains the compiler flags for creating a multi-threaded dll or when the version of Qt that you link against is a multi-threaded dll. The value of this variable is typically - handled by \l {qmake}{ \c qmake} or \l{#QMAKESPEC}{qmake.conf} and - rarely needs to be modified. + handled by \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} + and rarely needs to be modified. \target QMAKE_CFLAGS_MT_DLLDBG \section1 QMAKE_CFLAGS_MT_DLLDBG @@ -2045,16 +2095,17 @@ This variable contains the compiler flags for creating a debuggable multi-threaded dll or when the version of Qt that you link against is a debuggable multi-threaded statically linked library. - The value of this variable is typically handled by \l {qmake}{ \c qmake} or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + The value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \target QMAKE_CFLAGS_RELEASE \section1 QMAKE_CFLAGS_RELEASE This variable contains the compiler flags for creating a non-debuggable application. The value of this variable is typically - handled by \l {qmake}{ \c qmake} or \l{#QMAKESPEC}{qmake.conf} and - rarely needs to be modified. + handled by \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} + and rarely needs to be modified. \target QMAKE_CFLAGS_SHLIB \section1 QMAKE_CFLAGS_SHLIB @@ -2063,33 +2114,32 @@ This variable contains the compiler flags for creating a shared library. The value of this variable is typically handled by - \l {qmake}{ \c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely needs - to be modified. + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \target QMAKE_CFLAGS_THREAD \section1 QMAKE_CFLAGS_THREAD This variable contains the compiler flags for creating a multi-threaded application. The value of this variable is typically handled by - \l {qmake}{ \c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely needs - to be modified. + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \target QMAKE_CFLAGS_WARN_OFF \section1 QMAKE_CFLAGS_WARN_OFF This variable is not empty if the warn_off \l{#CONFIG}{CONFIG} option is specified. The value of this - variable is typically handled by \l {qmake}{ \c qmake} or \l{#QMAKESPEC}{qmake.conf} - and rarely needs to be modified. + variable is typically handled by \l{qmake Manual#qmake}{\c qmake} or + \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. \target QMAKE_CFLAGS_WARN_ON \section1 QMAKE_CFLAGS_WARN_ON - This variable is not empty if the warn_on - \l{#CONFIG}{CONFIG} option is specified. - The value of this variable is typically handled by - \l {qmake}{ \c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely needs - to be modified. + This variable is not empty if the warn_on \l{#CONFIG}{CONFIG} option is + specified. The value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \target QMAKE_CLEAN \section1 QMAKE_CLEAN @@ -2107,17 +2157,17 @@ \section1 QMAKE_CXXFLAGS This variable contains the C++ compiler flags that are used when building - a project. The value of this variable is typically handled by \l {qmake}{ \c qmake} or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. The flags - specific to debug and release modes can be adjusted by modifying - the \c QMAKE_CXXFLAGS_DEBUG and \c QMAKE_CXXFLAGS_RELEASE variables, - respectively. + a project. The value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. The flags specific to debug and release modes can be + adjusted by modifying the \c QMAKE_CXXFLAGS_DEBUG and + \c QMAKE_CXXFLAGS_RELEASE variables, respectively. \bold{Note:} On the Symbian platform, this variable can be used to pass architecture specific options to each compiler in the Symbian build system. For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 131 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 131 For more information, see \l{qmake Platform Notes#Compiler specific options}{qmake Platform Notes}. @@ -2127,24 +2177,24 @@ This variable contains the C++ compiler flags for creating a debuggable application. The value of this variable is typically handled by - \l {qmake}{ \c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely needs - to be modified. + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \target QMAKE_CXXFLAGS_MT \section1 QMAKE_CXXFLAGS_MT This variable contains the C++ compiler flags for creating a multi-threaded application. The value of this variable is typically handled by - \l {qmake}{ \c qmake}or \l{#QMAKESPEC}{qmake.conf} and rarely needs - to be modified. + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \target QMAKE_CXXFLAGS_MT_DBG \section1 QMAKE_CXXFLAGS_MT_DBG - This variable contains the C++ compiler flags for creating a debuggable multi-threaded - application. The value of this variable is typically handled by - \l {qmake}{ \c qmake}or \l{#QMAKESPEC}{qmake.conf} and rarely needs - to be modified. + This variable contains the C++ compiler flags for creating a debuggable + multi-threaded application. The value of this variable is typically handled + by \l{qmake Manual#qmake}{\c qmake}or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \target QMAKE_CXXFLAGS_MT_DLL \section1 QMAKE_CXXFLAGS_MT_DLL @@ -2153,56 +2203,58 @@ This variable contains the C++ compiler flags for creating a multi-threaded dll. The value of this variable is typically handled by - \l {qmake}{ \c qmake}or \l{#QMAKESPEC}{qmake.conf} and rarely needs - to be modified. + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \target QMAKE_CXXFLAGS_MT_DLLDBG \section1 QMAKE_CXXFLAGS_MT_DLLDBG \c {This is used on Windows only.} - This variable contains the C++ compiler flags for creating a multi-threaded debuggable - dll. The value of this variable is typically handled by - \l {qmake}{ \c qmake}or \l{#QMAKESPEC}{qmake.conf} and rarely needs - to be modified. + This variable contains the C++ compiler flags for creating a multi-threaded + debuggable dll. The value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \target QMAKE_CXXFLAGS_RELEASE \section1 QMAKE_CXXFLAGS_RELEASE - This variable contains the C++ compiler flags for creating an - application. The value of this variable is typically handled by - \l {qmake}{ \c qmake}or \l{#QMAKESPEC}{qmake.conf} and rarely needs - to be modified. + This variable contains the C++ compiler flags for creating an application. + The value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \target QMAKE_CXXFLAGS_SHLIB \section1 QMAKE_CXXFLAGS_SHLIB - This variable contains the C++ compiler flags for creating a - shared library. The value of this variable is typically handled by - \l {qmake}{ \c qmake}or \l{#QMAKESPEC}{qmake.conf} and rarely needs - to be modified. + This variable contains the C++ compiler flags for creating a shared library. + The value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \target QMAKE_CXXFLAGS_THREAD \section1 QMAKE_CXXFLAGS_THREAD - This variable contains the C++ compiler flags for creating a - multi-threaded application. The value of this variable is typically handled by - \l {qmake}{ \c qmake}or \l{#QMAKESPEC}{qmake.conf} and rarely needs - to be modified. + This variable contains the C++ compiler flags for creating a multi-threaded + application. The value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake}or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \target QMAKE_CXXFLAGS_WARN_OFF \section1 QMAKE_CXXFLAGS_WARN_OFF - This variable contains the C++ compiler flags for suppressing compiler warnings. - The value of this variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains the C++ compiler flags for suppressing compiler + warnings. The value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \target QMAKE_CXXFLAGS_WARN_ON \section1 QMAKE_CXXFLAGS_WARN_ON This variable contains C++ compiler flags for generating compiler warnings. - The value of this variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + The value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \target QMAKE_DISTCLEAN \section1 QMAKE_DISTCLEAN @@ -2212,9 +2264,9 @@ \target QMAKE_EXTENSION_SHLIB \section1 QMAKE_EXTENSION_SHLIB - This variable contains the extention for shared libraries. The value of this - variable is typically handled by \l {qmake}{ \c qmake}or \l{#QMAKESPEC}{qmake.conf} - and rarely needs to be modified. + This variable contains the extention for shared libraries. The value of + this variable is typically handled by \l{qmake Manual#qmake}{\c qmake} or + \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. Note that platform-specific variables that change the extension will override the contents of this variable. @@ -2286,16 +2338,18 @@ \target QMAKE_FAILED_REQUIREMENTS \section1 QMAKE_FAILED_REQUIREMENTS - This variable contains the list of requirements that were failed to be met when - \l {qmake}{ \c qmake}was used. For example, the sql module is needed and wasn't compiled into Qt. The - value of this variable is typically handled by \l {qmake}{ \c qmake}or \l{#QMAKESPEC}{qmake.conf} - and rarely needs to be modified. + This variable contains the list of requirements that were failed to be met + when \l{qmake Manual#qmake}{\c qmake} was used. For example, the sql module + is needed and wasn't compiled into Qt. The value of this variable is + typically handled by \l{qmake Manual#qmake}{\c qmake} or + \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. \target QMAKE_FILETAGS \section1 QMAKE_FILETAGS - This variable contains the file tags needed to be entered into the Makefile, such as SOURCES - and HEADERS. The value of this variable is typically handled by \l {qmake}{ \c qmake}or + This variable contains the file tags needed to be entered into the + Makefile, such as SOURCES and HEADERS. The value of this variable is + typically handled by \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. \section1 QMAKE_FRAMEWORK_BUNDLE_NAME @@ -2329,26 +2383,28 @@ \target QMAKE_INCDIR \section1 QMAKE_INCDIR - This variable contains the location of all known header files to be added to - INCLUDEPATH when building an application. The value of this variable is - typically handled by \l {qmake}{ \c qmake}or \l{#QMAKESPEC}{qmake.conf} and rarely - needs to be modified. + This variable contains the location of all known header files to be added + to INCLUDEPATH when building an application. The value of this variable is + typically handled by \l{qmake Manual#qmake}{\c qmake} or + \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. \target QMAKE_INCDIR_EGL \section1 QMAKE_INCDIR_EGL - This variable contains the location of EGL header files to be added - to INCLUDEPATH when building an application with OpenGL/ES or - OpenVG support. The value of this variable is typically handled by - \l {qmake}{ \c qmake}or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains the location of EGL header files to be added to + INCLUDEPATH when building an application with OpenGL/ES or OpenVG support. + The value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \target QMAKE_INCDIR_OPENGL \section1 QMAKE_INCDIR_OPENGL This variable contains the location of OpenGL header files to be added to INCLUDEPATH when building an application with OpenGL support. The - value of this variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. If the OpenGL implementation uses EGL (most OpenGL/ES systems), then QMAKE_INCDIR_EGL may also need to be set. @@ -2359,8 +2415,9 @@ to INCLUDEPATH when building an application with OpenGL ES 1 or OpenGL ES 2 support respectively. - The value of this variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + The value of this variable is typically handled by \ + l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. If the OpenGL implementation uses EGL (most OpenGL/ES systems), then QMAKE_INCDIR_EGL may also need to be set. @@ -2370,8 +2427,9 @@ This variable contains the location of OpenVG header files to be added to INCLUDEPATH when building an application with OpenVG support. The - value of this variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. If the OpenVG implementation uses EGL then QMAKE_INCDIR_EGL may also need to be set. @@ -2379,28 +2437,28 @@ \target QMAKE_INCDIR_QT \section1 QMAKE_INCDIR_QT - This variable contains the location of all known header file - paths to be added to INCLUDEPATH when building a Qt application. The value - of this variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains the location of all known header file paths to be + added to INCLUDEPATH when building a Qt application. The value of this + variable is typically handled by \l{qmake Manual#qmake}{\c qmake} or + \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. \target QMAKE_INCDIR_THREAD \section1 QMAKE_INCDIR_THREAD - This variable contains the location of all known header file - paths to be added to INCLUDEPATH when building a multi-threaded application. - The value of this variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains the location of all known header file paths to be + added to INCLUDEPATH when building a multi-threaded application. The value + of this variable is typically handled by \l{qmake Manual#qmake}{\c qmake} + or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. \target QMAKE_INCDIR_X11 \section1 QMAKE_INCDIR_X11 \e {This is used on Unix platforms only.} - This variable contains the location of X11 header file paths to be - added to INCLUDEPATH when building a X11 application. The - value of this variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains the location of X11 header file paths to be added + to INCLUDEPATH when building a X11 application. The value of this variable + is typically handled by \l{qmake Manual#qmake}{\c qmake} or + \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. \target QMAKE_INFO_PLIST \section1 QMAKE_INFO_PLIST @@ -2428,31 +2486,30 @@ \e {This is used on Windows only.} - This variable contains link flags when building console - programs. The value of this variable is typically handled by - \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains link flags when building console programs. The value + of this variable is typically handled by \l{qmake Manual#qmake}{\c qmake} + or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. \section1 QMAKE_LFLAGS_CONSOLE_DLL \e {This is used on Windows only.} - This variable contains link flags when building console - dlls. The value of this variable is typically handled by - \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains link flags when building console dlls. The value of + this variable is typically handled by \l{qmake Manual#qmake}{\c qmake} or + \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. \section1 QMAKE_LFLAGS_DEBUG - This variable contains link flags when building debuggable applications. The - value of this variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains link flags when building debuggable applications. + The value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \section1 QMAKE_LFLAGS_PLUGIN - This variable contains link flags when building plugins. The value - of this variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains link flags when building plugins. The value of this + variable is typically handled by \l{qmake Manual#qmake}{\c qmake} or + \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. \section1 QMAKE_LFLAGS_RPATH @@ -2463,122 +2520,125 @@ \section1 QMAKE_LFLAGS_QT_DLL - This variable contains link flags when building programs that - use the Qt library built as a dll. The value of this variable is - typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains link flags when building programs that use the Qt + library built as a dll. The value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \section1 QMAKE_LFLAGS_RELEASE - This variable contains link flags when building applications for - release. The value of this variable is typically handled by - \l {qmake}{ \c qmake}or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains link flags when building applications for release. + The value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \section1 QMAKE_LFLAGS_SHAPP - This variable contains link flags when building applications which are using - the \c app template. The value of this variable is typically handled by - \l {qmake}{ \c qmake}or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains link flags when building applications which are + using the \c app template. The value of this variable is typically + handled by \l{qmake Manual#qmake}{\c qmake} or + \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. \section1 QMAKE_LFLAGS_SHLIB This variable contains link flags when building shared libraries - The value of this variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + The value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \section1 QMAKE_LFLAGS_SONAME This variable specifies the link flags to set the name of shared objects, - such as .so or .dll. The value of this variable is typically handled by \c - qmake or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + such as .so or .dll. The value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \section1 QMAKE_LFLAGS_THREAD This variable contains link flags when building multi-threaded projects. - The value of this variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + The value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \section1 QMAKE_LFLAGS_WINDOWS \e {This is used on Windows only.} - This variable contains link flags when building Windows GUI projects - (i.e. non-console applications). - The value of this variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains link flags when building Windows GUI projects (i.e. + non-console applications). The value of this variable is typically handled + by \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \section1 QMAKE_LFLAGS_WINDOWS_DLL \e {This is used on Windows only.} - This variable contains link flags when building Windows DLL projects. - The value of this variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains link flags when building Windows DLL projects. The + value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \section1 QMAKE_LIBDIR - This variable contains the location of all known library - directories.The value of this variable is typically handled by - \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains the location of all known library directories. The + value of this variable is typically handled by \l{qmake Manual#qmake}{\c qmake} + or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. \section1 QMAKE_LIBDIR_FLAGS \e {This is used on Unix platforms only.} - This variable contains the location of all library - directory with -L prefixed. The value of this variable is typically handled by - \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains the location of all library directory with -L + prefixed. The value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \section1 QMAKE_LIBDIR_EGL - This variable contains the location of the EGL library - directory, when EGL is used with OpenGL/ES or OpenVG. The value - of this variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains the location of the EGL library directory, when EGL + is used with OpenGL/ES or OpenVG. The value of this variable is typically + handled by \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} + and rarely needs to be modified. \section1 QMAKE_LIBDIR_OPENGL - This variable contains the location of the OpenGL library - directory.The value of this variable is typically handled by - \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains the location of the OpenGL library directory. The + value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. If the OpenGL implementation uses EGL (most OpenGL/ES systems), then QMAKE_LIBDIR_EGL may also need to be set. \section1 QMAKE_LIBDIR_OPENVG - This variable contains the location of the OpenVG library - directory. The value of this variable is typically handled by - \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains the location of the OpenVG library directory. The + value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. If the OpenVG implementation uses EGL, then QMAKE_LIBDIR_EGL may also need to be set. \section1 QMAKE_LIBDIR_QT - This variable contains the location of the Qt library - directory.The value of this variable is typically handled by - \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains the location of the Qt library directory. The value + of this variable is typically handled by \l{qmake Manual#qmake}{\c qmake} + or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. \section1 QMAKE_LIBDIR_X11 \e {This is used on Unix platforms only.} - This variable contains the location of the X11 library - directory.The value of this variable is typically handled by - \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains the location of the X11 library directory. The value + of this variable is typically handled by \l{qmake Manual#qmake}{\c qmake} + or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. \section1 QMAKE_LIBS - This variable contains all project libraries. The value of this - variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains all project libraries. The value of this variable + is typically handled by \l{qmake Manual#qmake}{\c qmake} or + \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. \section1 QMAKE_LIBS_CONSOLE @@ -2591,42 +2651,44 @@ \section1 QMAKE_LIBS_EGL - This variable contains all EGL libraries when building Qt with - OpenGL/ES or OpenVG. The value of this variable is typically - handled by \l {qmake}{ \c qmake}or \l{#QMAKESPEC}{qmake.conf} and rarely + This variable contains all EGL libraries when building Qt with OpenGL/ES + or OpenVG. The value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. The usual value is \c{-lEGL}. \section1 QMAKE_LIBS_OPENGL - This variable contains all OpenGL libraries. The value of this - variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains all OpenGL libraries. The value of this variable + is typically handled by \l{qmake Manual#qmake}{\c qmake} or + \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. If the OpenGL implementation uses EGL (most OpenGL/ES systems), then QMAKE_LIBS_EGL may also need to be set. \section1 QMAKE_LIBS_OPENGL_QT - This variable contains all OpenGL Qt libraries.The value of this - variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains all OpenGL Qt libraries.The value of this variable + is typically handled by \l{qmake Manual#qmake}{\c qmake} or + \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. \section1 QMAKE_LIBS_OPENGL_ES1, QMAKE_LIBS_OPENGL_ES2 These variables contain all the OpenGL libraries for OpenGL ES 1 and OpenGL ES 2. - The value of these variables is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + The value of these variables is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. If the OpenGL implementation uses EGL (most OpenGL/ES systems), then QMAKE_LIBS_EGL may also need to be set. \section1 QMAKE_LIBS_OPENVG - This variable contains all OpenVG libraries. The value of this - variable is typically handled by \l {qmake}{ \c qmake}or \l{#QMAKESPEC}{qmake.conf} - and rarely needs to be modified. The usual value is \c{-lOpenVG}. + This variable contains all OpenVG libraries. The value of this variable + is typically handled by \l{qmake Manual#qmake}{\c qmake} or + \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. The usual + value is \c{-lOpenVG}. Some OpenVG engines are implemented on top of OpenGL. This will be detected at configure time and QMAKE_LIBS_OPENGL will be implicitly @@ -2637,95 +2699,96 @@ \section1 QMAKE_LIBS_QT - This variable contains all Qt libraries.The value of this - variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains all Qt libraries.The value of this variable is + typically handled by \l{qmake Manual#qmake}{\c qmake} or + \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. \section1 QMAKE_LIBS_QT_DLL \e {This is used on Windows only.} - This variable contains all Qt libraries when Qt is built as a dll. The - value of this variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains all Qt libraries when Qt is built as a dll. The + value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \section1 QMAKE_LIBS_QT_OPENGL - This variable contains all the libraries needed to link against if - OpenGL support is turned on. The - value of this variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains all the libraries needed to link against if OpenGL + support is turned on. The value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \section1 QMAKE_LIBS_QT_THREAD - This variable contains all the libraries needed to link against if - thread support is turned on. The - value of this variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains all the libraries needed to link against if thread + support is turned on. The value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \section1 QMAKE_LIBS_RT \e {This is used with Borland compilers only.} This variable contains the runtime library needed to link against when - building an application. The - value of this variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + building an application. The value of this variable is typically handled + by \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and + rarely needs to be modified. \section1 QMAKE_LIBS_RTMT \e {This is used with Borland compilers only.} This variable contains the runtime library needed to link against when - building a multi-threaded application. The - value of this variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + building a multi-threaded application. The value of this variable is + typically handled by \l{qmake Manual#qmake}{\c qmake} or + \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. \section1 QMAKE_LIBS_THREAD \e {This is used on Unix and Symbian platforms only.} - This variable contains all libraries that need to be linked against - when building a multi-threaded application. The - value of this variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains all libraries that need to be linked against when + building a multi-threaded application. The value of this variable is + typically handled by \l{qmake Manual#qmake}{\c qmake} or + \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. \section1 QMAKE_LIBS_WINDOWS \e {This is used on Windows only.} - This variable contains all windows libraries.The value of this - variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains all windows libraries. The value of this variable + is typically handled by \l{qmake Manual#qmake}{\c qmake} or + \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. \section1 QMAKE_LIBS_X11 \e {This is used on Unix platforms only.} - This variable contains all X11 libraries.The value of this - variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains all X11 libraries.The value of this variable is + typically handled by \l{qmake Manual#qmake}{\c qmake} or + \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. \section1 QMAKE_LIBS_X11SM \e {This is used on Unix platforms only.} - This variable contains all X11 session management libraries. The - value of this variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains all X11 session management libraries. The value of + this variable is typically handled by \l{qmake Manual#qmake}{\c qmake} or + \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. \section1 QMAKE_LIB_FLAG - This variable is not empty if the \c lib template is specified. The - value of this variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable is not empty if the \c lib template is specified. The value + of this variable is typically handled by \l{qmake Manual#qmake}{\c qmake} + or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. \section1 QMAKE_LINK_SHLIB_CMD - This variable contains the command to execute when creating a - shared library. The - value of this variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains the command to execute when creating a shared + library. The value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \section1 QMAKE_LN_SHLIB @@ -2754,8 +2817,8 @@ This variable determines the name of the project when generating project files for IDEs. The default value is the target name. The value of this - variable is typically handled by \l {qmake}{ \c qmake} and rarely needs - to be modified. + variable is typically handled by \l {qmake Manual#qmake}{ \c qmake} and + rarely needs to be modified. \section1 QMAKE_MAC_SDK @@ -2774,28 +2837,29 @@ \section1 QMAKE_MAKEFILE - This variable contains the name of the Makefile to create. The - value of this variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains the name of the Makefile to create. The value of + this variable is typically handled by \l{qmake Manual#qmake}{\c qmake} or + \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. \section1 QMAKE_MOC_SRC - This variable contains the names of all moc source files to - generate and include in the project. The value of this variable is - typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains the names of all moc source files to generate and + include in the project. The value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \section1 QMAKE_QMAKE - This variable contains the location of qmake if it is not in the path. - The value of this variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains the location of qmake if it is not in the path. The + value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \section1 QMAKE_QT_DLL - This variable is not empty if Qt was built as a dll. The - value of this variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable is not empty if Qt was built as a dll. The value of this + variable is typically handled by \l{qmake Manual#qmake}{\c qmake} or + \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. \section1 QMAKE_RESOURCE_FLAGS @@ -2805,7 +2869,7 @@ \c{-compress} options are used with particular values each time that \c rcc is invoked: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 45 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 45 \section1 QMAKE_RPATH @@ -2823,44 +2887,49 @@ \section1 QMAKE_RUN_CC - This variable specifies the individual rule needed to build an object. - The value of this variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable specifies the individual rule needed to build an object. The + value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \section1 QMAKE_RUN_CC_IMP - This variable specifies the individual rule needed to build an object. - The value of this variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable specifies the individual rule needed to build an object. The + value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \section1 QMAKE_RUN_CXX - This variable specifies the individual rule needed to build an object. - The value of this variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable specifies the individual rule needed to build an object. The + value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \section1 QMAKE_RUN_CXX_IMP - This variable specifies the individual rule needed to build an object. - The value of this variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable specifies the individual rule needed to build an object. The + value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \section1 QMAKE_TARGET - This variable contains the name of the project target. The value of - this variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains the name of the project target. The value of this + variable is typically handled by \l{qmake Manual#qmake}{\c qmake} or + \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. \section1 QMAKE_UIC - This variable contains the location of uic if it is not in the path. - The value of this variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains the location of uic if it is not in the path. The + value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. It can be used to specify arguments to uic as well, such as additional plugin paths. For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 46 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 46 \section1 QT @@ -2891,7 +2960,7 @@ exclude the \c gui value with the "-=" operator; the following line will result in a minimal Qt project being built: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 47 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 47 Note that adding the \c opengl option to the \c QT variable automatically causes the equivalent option to be added to the \c CONFIG variable. @@ -2927,8 +2996,9 @@ \section1 RC_FILE This variable contains the name of the resource file for the application. - The value of this variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + The value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \target RCC_DIR \section1 RCC_DIR @@ -2938,13 +3008,13 @@ For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 48 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 48 \target REQUIRES \section1 REQUIRES - This is a special variable processed by \c qmake. If the - contents of this variable do not appear in CONFIG by the time this + This is a special variable processed by \l{qmake Manual#qmake}{\c qmake}. + If the contents of this variable do not appear in CONFIG by the time this variable is assigned, then a minimal Makefile will be generated that states what dependencies (the values assigned to REQUIRES) are missing. @@ -2953,27 +3023,28 @@ \section1 RESOURCES - This variable contains the name of the resource collection file (qrc) + This variable contains the name of the resource collection file (qrc) for the application. Further information about the resource collection file can be found at \l{The Qt Resource System}. \section1 RES_FILE This variable contains the name of the resource file for the application. - The value of this variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + The value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \target RSS_RULES \section1 RSS_RULES - \e {This is only used on the Symbian platform.} + \e {This is only used on the Symbian platform.} - Generic RSS file content can be specified with this variable. The syntax is + Generic RSS file content can be specified with this variable. The syntax is similar to \c MMP_RULES and \c BLD_INF_RULES. For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 144 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 144 This will add the specified statement to the end of the \c APP_REGISTRATION_INFO resource struct in the generated registration resource file. @@ -2982,9 +3053,9 @@ It is also possible to add multiple rows in a single block. Each double quoted string will be placed on a new row in the registration resource file. - For example: + For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 145 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 145 This example will install the application to MyFolder in the Symbian platform application shell. In addition it will make the application to @@ -3016,7 +3087,7 @@ For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 151 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 151 This example will define service information for a fictional service that requires an icon to be supplied via the \c opaque_data of the service information. @@ -3045,17 +3116,17 @@ For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 49 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 49 See also \l{#HEADERS}{HEADERS} \section1 SRCMOC - This variable is set by \l {qmake}{ \c qmake}if files can be found that - contain the Q_OBJECT macro. \c SRCMOC contains the - name of all the generated moc files. The value of this variable - is typically handled by \l {qmake}{ \c qmake}or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be - modified. + This variable is set by \l{qmake Manual#qmake}{\c qmake} if files can be + found that contain the Q_OBJECT macro. \c SRCMOC contains the name of all + the generated moc files. The value of this variable is typically handled + by \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and + rarely needs to be modified. \target SUBDIRS \section1 SUBDIRS @@ -3067,18 +3138,18 @@ For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 50 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 50 It is essential that the project file in each subdirectory has the same - name as the subdirectory itself, so that \l {qmake}{ \c qmake}can find it. - For example, if the subdirectory is called \c myapp then the project file - in that directory should be called \c myapp.pro. + name as the subdirectory itself, so that \l{qmake Manual#qmake}{\c qmake} + can find it. For example, if the subdirectory is called \c myapp then the + project file in that directory should be called \c myapp.pro. If you need to ensure that the subdirectories are built in the order in which they are specified, update the \l{#CONFIG}{CONFIG} variable to include the \c ordered option: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 51 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 51 It is possible to modify this default behavior of \c SUBDIRS by giving additional modifiers to \c SUBDIRS elements. Supported modifiers are: @@ -3102,11 +3173,11 @@ For example, define two subdirectories, both of which reside in a different directory than the \c SUBDIRS value, and one of the subdirectories must be built before the other: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 149 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 149 For example, define a subdirectory that is only build for emulator builds in Qt for Symbian: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 150 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 150 \target SYMBIAN_VERSION \section1 SYMBIAN_VERSION @@ -3122,7 +3193,7 @@ For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 52 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 52 The project file above would produce an executable named \c myapp on unix and 'myapp.exe' on windows. @@ -3132,8 +3203,34 @@ \e {This is only used on the Symbian platform.} - Specifies which platform capabilities the application should have. For more - information, please refer to the Symbian SDK documentation. + Specifies which platform capabilities the application should have. These + include the following basic capabilities, but others are also available + for signed applications. + + \table + \header \o Capability \o Description + \row \o LocalServices \o The ability to use local services running on the + phone or device, including those which provide + local connectivity to other devices. + \row \o Location \o Access to the service that provides information + about the user's location, from GPS, phone + network, or other sources. + \row \o NetworkServices \o Use of services that access the phone network, + such as dialling a phone number, sending an SMS, + or other operations that result in network + traffic. + \row \o ReadUserData \o Access to the user's private data, such as + contact information. + \row \o UserEnvironment \o The ability to use services that provide from the + user's physical environment, such as the camera or + microphone. + \row \o WriteUserData \o The ability to write or modify the user's private + data. + \endtable + + For more information, and a comprehensive list of capabilities, please refer + to the Symbian SDK documentation or the \l{Symbian Capabilities} page of + the \l{Forum Nokia Wiki}. \target TARGET.EPOCALLOWDLLDATA \section1 TARGET.EPOCALLOWDLLDATA @@ -3152,7 +3249,7 @@ will refuse to run if the minimum size is not available when it starts. For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 135 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 135 \target TARGET.EPOCSTACKSIZE \section1 TARGET.EPOCSTACKSIZE @@ -3161,7 +3258,7 @@ Specifies the maximum stack size of the application. For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 136 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 136 \target TARGET.SID \section1 TARGET.SID @@ -3201,21 +3298,23 @@ \section1 TARGET_EXT - This variable specifies the target's extension. The value of this variable - is typically handled by \l {qmake}{ \c qmake}or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be - modified. + This variable specifies the target's extension. The value of this variable + is typically handled by \l {qmake Manual#qmake}{\c qmake} or + \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. \section1 TARGET_x - This variable specifies the target's extension with a major version number. The value of this variable - is typically handled by \l {qmake}{ \c qmake}or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be - modified. + This variable specifies the target's extension with a major version number. + The value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \section1 TARGET_x.y.z - This variable specifies the target's extension with version number. The value of this variable - is typically handled by \l {qmake}{ \c qmake}or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be - modified. + This variable specifies the target's extension with version number. The + value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \target TEMPLATE \section1 TEMPLATE @@ -3242,7 +3341,7 @@ For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 53 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 53 The template can be overridden by specifying a new template type with the \c -t command line option. This overrides the template type \e after the .pro @@ -3261,16 +3360,16 @@ \section1 UICIMPLS This variable contains a list of the generated implementation files by UIC. - The value of this variable - is typically handled by \l {qmake}{ \c qmake}or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be - modified. + The value of this variable is typically handled by + \l{qmake Manual#qmake}{\c qmake} or \l{#QMAKESPEC}{qmake.conf} and rarely + needs to be modified. \section1 UICOBJECTS - This variable is generated from the UICIMPLS variable. The extension of each - file will have been replaced by .o (Unix) or .obj (Win32). The value of this variable is - typically handled by \l {qmake}{ \c qmake}or \l{#QMAKESPEC}{qmake.conf} and - rarely needs to be modified. + This variable is generated from the UICIMPLS variable. The extension of + each file will have been replaced by .o (Unix) or .obj (Win32). The value + of this variable is typically handled by \l{qmake Manual#qmake}{\c qmake} + or \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. \target UI_DIR \section1 UI_DIR @@ -3281,7 +3380,7 @@ For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 54 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 54 \target UI_HEADERS_DIR \section1 UI_HEADERS_DIR @@ -3291,7 +3390,7 @@ For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 55 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 55 \target UI_SOURCES_DIR \section1 UI_SOURCES_DIR @@ -3301,7 +3400,7 @@ For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 56 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 56 \target VERSION \section1 VERSION @@ -3312,7 +3411,7 @@ For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 57 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 57 \section1 VER_MAJ @@ -3331,36 +3430,36 @@ \section1 VPATH - This variable tells \l {qmake}{ \c qmake}where to search for files it cannot - open. With this you may tell \l {qmake}{ \c qmake}where it may look for things - like SOURCES, and if it finds an entry in SOURCES that cannot be - opened it will look through the entire VPATH list to see if it can - find the file on its own. + This variable tells \l{qmake Manual#qmake}{\c qmake} where to search for + files it cannot open. With this you may tell + \l{qmake Manual#qmake}{\c qmake} where it may look for things like SOURCES, + and if it finds an entry in SOURCES that cannot be opened it will look + through the entire VPATH list to see if it can find the file on its own. See also \l{#DEPENDPATH}{DEPENDPATH}. \section1 YACCIMPLS - This variable contains a list of yacc source files. The value of - this variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains a list of yacc source files. The value of this + variable is typically handled by \l{qmake Manual#qmake}{\c qmake} or + \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. \section1 YACCOBJECTS - This variable contains a list of yacc object files. The value of - this variable is typically handled by \l {qmake}{ \c qmake}or - \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. + This variable contains a list of yacc object files. The value of this + variable is typically handled by \l{qmake Manual#qmake}{\c qmake} or + \l{#QMAKESPEC}{qmake.conf} and rarely needs to be modified. \target YACCSOURCES \section1 YACCSOURCES This variable contains a list of yacc source files to be included - in the project. All dependencies, headers and source files will + in the project. All dependencies, headers and source files will automatically be included in the project. For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 58 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 58 \section1 _PRO_FILE_ @@ -3389,8 +3488,8 @@ \previouspage qmake Variable Reference \nextpage Configuring qmake's Environment - \l {qmake}{ \c qmake}provides built-in functions to allow the contents of - variables to be processed, and to enable tests to be performed + \l{qmake Manual#qmake}{\c qmake} provides built-in functions to allow the + contents of variables to be processed, and to enable tests to be performed during the configuration process. Functions that process the contents of variables typically return values that can be assigned to other variables, and these values are obtained by prefixing @@ -3417,7 +3516,7 @@ Returns the basename of the file specified. For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 59 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 59 \section1 CONFIG(config) [Conditional] @@ -3430,7 +3529,7 @@ mutually exclusive values) a second parameter can be used to specify a set of values to consider. For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 60 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 60 Because release is considered the active setting (for feature parsing) it will be the CONFIG used to generate the build file. In the common @@ -3446,7 +3545,7 @@ For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 61 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 61 The contents of the scope are only processed if the \c drivers variable contains the value, \c network. If this is the case, the @@ -3473,19 +3572,19 @@ \section1 error(string) - This function never returns a value. \l {qmake}{ \c qmake}displays the given - \e string to the user, and exits. This function should only be used - for unrecoverable errors. + This function never returns a value. \l{qmake Manual#qmake}{\c qmake} + displays the given \e string to the user, and exits. This function + should only be used for unrecoverable errors. For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 62 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 62 \section1 eval(string) [Conditional] - Evaluates the contents of the string using \c qmake's syntax rules - and returns true. + Evaluates the contents of the string using + \l{qmake Manual#qmake}{\c qmake}'s syntax rules and returns true. Definitions and assignments can be used in the string to modify the values of existing variables or create new definitions. @@ -3504,7 +3603,7 @@ succeeds if any file matches the regular expression specified. For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 63 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 63 Note that "/" can be used as a directory separator, regardless of the platform in use. @@ -3514,7 +3613,7 @@ Places all the values in \e variablename that match \e substr. \e substr may be a regular expression, and will be matched accordingly. - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 64 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 64 MY_VAR2 will contain '-Lone -Ltwo -Lthree -Lfour -Lfive', and MY_VAR3 will contains 'three two three'. @@ -3531,7 +3630,7 @@ For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 65 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 65 \section1 include(filename) [Conditional] @@ -3544,15 +3643,16 @@ You can check whether the file was included by using this function as the condition for a scope; for example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 66 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 66 \section1 infile(filename, var, val) [Conditional] - Succeeds if the file \e filename (when parsed by \l {qmake}{ \c qmake}itself) - contains the variable \e var with a value of \e val; otherwise fails. - If you do not specify a third argument (\e val), the function will - only test whether \e var has been declared in the file. + Succeeds if the file \e filename (when parsed by + \l{qmake Manual#qmake}{\c qmake} itself) contains the variable \e var with + a value of \e val; otherwise fails. If you do not specify a third argument + (\e val), the function will only test whether \e var has been declared in + the file. \section1 isEmpty(variablename) [Conditional] @@ -3562,7 +3662,7 @@ For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 67 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 67 \section1 join(variablename, glue, before, after) @@ -3586,7 +3686,7 @@ This function simply writes a message to the console. Unlike the \c error() function, this function allows processing to continue. - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 68 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 68 The above line causes "This is a message" to be written to the console. The use of quotation marks is optional. @@ -3597,7 +3697,7 @@ \l{qmake Advanced Usage}{in conjunction with a scope} to filter out messages during builds; for example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 69 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 69 \section1 prompt(question) @@ -3618,7 +3718,7 @@ prints the message: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 70 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 70 \section1 sprintf(string, arguments...) @@ -3634,13 +3734,13 @@ For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 71 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 71 Alternatively, you can use this function to obtain stdout and stderr from the command, and assign it to a variable. For example, you can use this to interrogate information about the platform: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 72 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 72 \target unique \section1 unique(variablename) @@ -3648,7 +3748,7 @@ This will return a list of values in variable that are unique (that is with repetitive entries removed). For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 73 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 73 \section1 warning(string) @@ -3668,18 +3768,19 @@ \target Properties \section1 Properties - \l {qmake}{ \c qmake}has a system of persistent information, this allows you to - \c set a variable in qmake once, and each time qmake is invoked this - value can be queried. Use the following to set a property in qmake: + \l{qmake Manual#qmake}{\c qmake} has a system of persistent information, + this allows you to \c set a variable in qmake once, and each time qmake is + invoked this value can be queried. Use the following to set a property in + qmake: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 74 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 74 The appropriate variable and value should be substituted for \c VARIABLE and \c VALUE. To retrieve this information back from qmake you can do: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 75 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 75 \note \c{qmake -query} will only list variables that you have previously set with \c{qmake -set VARIABLE VALUE}. @@ -3687,24 +3788,26 @@ This information will be saved into a QSettings object (meaning it will be stored in different places for different platforms). As \c VARIABLE is versioned as well, you can set one value in an older - version of \c qmake, and newer versions will retrieve this value. However, - if you set \c VARIABLE for a newer version of \c qmake, the older version - will not use this value. You can however query a specific version of a - variable if you prefix that version of \l {qmake}{ \c qmake}to \c VARIABLE, as in - the following example: + version of \l{qmake Manual#qmake}{\c qmake}, and newer versions will + retrieve this value. However, if you set \c VARIABLE for a newer version + of \l{qmake Manual#qmake}{\c qmake}, the older version will not use this + value. You can however query a specific version of a variable if you + prefix that version of \l{qmake Manual#qmake}{\c qmake} to \c VARIABLE, + as in the following example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 76 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 76 - \l {qmake}{ \c qmake}also has the notion of \c builtin properties, for example you can - query the installation of Qt for this version of \l {qmake}{ \c qmake}with the + \l{qmake Manual#qmake}{\c qmake} also has the notion of \c builtin + properties, for example you can query the installation of Qt for this + version of \l{qmake Manual#qmake}{\c qmake} with the \c QT_INSTALL_PREFIX property: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 77 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 77 - These built-in properties cannot have a version prefixed to them as - they are not versioned, and each version of \l {qmake}{ \c qmake}will have its own - built-in set of these values. The list below outlines the built-in - properties: + These built-in properties cannot have a version prefixed to them as they + are not versioned, and each version of \l{qmake Manual#qmake}{\c qmake} + will have its own built-in set of these values. The list below outlines + the built-in properties: \list \o \c QT_INSTALL_PREFIX - Where the version of Qt this qmake is built for resides @@ -3715,27 +3818,27 @@ Finally, these values can be queried in a project file with a special notation such as: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 78 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 78 \target QMAKESPEC \section1 QMAKESPEC - \l {qmake}{ \c qmake}requires a platform and compiler description file which - contains many default values used to generate appropriate Makefiles. - The standard Qt distribution comes with many of these files, located - in the \c mkspecs subdirectory of the Qt installation. + \l{qmake Manual#qmake}{\c qmake}requires a platform and compiler + description file which contains many default values used to generate + appropriate Makefiles. The standard Qt distribution comes with many of + these files, located in the \c mkspecs subdirectory of the Qt installation. The \c QMAKESPEC environment variable can contain any of the following: \list \o A complete path to a directory containing a \c{qmake.conf} file. - In this case \l {qmake}{ \c qmake}will open the \c{qmake.conf} file from within that - directory. If the file does not exist, \l {qmake}{ \c qmake}will exit with an - error. - \o The name of a platform-compiler combination. In this case, \c qmake - will search in the directory specified by the \c mkspecs subdirectory - of the data path specified when Qt was compiled (see - QLibraryInfo::DataPath). + In this case \l{qmake Manual#qmake}{\c qmake} will open the + \c{qmake.conf} file from within that directory. If the file does not + exist, \l{qmake Manual#qmake}{\c qmake} will exit with an error. + \o The name of a platform-compiler combination. In this case, + \l{qmake Manual#qmake}{\c qmake} will search in the directory specified + by the \c mkspecs subdirectory of the data path specified when Qt was + compiled (see QLibraryInfo::DataPath). \endlist \bold{Note:} The \c QMAKESPEC path will automatically be added to the @@ -3746,31 +3849,32 @@ It is common on Unix to also use the build tool to install applications and libraries; for example, by invoking \c{make install}. For this reason, - \l {qmake}{ \c qmake}has the concept of an install set, an object which contains - instructions about the way part of a project is to be installed. - For example, a collection of documentation files can be described in the - following way: + \l{qmake Manual#qmake}{\c qmake}has the concept of an install set, an + object which contains instructions about the way part of a project is to + be installed. For example, a collection of documentation files can be + described in the following way: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 79 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 79 - The \c path member informs \l {qmake}{ \c qmake}that the files should be installed in - \c /usr/local/program/doc (the path member), and the \c files member - specifies the files that should be copied to the installation directory. - In this case, everything in the \c docs directory will be coped to - \c /usr/local/program/doc. + The \c path member informs \l{qmake Manual#qmake}{\c qmake} that the files + should be installed in \c /usr/local/program/doc (the path member), and the + \c files member specifies the files that should be copied to the + installation directory. In this case, everything in the \c docs directory + will be coped to \c /usr/local/program/doc. Once an install set has been fully described, you can append it to the install list with a line like this: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 80 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 80 - \l {qmake}{ \c qmake}will ensure that the specified files are copied to the installation - directory. If you require greater control over this process, you can also - provide a definition for the \c extra member of the object. For example, - the following line tells \l {qmake}{ \c qmake}to execute a series of commands for this + \l{qmake Manual#qmake}{\c qmake} will ensure that the specified files are + copied to the installation directory. If you require greater control over + this process, you can also provide a definition for the \c extra member of + the object. For example, the following line tells + \l{qmake Manual#qmake}{\c qmake} to execute a series of commands for this install set: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 81 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 81 The \c unix scope (see \l{qmake Advanced Usage#Scopes and Conditions}{Scopes and Conditions}) @@ -3782,23 +3886,24 @@ in the other members of the object are performed. If you append a built-in install set to the \c INSTALLS variable and do - not specify \c files or \c extra members, \l {qmake}{ \c qmake}will decide what needs to - be copied for you. Currently, the only supported built-in install set is - \c target: + not specify \c files or \c extra members, \l{qmake Manual#qmake}{\c qmake} + will decide what needs to be copied for you. Currently, the only supported + built-in install set is \c target: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 82 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 82 - In the above lines, \l {qmake}{ \c qmake}knows what needs to be copied, and will handle - the installation process automatically. + In the above lines, \l{qmake Manual#qmake}{\c qmake} knows what needs to + be copied, and will handle the installation process automatically. \target cache \section1 Cache File - The cache file is a special file \l {qmake}{ \c qmake}reads to find settings not specified - in the \c qmake.conf file, project files, or at the command line. If - \c -nocache is not specified when \l {qmake}{ \c qmake}is run, it will try to find a file - called \c{.qmake.cache} in parent directories of the current directory. If - it fails to find this file, it will silently ignore this step of processing. + The cache file is a special file \l{qmake Manual#qmake}{\c qmake} reads to + find settings not specified in the \c qmake.conf file, project files, or + at the command line. If \c -nocache is not specified when + \l{qmake Manual#qmake}{\c qmake} is run, it will try to find a file called + \c{.qmake.cache} in parent directories of the current directory. If it + fails to find this file, it will silently ignore this step of processing. If it finds a \c{.qmake.cache} file then it will process this file first before it processes the project file. @@ -3806,67 +3911,73 @@ \target LibDepend \section1 Library Dependencies - Often when linking against a library, \l {qmake}{ \c qmake}relies on the underlying - platform to know what other libraries this library links against, and - lets the platform pull them in. In many cases, however, this is not - sufficent. For example, when statically linking a library, no other - libraries are linked to, and therefore no dependencies to those - libraries are created. However, an application that later links + Often when linking against a library, \l{qmake Manual#qmake}{\c qmake} + relies on the underlying platform to know what other libraries this + library links against, and lets the platform pull them in. In many cases, + however, this is not sufficent. For example, when statically linking a + library, no other libraries are linked to, and therefore no dependencies + to those libraries are created. However, an application that later links against this library will need to know where to find the symbols that - the static library will require. To help with this situation, \c qmake - attempts to follow a library's dependencies where appropriate, but - this behavior must be explicitly enabled by following two steps. + the static library will require. To help with this situation, + \l{qmake Manual#qmake}{\c qmake} attempts to follow a library's + dependencies where appropriate, but this behavior must be explicitly + enabled by following two steps. The first step is to enable dependency tracking in the library itself. - To do this you must tell \l {qmake}{ \c qmake}to save information about the library: + To do this you must tell \l{qmake Manual#qmake}{\c qmake} to save + information about the library: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 83 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 83 - This is only relevant to the \c lib template, and will be ignored for - all others. When this option is enabled, \l {qmake}{ \c qmake}will create a file - ending in .prl which will save some meta-information about the - library. This metafile is just like an ordinary project file, but only + This is only relevant to the \c lib template, and will be ignored for all + others. When this option is enabled, \l{qmake Manual#qmake}{\c qmake} will + create a file ending in .prl which will save some meta-information about + the library. This metafile is just like an ordinary project file, but only contains internal variable declarations. You are free to view this file - and, if it is deleted, \l {qmake}{ \c qmake}will know to recreate it when necessary, - either when the project file is later read, or if a dependent library - (described below) has changed. When installing this library, by - specifying it as a target in an \c INSTALLS declaration, \l {qmake}{ \c qmake}will - automatically copy the .prl file to the installation path. + and, if it is deleted, \l{qmake Manual#qmake}{\c qmake} will know to + recreate it when necessary, either when the project file is later read, or + if a dependent library (described below) has changed. When installing this + library, by specifying it as a target in an \c INSTALLS declaration, + \l{qmake Manual#qmake}{\c qmake} will automatically copy the .prl file to + the installation path. The second step in this process is to enable reading of this meta information in the applications that use the static library: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 84 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 84 - When this is enabled, \l {qmake}{ \c qmake}will process all libraries linked to - by the application and find their meta-information. \l {qmake}{ \c qmake}will use - this to determine the relevant linking information, specifically adding - values to the application project file's list of \c DEFINES as well as - \c LIBS. Once \l {qmake}{ \c qmake}has processed this file, it will then look through - the newly introduced libraries in the \c LIBS variable, and find their - dependent .prl files, continuing until all libraries have been resolved. - At this point, the Makefile is created as usual, and the libraries are - linked explicitly against the application. + When this is enabled, \l{qmake Manual#qmake}{\c qmake} will process all + libraries linked to by the application and find their meta-information. + \l{qmake Manual#qmake}{\c qmake} will use this to determine the relevant + linking information, specifically adding values to the application project + file's list of \c DEFINES as well as \c LIBS. Once + \l{qmake Manual#qmake}{\c qmake} has processed this file, it will then + look through the newly introduced libraries in the \c LIBS variable, and + find their dependent .prl files, continuing until all libraries have been + resolved. At this point, the Makefile is created as usual, and the + libraries are linked explicitly against the application. The internals of the .prl file are left closed so they can easily change later. They are not designed to be changed by hand, should only - be created by \c qmake, and should not be transferred between operating - systems as they may contain platform-dependent information. + be created by \{qmake Manual#qmake}{\c qmake}, and should not be + transferred between operating systems as they may contain + platform-dependent information. \target Extensions \section1 File Extensions - Under normal circumstances \l {qmake}{ \c qmake}will try to use appropriate file extensions - for your platform. However, it is sometimes necessary to override the default - choices for each platform and explicitly define file extensions for \l {qmake}{ \c qmake}to use. - This is achieved by redefining certain built-in variables; for example the extension - used for \l moc files can be redefined with the following assignment in a project - file: + Under normal circumstances \l{qmake Manual#qmake}{\c qmake} will try to + use appropriate file extensions for your platform. However, it is + sometimes necessary to override the default choices for each platform and + explicitly define file extensions for \l{qmake Manual#qmake}{\c qmake} to + use. This is achieved by redefining certain built-in variables; for + example the extension used for \l moc files can be redefined with the + following assignment in a project file: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 85 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 85 The following variables can be used to redefine common file extensions recognized - by \c qmake: + by \l{qmake Manual#qmake}{\c qmake}: \list \o QMAKE_EXT_MOC - This modifies the extension placed on included moc files. @@ -3884,45 +3995,47 @@ accept a list of values: \list - \o QMAKE_EXT_CPP - Causes \l {qmake}{ \c qmake}to interpret all files with these suffixes as - C++ source files. - \o QMAKE_EXT_H - Causes \l {qmake}{ \c qmake}to interpret all files with these suffixes as - C and C++ header files. + \o QMAKE_EXT_CPP - Causes \l{qmake Manual#qmake}{\c qmake} to interpret + all files with these suffixes as C++ source files. + \o QMAKE_EXT_H - Causes \l qmake Manual#{qmake}{\c qmake} to interpret + all files with these suffixes as C and C++ header files. \endlist \target Customizing \section1 Customizing Makefile Output - \l {qmake}{ \c qmake}tries to do everything expected of a cross-platform build tool. - This is often less than ideal when you really need to run special - platform-dependent commands. This can be achieved with specific instructions - to the different \l {qmake}{ \c qmake}backends. + \l{qmake Manual#qmake}{\c qmake} tries to do everything expected of a + cross-platform build tool. This is often less than ideal when you really + need to run special platform-dependent commands. This can be achieved with + specific instructions to the different \l{qmake Manual#qmake}{\c qmake} + backends. Customization of the Makefile output is performed through an object-style - API as found in other places in \c qmake. Objects are defined automatically - by specifying their members; for example: + API as found in other places in \l{qmake Manual#qmake}{\c qmake}. Objects + are defined automatically by specifying their members; for example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 86 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 86 - The definitions above define a \l {qmake}{ \c qmake}target called \c mytarget, containing - a Makefile target called \c{.buildfile} which in turn is generated with - the \c touch command. Finally, the \c{.depends} member specifies that - \c mytarget depends on \c mytarget2, another target that is defined afterwards. - \c mytarget2 is a dummy target; it is only defined to echo some text to - the console. + The definitions above define a \l{qmake Manual#qmake}{\c qmake} target + called \c mytarget, containing a Makefile target called \c{.buildfile} + which in turn is generated with the \c touch command. Finally, the + \c{.depends} member specifies that \c mytarget depends on \c mytarget2, + another target that is defined afterwards. \c mytarget2 is a dummy target; + it is only defined to echo some text to the console. - The final step is to instruct \l {qmake}{ \c qmake}that this object is a target to be built: + The final step is to instruct \l{qmake Manual#qmake}{\c qmake} that this + object is a target to be built: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 87 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 87 - This is all you need to do to actually build custom targets. Of course, you may - want to tie one of these targets to the - \l{qmake Variable Reference#TARGET}{qmake build target}. To do this, you simply need to - include your Makefile target in the list of + This is all you need to do to actually build custom targets. Of course, + you may want to tie one of these targets to the + \l{qmake Variable Reference#TARGET}{qmake build target}. To do this, you + simply need to include your Makefile target in the list of \l{qmake Variable Reference#PRE_TARGETDEPS}{PRE_TARGETDEPS}. - The following tables are an overview of the options available to you with the QMAKE_EXTRA_TARGETS - variable. + The following tables are an overview of the options available to you with + the QMAKE_EXTRA_TARGETS variable. \table \header @@ -3967,15 +4080,16 @@ For convenience, there is also a method of customizing projects for new compilers or preprocessors: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 88 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 88 With the above definitions, you can use a drop-in replacement for moc if one is available. The commands is executed on all arguments given to the \c NEW_HEADERS variable (from the \c input member), and the result is written to the file defined by the \c output member; this file is added to the other source files in the project. - Additionally, \l {qmake}{ \c qmake}will execute \c depend_command to generate dependency - information, and place this information in the project as well. + Additionally, \l{qmake Manual#qmake}{\c qmake} will execute + \c depend_command to generate dependency information, and place this + information in the project as well. These commands can easily be placed into a cache file, allowing subsequent project files to add arguments to \c NEW_HEADERS. @@ -4024,71 +4138,71 @@ \table \header - \o Member - \o Description - \row - \o commands - \o The commands used for for generating the output from the input. - \row - \o CONFIG - \o Specific configuration options for the custom compiler. See the CONFIG table for details. - \row - \o depend_command - \o Specifies a command used to generate the list of dependencies for the output. - \row - \o dependency_type - \o Specifies the type of file the output is, if it is a known type (such as TYPE_C, - TYPE_UI, TYPE_QRC) then it is handled as one of those type of files. - \row - \o depends - \o Specifies the dependencies of the output file. - \row - \o input - \o The variable that contains the files that should be processed with the custom compiler. - \row - \o name - \o A description of what the custom compiler is doing. This is only used in some backends. - \row - \o output - \o The filename that is created from the custom compiler. - \row - \o output_function - \o Specifies a custom qmake function that is used to specify the filename to be created. - \row - \o variables - \o Indicates that the variables specified here are replaced with $(QMAKE_COMP_VARNAME) when refered to - in the pro file as $(VARNAME). - \row - \o variable_out - \o The variable that the files created from the output should be added to. - \endtable - - List of members specific to the CONFIG option: - - \table - \header - \o Member - \o Description - \row - \o combine - \o Indicates that all of the input files are combined into a single output file. - \row - \o target_predeps - \o Indicates that the output should be added to the list of PRE_TARGETDEPS. - \row - \o explicit_dependencies - \o The dependencies for the output only get generated from the depends member and from - nowhere else. - \row - \o no_link - \o Indicates that the output should not be added to the list of objects to be linked in. - \endtable + \o Member + \o Description + \row + \o commands + \o The commands used for for generating the output from the input. + \row + \o CONFIG + \o Specific configuration options for the custom compiler. See the CONFIG table for details. + \row + \o depend_command + \o Specifies a command used to generate the list of dependencies for the output. + \row + \o dependency_type + \o Specifies the type of file the output is, if it is a known type (such as TYPE_C, + TYPE_UI, TYPE_QRC) then it is handled as one of those type of files. + \row + \o depends + \o Specifies the dependencies of the output file. + \row + \o input + \o The variable that contains the files that should be processed with the custom compiler. + \row + \o name + \o A description of what the custom compiler is doing. This is only used in some backends. + \row + \o output + \o The filename that is created from the custom compiler. + \row + \o output_function + \o Specifies a custom qmake function that is used to specify the filename to be created. + \row + \o variables + \o Indicates that the variables specified here are replaced with $(QMAKE_COMP_VARNAME) when refered to + in the pro file as $(VARNAME). + \row + \o variable_out + \o The variable that the files created from the output should be added to. + \endtable + + List of members specific to the CONFIG option: + + \table + \header + \o Member + \o Description + \row + \o combine + \o Indicates that all of the input files are combined into a single output file. + \row + \o target_predeps + \o Indicates that the output should be added to the list of PRE_TARGETDEPS. + \row + \o explicit_dependencies + \o The dependencies for the output only get generated from the depends member and from + nowhere else. + \row + \o no_link + \o Indicates that the output should not be added to the list of objects to be linked in. + \endtable \note Symbian platform specific: Generating objects to be linked in is not supported on the Symbian platform, so either the \c CONFIG option \c no_link or variable \c variable_out should always be defined for extra compilers. - + */ /*! @@ -4098,12 +4212,13 @@ \previouspage qmake Platform Notes \nextpage Using Precompiled Headers - Many \l {qmake}{ \c qmake}project files simply describe the sources and header files used - by the project, using a list of \c{name = value} and \c{name += value} - definitions. \l {qmake}{ \c qmake}also provides other operators, functions, and scopes - that can be used to process the information supplied in variable declarations. - These advanced features allow Makefiles to be generated for multiple platforms - from a single project file. + Many \l{qmake Manual#qmake}{\c qmake} project files simply describe the + sources and header files used by the project, using a list of + \c{name = value} and \c{name += value} definitions. + \l{qmake Manual#qmake}{\c qmake} also provides other operators, functions, + and scopes that can be used to process the information supplied in + variable declarations. These advanced features allow Makefiles to be + generated for multiple platforms from a single project file. \tableofcontents @@ -4112,28 +4227,29 @@ In many project files, the assignment (\c{=}) and append (\c{+=}) operators can be used to include all the information about a project. The typical pattern of use is to assign a list of values to a variable, and append more values - depending on the result of various tests. Since \l {qmake}{ \c qmake}defines certain - variables using default values, it is sometimes necessary to use the removal - (\c{-=}) operator to filter out values that are not required. The following - operators can be used to manipulate the contents of variables. + depending on the result of various tests. Since + \l{qmake Manual#qmake}{\c qmake} defines certain variables using default + values, it is sometimes necessary to use the removal (\c{-=}) operator to + filter out values that are not required. The following operators can be + used to manipulate the contents of variables. The \c = operator assigns a value to a variable: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 89 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 89 The above line sets the \c TARGET variable to \c myapp. This will overwrite any values previously set for \c TARGET with \c myapp. The \c += operator appends a new value to the list of values in a variable: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 90 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 90 The above line appends \c QT_DLL to the list of pre-processor defines to be put in the generated Makefile. The \c -= operator removes a value from the list of values in a variable: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 91 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 91 The above line removes \c QT_DLL from the list of pre-processor defines to be put in the generated Makefile. @@ -4142,7 +4258,7 @@ if it is not already present. This prevents values from being included many times in a variable. For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 92 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 92 In the above line, \c QT_DLL will only be added to the list of pre-processor defines if it is not already defined. Note that the @@ -4153,7 +4269,7 @@ The \c ~= operator replaces any values that match a regular expression with the specified value: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 93 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 93 In the above line, any values in the list that start with \c QT_D or \c QT_T are replaced with \c QT. @@ -4161,7 +4277,7 @@ The \c $$ operator is used to extract the contents of a variable, and can be used to pass values between variables or supply them to functions: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 94 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 94 \target Scopes \section1 Scopes @@ -4188,9 +4304,9 @@ \snippet doc/src/snippets/qmake/scopes.pro 0 The above code will add the \c paintwidget_win.cpp file to the sources listed - in the generated Makefile if \l {qmake}{ \c qmake}is used on a Windows platform. - If \l {qmake}{ \c qmake}is used on a platform other than Windows, the define will be - ignored. + in the generated Makefile if \l{qmake Manual#qmake}{\c qmake} is used on a + Windows platform. If \l{qmake Manual#qmake}{\c qmake} is used on a + platform other than Windows, the define will be ignored. The conditions used in a given scope can also be negated to provide an alternative set of declarations that will be processed only if the @@ -4215,17 +4331,17 @@ You may also use the \c : operator to perform single line conditional assignments; for example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 95 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 95 The above line adds \c QT_DLL to the \c DEFINES variable only on the Windows platform. Generally, the \c : operator behaves like a logical AND operator, joining together a number of conditions, and requiring all of them to be true. - There is also the \c | operator to act like a logical OR operator, joining - together a number of conditions, and requiring only one of them to be true. + There is also the \c | operator to act like a logical OR operator, joining + together a number of conditions, and requiring only one of them to be true. - \snippet doc/src/snippets/qmake/scopes.pro 4 + \snippet doc/src/snippets/qmake/scopes.pro 4 You can also provide alternative declarations to those within a scope by using an \c else scope. Each \c else scope is processed if the conditions @@ -4233,15 +4349,15 @@ This allows you to write complex tests when combined with other scopes (separated by the \c : operator as above). For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 96 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 96 \section2 Configuration and Scopes The values stored in the - \l{qmake-project-files.html#GeneralConfiguration}{\c CONFIG variable} - are treated specially by \c qmake. Each of the possible values can be - used as the condition for a scope. For example, the list of values - held by \c CONFIG can be extended with the \c opengl value: + \l{qmake-project-files.html#GeneralConfiguration}{\c CONFIG variable} are + treated specially by \l{qmake Manual#qmake}{\c qmake}. Each of the possible + values can be used as the condition for a scope. For example, the list of + values held by \c CONFIG can be extended with the \c opengl value: \snippet doc/src/snippets/qmake/configscopes.pro 0 @@ -4284,12 +4400,13 @@ \section1 Variables Many of the variables used in project files are special variables that - \l {qmake}{ \c qmake}uses when generating Makefiles, such as \c DEFINES, \c SOURCES, - and \c HEADERS. It is possible for you to create variables for your own - use; \l {qmake}{ \c qmake}creates new variables with a given name when it encounters - an assignment to that name. For example: + \l{qmake Manual#qmake}{\c qmake} uses when generating Makefiles, such as + \c DEFINES, \c SOURCES, and \c HEADERS. It is possible for you to create + variables for your own use; \l{qmake Manual#qmake}{\c qmake} creates new + variables with a given name when it encounters an assignment to that name. + For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 97 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 97 There are no restricitions on what you do to your own variables, as \c qmake will ignore them unless it needs to evaluate them when processing @@ -4298,26 +4415,27 @@ You can also assign the value of a current variable to another variable by prefixing $$ to the variable name. For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 98 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 98 Now the MY_DEFINES variable contains what is in the DEFINES variable at this point in the project file. This is also equivalent to: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 99 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 99 The second notation allows you to append the contents of the variable to another value without separating the two with a space. For example, the following will ensure that the final executable will be given a name that includes the project template being used: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 100 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 100 Variables can be used to store the contents of environment variables. - These can be evaluated at the time that \l {qmake}{ \c qmake}is run, or included - in the generated Makefile for evaluation when the project is built. + These can be evaluated at the time that \l{qmake Manual#qmake}{\c qmake} + is run, or included in the generated Makefile for evaluation when the + project is built. - To obtain the contents of an environment value when \l {qmake}{ \c qmake}is run, - use the \c $$(...) operator: + To obtain the contents of an environment value when + \l{qmake Manual#qmake}{\c qmake}is run, use the \c $$(...) operator: \snippet doc/src/snippets/qmake/environment.pro 0 @@ -4345,17 +4463,17 @@ For example, a \QD plugin can be installed alongside \QD's built-in plugins if the following declaration is made in its project file: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 101 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 101 \target VariableProcessingFunctions \section1 Variable Processing Functions - \l {qmake}{ \c qmake}provides a selection of built-in functions to allow the - contents of variables to be processed. These functions process the - arguments supplied to them and return a value, or list of values, as - a result. In order to assign a result to a variable, it is necessary - to use the \c $$ operator with this type of function in the same way - used to assign contents of one variable to another: + \l{qmake Manual#qmake}{\c qmake} provides a selection of built-in + functions to allow the contents of variables to be processed. These + functions process the arguments supplied to them and return a value, or + list of values, as a result. In order to assign a result to a variable, + it is necessary to use the \c $$ operator with this type of function in + the same way used to assign contents of one variable to another: \snippet doc/src/snippets/qmake/functions.pro 1 @@ -4366,7 +4484,7 @@ contents of variables. These functions can be defined in the following way: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 102 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 102 The following example function takes a variable name as its only argument, extracts a list of values from the variable with the @@ -4378,9 +4496,9 @@ \target ConditionalFunctions \section1 Conditional Functions - \l {qmake}{ \c qmake}provides built-in functions that can be used as conditions - when writing scopes. These functions do not return a value, but - instead indicate "success" or "failure": + \l{qmake Manual#qmake}{\c qmake} provides built-in functions that can be + used as conditions when writing scopes. These functions do not return a + value, but instead indicate "success" or "failure": \snippet doc/src/snippets/qmake/functions.pro 3 @@ -4395,13 +4513,13 @@ \section1 Adding New Configuration Features - \l {qmake}{ \c qmake}lets you create your own \e features that can be included in - project files by adding their names to the list of values specified by - the \c CONFIG variable. Features are collections of custom functions and - definitions in \c{.prf} files that can reside in one of many standard - directories. The locations of these directories are defined in a number - of places, and \l {qmake}{ \c qmake}checks each of them in the following order when - it looks for \c{.prf} files: + \l{qmake Manual#qmake}{\c qmake} lets you create your own \e features that + can be included in project files by adding their names to the list of + values specified by the \c CONFIG variable. Features are collections of + custom functions and definitions in \c{.prf} files that can reside in one + of many standard directories. The locations of these directories are + defined in a number of places, and \l{qmake Manual#qmake}{\c qmake} checks + each of them in the following order when it looks for \c{.prf} files: \list 1 \o In a directory listed in the \c QMAKEFEATURES environment variable; @@ -4435,12 +4553,12 @@ For example, consider the following assignment in a project file: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 103 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 103 - With this addition to the \c CONFIG variable, \l {qmake}{ \c qmake}will search the - locations listed above for the \c myfeatures.prf file after it has - finished parsing your project file. On Unix systems, it will look for - the following file: + With this addition to the \c CONFIG variable, + \l{qmake Manual#qmake}{\c qmake} will search the locations listed above for + the \c myfeatures.prf file after it has finished parsing your project file. + On Unix systems, it will look for the following file: \list 1 \o \c $QMAKEFEATURES/myfeatures.prf (for each directory listed in the @@ -4480,8 +4598,8 @@ specified file. Each subsequent compilation is faster because the stable code does not need to be recompiled. - \l {qmake}{ \c qmake}supports the use of precompiled headers (PCH) on some - platforms and build environments, including: + \l{qmake Manual#qmake}{\c qmake} supports the use of precompiled headers + (PCH) on some platforms and build environments, including: \list \o Windows \list @@ -4512,7 +4630,7 @@ \section3 Example: \c stable.h - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 104 + \snippet doc/src/snippets/code/doc_src_qmake-manual.cpp 104 Note that a precompiled header file needs to separate C includes from C++ includes, since the precompiled header file for C files may not @@ -4524,11 +4642,12 @@ To make your project use PCH, you only need to define the \c PRECOMPILED_HEADER variable in your project file: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 105 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 105 - \l {qmake}{ \c qmake}will handle the rest, to ensure the creation and use of the - precompiled header file. You do not need to include the precompiled - header file in \c HEADERS, as \l {qmake}{ \c qmake}will do this if the configuration + \l{qmake Manual#qmake}{\c qmake} will handle the rest, to ensure the + creation and use of the precompiled header file. You do not need to + include the precompiled header file in \c HEADERS, as + \l{qmake Manual#qmake}{\c qmake} will do this if the configuration supports PCH. All platforms that support precompiled headers have the configuration @@ -4536,7 +4655,7 @@ conditional blocks in your project file to add settings when using PCH. For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 106 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 106 \section1 Notes on Possible Issues @@ -4545,7 +4664,7 @@ declarations may cause two different object files with the same name to be generated: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 107 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 107 To avoid potential conflicts like these, it is good practice to ensure that header files that will be precompiled are given distinctive names. @@ -4593,8 +4712,9 @@ \previouspage qmake Manual \nextpage qmake Common Projects - This tutorial teaches you how to use \c qmake. We recommend that - you read the \l {qmake}{ \c qmake}user guide after completing this tutorial. + This tutorial teaches you how to use \l{qmake Manual#qmake}{\c qmake}. We + recommend that you read the \l{qmake Manual#qmake}{\c qmake} user guide + after completing this tutorial. \section1 Starting off Simple @@ -4612,25 +4732,25 @@ the application is that it's written in Qt. First, using your favorite plain text editor, create a file called \c hello.pro in \c{examples/qmake/tutorial}. The first thing you need to do is add the - lines that tell \l {qmake}{ \c qmake}about the source and header files that are part - of your development project. + lines that tell \l{qmake Manual#qmake}{\c qmake} about the source and + header files that are part of your development project. We'll add the source files to the project file first. To do this you need to use the \l{qmake Variable Reference#SOURCES}{SOURCES} variable. Just start a new line with \c {SOURCES +=} and put hello.cpp after it. You should have something like this: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 108 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 108 We repeat this for each source file in the project, until we end up with the following: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 109 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 109 If you prefer to use a Make-like syntax, with all the files listed in one go you can use the newline escaping like this: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 110 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 110 Now that the source files are listed in the project file, the header files must be added. These are added in exactly the same way as source @@ -4640,7 +4760,7 @@ Once you have done this, your project file should look something like this: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 111 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 111 The target name is set automatically; it is the same as the project file, but with the suffix appropriate to the platform. For example, if @@ -4648,29 +4768,30 @@ on Windows and \c hello on Unix. If you want to use a different name you can set it in the project file: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 112 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 112 The final step is to set the \l{qmake Variable Reference#CONFIG}{CONFIG} variable. Since this is a Qt application, we need to put \c qt on the - \c CONFIG line so that \l {qmake}{ \c qmake}will add the relevant libraries to be - linked against and ensure that build lines for \c moc and \c uic are - included in the generated Makefile. + \c CONFIG line so that \l{qmake Manual#qmake}{\c qmake} will add the + relevant libraries to be linked against and ensure that build lines for + \c moc and \c uic are included in the generated Makefile. The finished project file should look like this: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 113 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 113 - You can now use \l {qmake}{ \c qmake}to generate a Makefile for your application. - On the command line, in your project's directory, type the following: + You can now use \l{qmake Manual#qmake}{\c qmake} to generate a Makefile + for your application. On the command line, in your project's directory, + type the following: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 114 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 114 Then type \c make or \c nmake depending on the compiler you use. - For Visual Studio users, \l {qmake}{ \c qmake}can also generate \c .dsp or - \c .vcproj files, for example: + For Visual Studio users, \l{qmake Manual#qmake}{\c qmake} can also + generate \c .dsp or \c .vcproj files, for example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 115 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 115 \section1 Making an Application Debuggable @@ -4682,11 +4803,11 @@ For example: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 116 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 116 - Use \l {qmake}{ \c qmake}as before to generate a Makefile and you will be able to - obtain useful information about your application when running it in - a debugging environment. + Use \l{qmake Manual#qmake}{\c qmake} as before to generate a Makefile and + you will be able to obtain useful information about your application when + running it in a debugging environment. \section1 Adding Platform-Specific Source Files @@ -4697,44 +4818,46 @@ hellounix.cpp. We can't just add these to the \c SOURCES variable since this will put both files in the Makefile. So, what we need to do here is to use a scope which will be processed depending on - which platform \l {qmake}{ \c qmake}is run on. + which platform \l{qmake Manual#qmake}{\c qmake} is run on. A simple scope that will add in the platform-dependent file for Windows looks like this: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 117 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 117 - So if \l {qmake}{ \c qmake}is run on Windows, it will add \c hellowin.cpp to the - list of source files. If \l {qmake}{ \c qmake}is run on any other platform, it + So if \l{qmake Manual#qmake}{\c qmake} is run on Windows, it will add + \c hellowin.cpp to the list of source files. If + \l{qmake Manual#qmake}{\c qmake} is run on any other platform, it will simply ignore it. Now all that is left to be done is to create a scope for the Unix-specific file. When you have done that, your project file should now look something like this: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 118 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 118 - Use \l {qmake}{ \c qmake}as before to generate a Makefile. + Use \l{qmake Manual#qmake}{\c qmake} as before to generate a Makefile. \section1 Stopping qmake If a File Doesn't Exist You may not want to create a Makefile if a certain file doesn't exist. We can check if a file exists by using the exists() function. We can - stop \l {qmake}{ \c qmake}from processing by using the error() function. This - works in the same way as scopes do. Simply replace the scope condition - with the function. A check for a \c main.cpp file looks like this: + stop \l{qmake Manual#qmake}{\c qmake} from processing by using the error() + function. This works in the same way as scopes do. Simply replace the + scope condition with the function. A check for a \c main.cpp file looks + like this: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 119 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 119 The \c{!} symbol is used to negate the test; i.e. \c{exists( main.cpp )} is true if the file exists, and \c{!exists( main.cpp )} is true if the file doesn't exist. - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 120 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 120 - Use \l {qmake}{ \c qmake}as before to generate a makefile. If you rename \c - main.cpp temporarily, you will see the message and \l {qmake}{ \c qmake}will stop - processing. + Use \l{qmake Manual#qmake}{\c qmake} as before to generate a makefile. + If you rename \c main.cpp temporarily, you will see the message and + \l{qmake Manual#qmake}{\c qmake} will stop processing. \section1 Checking for More than One Condition @@ -4749,15 +4872,16 @@ the other inside it. Put the settings to be processed inside the last scope, like this: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 121 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 121 Nested scopes can be joined together using colons, so the final project file looks like this: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 122 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 122 - That's it! You have now completed the tutorial for \c qmake, and are - ready to write project files for your development projects. + That's it! You have now completed the tutorial for + \l{qmake Manual#qmake}{\c qmake}, and are ready to write project files for + your development projects. */ /*! @@ -4767,10 +4891,10 @@ \previouspage qmake Tutorial \nextpage Using qmake - This chapter describes how to set up \l {qmake}{ \c qmake}project files for three - common project types that are based on Qt. Although all kinds of - projects use many of the same variables, each of them use project-specific - variables to customize output files. + This chapter describes how to set up \l{qmake Manual#qmake}{\c qmake} + project files for three common project types that are based on Qt. + Although all kinds of projects use many of the same variables, each of + them use project-specific variables to customize output files. Platform-specific variables are not described here; we refer the reader to the \l{Deploying Qt Applications} document for information on issues such as @@ -4786,9 +4910,10 @@ \section2 The app Template - The \c app template tells \l {qmake}{ \c qmake}to generate a Makefile that will build - an application. With this template, the type of application can be specified - by adding one of the following options to the \c CONFIG variable definition: + The \c app template tells \l{qmake Manual#qmake}{\c qmake} to generate a + Makefile that will build an application. With this template, the type of + application can be specified by adding one of the following options to the + \c CONFIG variable definition: \table \header \o Option \o Description @@ -4797,9 +4922,9 @@ application. \endtable - When using this template the following \l {qmake}{ \c qmake}system variables are recognized. - You should use these in your .pro file to specify information about your - application. + When using this template the following \l{qmake Manual#qmake}{\c qmake} + system variables are recognized. You should use these in your .pro file to + specify information about your application. \list \o HEADERS - A list of all the header files for the application. @@ -4821,12 +4946,12 @@ \o RES_FILE - Windows only: A resource file to be linked against for the application. \endlist - You only need to use the system variables that you have values for, - for instance, if you do not have any extra INCLUDEPATHs then you do not - need to specify any, \l {qmake}{ \c qmake}will add in the default ones needed. - For instance, an example project file might look like this: + You only need to use the system variables that you have values for, for + instance, if you do not have any extra INCLUDEPATHs then you do not need + to specify any, \l{qmake Manual#qmake}{\c qmake} will add in the default + ones needed. For instance, an example project file might look like this: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 123 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 123 For items that are single valued, e.g. the template or the destination directory, we use "="; but for multi-valued items we use "+=" to \e @@ -4839,11 +4964,11 @@ \section2 The lib Template - The \c lib template tells \l {qmake}{ \c qmake}to generate a Makefile that will - build a library. When using this template, in addition to the system variables - mentioned above for the \c app template the \c VERSION variable is - supported. You should use these in your .pro file to specify - information about the library. + The \c lib template tells \l{qmake Manual#qmake}{\c qmake} to generate a + Makefile that will build a library. When using this template, in addition + to the system variables mentioned above for the \c app template the + \c VERSION variable is supported. You should use these in your .pro file + to specify information about the library. When using the \c lib template, the following options can be added to the \c CONFIG variable to determine the type of library that is built: @@ -4870,10 +4995,10 @@ \section1 Building a Plugin Plugins are built using the \c lib template, as described in the previous - section. This tells \l {qmake}{ \c qmake}to generate a Makefile for the project that will - build a plugin in a suitable form for each platform, usually in the form of a - library. As with ordinary libraries, the \c VERSION variable is used to specify - information about the plugin. + section. This tells \l{qmake Manual#qmake}{\c qmake} to generate a + Makefile for the project that will build a plugin in a suitable form for + each platform, usually in the form of a library. As with ordinary + libraries, the \c VERSION variable is used to specify information about the plugin. \list \o VERSION - The version number of the target library, for example, 2.3.1. @@ -4908,11 +5033,11 @@ ensure that the resulting targets have different names. Providing different names for targets ensures that one will not overwrite the other. - When \l {qmake}{ \c qmake}processes the project file, it will generate a Makefile rule - to allow the project to be built in both modes. This can be invoked in the - following way: + When \l{qmake Manual#qmake}{\c qmake} processes the project file, it will + generate a Makefile rule to allow the project to be built in both modes. + This can be invoked in the following way: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 124 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 124 The \c build_all option can be added to the \c CONFIG variable in the project file to ensure that the project is built in both modes by default: @@ -4921,14 +5046,14 @@ This allows the Makefile to be processed using the default rule: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 125 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 125 \section2 Installing in Both Modes The \c build_all option also ensures that both versions of the target will be installed when the installation rule is invoked: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 126 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 126 It is possible to customize the names of the build targets depending on the target platform. For example, a library or plugin may be named using a @@ -4938,7 +5063,7 @@ Note: This was originally used in the customwidgetplugin.pro file, but is no longer needed there. \endomit - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 127 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 127 The default behavior in the above snippet is to modify the name used for the build target when building in debug mode. An \c else clause could be diff --git a/doc/src/development/qtestlib.qdoc b/doc/src/development/qtestlib.qdoc index 8924bdb..44b682a 100644 --- a/doc/src/development/qtestlib.qdoc +++ b/doc/src/development/qtestlib.qdoc @@ -119,7 +119,7 @@ testfunction. Example: - \snippet doc/src/snippets/code/doc_src_qtestlib.qdoc 0 + \snippet doc/src/snippets/code/doc_src_qtestlib.cpp 0 For more examples, refer to the \l{QTestLib Tutorial}. @@ -128,7 +128,7 @@ If you are using \c qmake as your build tool, just add the following to your project file: - \snippet doc/src/snippets/code/doc_src_qtestlib.qdoc 1 + \snippet doc/src/snippets/code/doc_src_qtestlib.pro 1 If you are using other build tools, make sure that you add the location of the QTestLib header files to your include path (usually \c{include/QtTest} @@ -217,7 +217,7 @@ To create a benchmark, follow the instructions for creating a test and then add a QBENCHMARK macro to the test function that you want to benchmark. - \snippet doc/src/snippets/code/doc_src_qtestlib.qdoc 12 + \snippet doc/src/snippets/code/doc_src_qtestlib.cpp 12 The code inside the QBENCHMARK macro will be measured, and possibly also repeated several times in order to get an accurate measurement. This depends on the selected @@ -410,7 +410,7 @@ Then you need to implement the test function itself. The implementation could look like this: - \snippet doc/src/snippets/code/doc_src_qtestlib.qdoc 8 + \snippet doc/src/snippets/code/doc_src_qtestlib.cpp 8 The \l QVERIFY() macro evaluates the expression passed as its argument. If the expression evaluates to true, the execution of @@ -475,7 +475,7 @@ test function. If we add more test data, the function might look like this: - \snippet doc/src/snippets/code/doc_src_qtestlib.qdoc 11 + \snippet doc/src/snippets/code/doc_src_qtestlib.cpp 11 To prevent that the function ends up being cluttered by repetitive code, QTestLib supports adding test data to a test function. All diff --git a/doc/src/examples/activeqt/hierarchy-demo-snippet.qdoc b/doc/src/examples/activeqt/hierarchy-demo-snippet.qdoc new file mode 100644 index 0000000..a36ebbb --- /dev/null +++ b/doc/src/examples/activeqt/hierarchy-demo-snippet.qdoc @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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:FDL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Free Documentation License +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of this +** file. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [script] +<script language="javascript"> +function createSubWidget( form ) +{ + ParentWidget.createSubWidget( form.nameEdit.value ); +} + +function renameSubWidget( form ) +{ + var SubWidget = ParentWidget.subWidget( form.nameEdit.value ); + if ( !SubWidget ) { + alert( "No such widget " + form.nameEdit.value + "!" ); + return; + } + SubWidget.label = form.labelEdit.value; + form.nameEdit.value = SubWidget.label; +} + +function setFont( form ) +{ + ParentWidget.font = form.fontEdit.value; +} +</script> + +<p> +This widget can have many children! +</p> +<object ID="ParentWidget" CLASSID="CLSID:d574a747-8016-46db-a07c-b2b4854ee75c" +CODEBASE="http://qt.nokia.com/demos/hierarchy.cab"> +[Object not available! Did you forget to build and register the server?] +</object><br /> +<form> +<input type="edit" ID="nameEdit" value="<enter object name>" /> +<input type="button" value="Create" onClick="createSubWidget(this.form)" /> +<input type="edit" ID="labelEdit" /> +<input type="button" value="Rename" onClick="renameSubWidget(this.form)" /> +<br /> +<input type="edit" ID="fontEdit" value="MS Sans Serif" /> +<input type="button" value = "Set Font" onClick="setFont(this.form)" /> +</form> +//! [script] diff --git a/doc/src/examples/activeqt/hierarchy-demo.qdocinc b/doc/src/examples/activeqt/hierarchy-demo.qdocinc index e7cb56e..86bfd87 100644 --- a/doc/src/examples/activeqt/hierarchy-demo.qdocinc +++ b/doc/src/examples/activeqt/hierarchy-demo.qdocinc @@ -1,5 +1,4 @@ \raw HTML -//! [0] <script language="javascript"> function createSubWidget( form ) { @@ -39,5 +38,4 @@ CODEBASE="http://qt.nokia.com/demos/hierarchy.cab"> <input type="edit" ID="fontEdit" value="MS Sans Serif" /> <input type="button" value = "Set Font" onClick="setFont(this.form)" /> </form> -//! [0] \endraw diff --git a/doc/src/examples/activeqt/hierarchy.qdoc b/doc/src/examples/activeqt/hierarchy.qdoc index eb6cc71..791af1f 100644 --- a/doc/src/examples/activeqt/hierarchy.qdoc +++ b/doc/src/examples/activeqt/hierarchy.qdoc @@ -25,7 +25,7 @@ ** ****************************************************************************/ -/*! +/*! \page qaxserver-demo-hierarchy.html \title Qt Widget Hierarchy @@ -84,5 +84,5 @@ your WebBrowser to support ActiveX controls, and scripting to be enabled. - \snippet examples/activeqt/hierarchy-demo.qdocinc 0 + \snippet examples/activeqt/hierarchy-demo-snippet.qdoc script */ diff --git a/doc/src/examples/arrowpad.qdoc b/doc/src/examples/arrowpad.qdoc index bb22f83..5e9cc9a 100644 --- a/doc/src/examples/arrowpad.qdoc +++ b/doc/src/examples/arrowpad.qdoc @@ -66,7 +66,7 @@ context: it is the context of the texts in the \c ArrowPad class. The \c Q_OBJECT macro defines \c tr(x) in \c ArrowPad like this: - \snippet doc/src/snippets/code/doc_src_examples_arrowpad.qdoc 0 + \snippet doc/src/snippets/code/doc_src_examples_arrowpad.cpp 0 Knowing which class each source text appears in enables \e {Qt Linguist} to group texts that are logically related together, e.g. diff --git a/doc/src/examples/containerextension.qdoc b/doc/src/examples/containerextension.qdoc index 818547c..57295de 100644 --- a/doc/src/examples/containerextension.qdoc +++ b/doc/src/examples/containerextension.qdoc @@ -138,7 +138,7 @@ target path for the project and adding it to the list of items to install: - \snippet doc/src/snippets/code/doc_src_examples_containerextension.qdoc 0 + \snippet doc/src/snippets/code/doc_src_examples_containerextension.pro 0 The container extension is created as a library, and will be installed alongside the other \QD plugins when the project is diff --git a/doc/src/examples/customwidgetplugin.qdoc b/doc/src/examples/customwidgetplugin.qdoc index f972500..5b6aab6 100644 --- a/doc/src/examples/customwidgetplugin.qdoc +++ b/doc/src/examples/customwidgetplugin.qdoc @@ -89,7 +89,7 @@ target path for the project and adding it to the list of items to install: - \snippet doc/src/snippets/code/doc_src_examples_customwidgetplugin.qdoc 0 + \snippet doc/src/snippets/code/doc_src_examples_customwidgetplugin.pro 0 The custom widget is created as a library, and will be installed alongside the other \QD plugins when the project is installed diff --git a/doc/src/examples/editabletreemodel.qdoc b/doc/src/examples/editabletreemodel.qdoc index 042b745..5edc91b 100644 --- a/doc/src/examples/editabletreemodel.qdoc +++ b/doc/src/examples/editabletreemodel.qdoc @@ -131,14 +131,14 @@ In the case shown in the diagram, the piece of information represented by \bold{a} can be obtained using the standard model/view API: - \snippet doc/src/snippets/code/doc_src_examples_editabletreemodel.qdoc 0 + \snippet doc/src/snippets/code/doc_src_examples_editabletreemodel.cpp 0 Since each items holds pieces of data for each column in a given row, there can be many model indexes that map to the same \c TreeItem object. For example, the information represented by \bold{b} can be obtained using the following code: - \snippet doc/src/snippets/code/doc_src_examples_editabletreemodel.qdoc 1 + \snippet doc/src/snippets/code/doc_src_examples_editabletreemodel.cpp 1 The same underlying \c TreeItem would be accessed to obtain information for the other model indexes in the same row as \bold{b}. diff --git a/doc/src/examples/fademessage.qdoc b/doc/src/examples/fademessage.qdoc index b8a09e8..09c1d94 100644 --- a/doc/src/examples/fademessage.qdoc +++ b/doc/src/examples/fademessage.qdoc @@ -29,13 +29,9 @@ \example effects/fademessage \title Fade Message Effect Example - \raw HTML - <div style="text-align: center"> - \endraw + \div { style="text-align: center"} \inlineimage fademessageeffect-example.png \inlineimage fademessageeffect-example-faded.png - \raw HTML - </div> - \endraw + \enddiv */ diff --git a/doc/src/examples/fancybrowser.qdoc b/doc/src/examples/fancybrowser.qdoc index b46903d..bc30988 100644 --- a/doc/src/examples/fancybrowser.qdoc +++ b/doc/src/examples/fancybrowser.qdoc @@ -26,8 +26,8 @@ ****************************************************************************/ /*! - \example webkit/fancybrowser - \title Fancy Browser Example + \example webkit/fancybrowser + \title Fancy Browser Example The Fancy Browser example shows how to use jQuery with QtWebKit to create a web browser with special effects and content diff --git a/doc/src/examples/globalVariables.qdoc b/doc/src/examples/globalVariables.qdoc index 4629801..224a3a7 100644 --- a/doc/src/examples/globalVariables.qdoc +++ b/doc/src/examples/globalVariables.qdoc @@ -101,48 +101,25 @@ The \c xmlpatterns command loads and parses \c globals.gccxml, runs the XQuery \c reportGlobals.xq, and generates this report: - \raw HTML -<html xmlns="http://www.w3.org/1999/xhtml/" xml:lang="en" lang="en"> - <head> - <title>Global variables report for globals.gccxml</title> - </head> - <style type="text/css"> - .details - { - text-align: left; - font-size: 80%; - color: blue - } - .variableName - { - font-family: courier; - color: blue - } - </style> - <body> - <p class="details">Start report: 2008-12-16T13:43:49.65Z</p> - <p>Global variables with complex types:</p> - <ol> - <li> - <span class="variableName">mutableComplex1</span> in globals.cpp at line 14</li> - <li> - <span class="variableName">mutableComplex2</span> in globals.cpp at line 15</li> - <li> - <span class="variableName">constComplex1</span> in globals.cpp at line 16</li> - <li> - <span class="variableName">constComplex2</span> in globals.cpp at line 17</li> - </ol> - <p>Mutable global variables with primitives types:</p> - <ol> - <li> - <span class="variableName">mutablePrimitive1</span> in globals.cpp at line 1</li> - <li> - <span class="variableName">mutablePrimitive2</span> in globals.cpp at line 2</li> - </ol> - <p class="details">End report: 2008-12-16T13:43:49.65Z</p> - </body> -</html> - \endraw + \div {class="details"} + Start report: 2008-12-16T13:43:49.65Z + \enddiv + + Global variables with complex types: + \list 1 + \o \span {class="variableName"} {mutableComplex1} in globals.cpp at line 14 + \o \span {class="variableName"} {mutableComplex2} in globals.cpp at line 15 + \o \span {class="variableName"} {constComplex1} in globals.cpp at line 16 + \o \span {class="variableName"} {constComplex2} in globals.cpp at line 17 + \endlist + + Mutable global variables with primitives types: + \list 1 + \o \span {class="variableName"} {mutablePrimitive1} in globals.cpp at line 1 + \o \span {class="variableName"} {mutablePrimitive2} in globals.cpp at line 2 + \endlist + + \div {class="details"} End report: 2008-12-16T13:43:49.65Z \enddiv \section1 XQuery Code Walk-Through diff --git a/doc/src/examples/icons.qdoc b/doc/src/examples/icons.qdoc index 4210859..3966bf4 100644 --- a/doc/src/examples/icons.qdoc +++ b/doc/src/examples/icons.qdoc @@ -147,8 +147,8 @@ render the other six mode/state combinations, QIcon uses the search algorithm described in the table below: - \table - \header \o{2,1} Requested Pixmap \o{8,1} Preferred Alternatives (mode/state) + \table 100% + \header \o{2,1} Requested Pixmap \o {8,1} Preferred Alternatives (mode/state) \header \o Mode \o State \o 1 \o 2 \o 3 \o 4 \o 5 \o 6 \o 7 \o 8 \row \o{1,2} Normal \o Off \o \bold N0 \o A0 \o N1 \o A1 \o D0 \o S0 \o D1 \o S1 \row \o On \o N1 \o \bold A1 \o N0 \o A0 \o D1 \o S1 \o D0 \o S0 @@ -278,7 +278,7 @@ If the application is built in debug mode, the \c Q_ASSERT() macro will expand to - \snippet doc/src/snippets/code/doc_src_examples_icons.qdoc 0 + \snippet doc/src/snippets/code/doc_src_examples_icons.cpp 0 In release mode, the macro simply disappear. The mode can be set in the application's \c .pro file. One way to do so is to add an diff --git a/doc/src/examples/imageviewer.qdoc b/doc/src/examples/imageviewer.qdoc index 70f71c8..f1d02c3 100644 --- a/doc/src/examples/imageviewer.qdoc +++ b/doc/src/examples/imageviewer.qdoc @@ -149,7 +149,7 @@ \{QWidget::adjustSize()}{adjustSize()} to achieve this, which is essentially the same as - \snippet doc/src/snippets/code/doc_src_examples_imageviewer.qdoc 0 + \snippet doc/src/snippets/code/doc_src_examples_imageviewer.cpp 0 In the \c print() slot, we first make sure that an image has been loaded into the application: @@ -160,7 +160,7 @@ If the application is built in debug mode, the \c Q_ASSERT() macro will expand to - \snippet doc/src/snippets/code/doc_src_examples_imageviewer.qdoc 1 + \snippet doc/src/snippets/code/doc_src_examples_imageviewer.cpp 1 In release mode, the macro simply disappear. The mode can be set in the application's \c .pro file. One way to do so is to add an @@ -318,7 +318,7 @@ Whenever we zoom in or out, we need to adjust the scroll bars in consequence. It would have been tempting to simply call - \snippet doc/src/snippets/code/doc_src_examples_imageviewer.qdoc 4 + \snippet doc/src/snippets/code/doc_src_examples_imageviewer.cpp 4 but this would make the top-left corner the focal point, not the center. Therefore we need to take into account the scroll bar diff --git a/doc/src/examples/qml-examples.qdoc b/doc/src/examples/qml-examples.qdoc index 3439b09..68deae7 100644 --- a/doc/src/examples/qml-examples.qdoc +++ b/doc/src/examples/qml-examples.qdoc @@ -29,7 +29,7 @@ \title Animation: Basics Example \example declarative/animation/basics - This example shows how to create and combine \l{QML Animation}{animations} in QML. + This example shows how to create and combine \l{QML Animation and Transitions}{animations} in QML. \table \row @@ -50,16 +50,16 @@ \title Animation: Behavior Examples \example declarative/animation/behaviors - This example shows how to use QML behaviors. + This example shows how to use QML behaviors. \image qml-behaviors-example.png */ /*! - \title Animation: Easing Example + \title Animation: Easing Example \example declarative/animation/easing - This example shows the different easing modes available for \l{QML Animation}{animations}. + This example shows the different easing modes available for \l{QML Animation and Transitions}{animations}. \image qml-easing-example.png */ @@ -122,9 +122,9 @@ \page declarative-cppextensions-reference.html \title C++ Extensions: Reference examples - These examples show how QML can be extended from C++ in various ways. - - The code for these examples is used throughout the \l {Extending QML in C++} reference + These examples show how QML can be extended from C++ in various ways. + + The code for these examples is used throughout the \l {Extending QML Functionalities using C++} reference documentation, which highlights the main principles demonstrated in each example. Furthermore, here are additional pages that discuss each example in detail: @@ -160,7 +160,7 @@ \title LayoutItem Example \example declarative/cppextensions/qgraphicslayouts/layoutitem - This example show how to use the LayoutItem element to integrate QML items into an existing + This example show how to use the LayoutItem element to integrate QML items into an existing \l{Graphics View Framework}{Graphics View}-based application. \image qml-layoutitem-example.png @@ -169,7 +169,7 @@ \title QGraphicsGridLayout Example \example declarative/cppextensions/qgraphicslayouts/qgraphicsgridlayout - This example shows how to use QGraphicsGridLayout to lay out QML items. This is + This example shows how to use QGraphicsGridLayout to lay out QML items. This is useful if you need to integrate Qt \l{Graphics View Framework}{Graphics View} layouts with QML. @@ -179,10 +179,10 @@ \title QGraphicsLinearLayout Example \example declarative/cppextensions/qgraphicslayouts/qgraphicslinearlayout - This example shows how to use QGraphicsLinearLayout to lay out QML items. This is + This example shows how to use QGraphicsLinearLayout to lay out QML items. This is useful if you need to integrate Qt \l{Graphics View Framework}{Graphics View} layouts with QML. - + \image qml-qgraphicslinearlayout-example.png */ /*! @@ -198,7 +198,7 @@ \o \l{declarative/cppextensions/qgraphicslayouts/qgraphicslinearlayout}{QGraphicsLinearLayout} \endlist - Also see \l {Integrating QML with existing Qt UI code} for information on using QML + Also see \l {Integrating QML Code with Existing Qt UI Code} for information on using QML in Qt applications that use the Graphics View framework or ordinary QWidget-based views. */ @@ -215,7 +215,7 @@ \title C++ Extensions: Image Provider Example \example declarative/cppextensions/imageprovider - This examples shows how to use QDeclarativeImageProvider to serve images + This examples shows how to use QDeclarativeImageProvider to serve images to QML image elements. \image qml-imageprovider-example.png @@ -232,6 +232,7 @@ /*! \title Internationalization Example \example declarative/i18n + \ingroup internationalization This example shows how to enable text translation in QML. @@ -567,7 +568,7 @@ \example declarative/toys/clocks This example displays a set of clocks with different times for different cities. - Each clock is created by combining \l Image elements with \l Rotation transforms + Each clock is created by combining \l Image elements with \l Rotation transforms and \l SpringAnimation behaviors. \image qml-clocks-example.png @@ -615,13 +616,6 @@ */ /*! - \title Touch Interaction: Gestures Example - \example declarative/touchinteraction/gestures - - This example shows how to use the GestureArea element. -*/ - -/*! \title Touch Interaction: MouseArea Example \example declarative/touchinteraction/mousearea diff --git a/doc/src/examples/qtscriptcustomclass.qdoc b/doc/src/examples/qtscriptcustomclass.qdoc index f2b4f36..3ee6c95 100644 --- a/doc/src/examples/qtscriptcustomclass.qdoc +++ b/doc/src/examples/qtscriptcustomclass.qdoc @@ -46,7 +46,7 @@ scripting environment, \c{ByteArray} objects can be constructed like so: - \snippet doc/src/snippets/code/doc_src_examples_qtscriptcustomclass.qdoc 0 + \snippet doc/src/snippets/code/doc_src_examples_qtscriptcustomclass.cpp 0 \c{ByteArray} objects behave similar to normal \c{Array} objects. Every \c{ByteArray} object has a \c{length} property, that holds the length of the array. If a new value is assigned to the \c{length} @@ -55,22 +55,22 @@ Use normal array operations to read or write bytes in the array. The following code sets all the bytes of an array to a certain value: - \snippet doc/src/snippets/code/doc_src_examples_qtscriptcustomclass.qdoc 1 + \snippet doc/src/snippets/code/doc_src_examples_qtscriptcustomclass.cpp 1 When assigning a value to an array element, the value is truncated to eight bits: - \snippet doc/src/snippets/code/doc_src_examples_qtscriptcustomclass.qdoc 2 + \snippet doc/src/snippets/code/doc_src_examples_qtscriptcustomclass.cpp 2 Like normal \c{Array} objects, if the array index is greater than the current length of the array, the array is resized accordingly: - \snippet doc/src/snippets/code/doc_src_examples_qtscriptcustomclass.qdoc 3 + \snippet doc/src/snippets/code/doc_src_examples_qtscriptcustomclass.cpp 3 Property names that aren't valid array indexes are treated like normal object properties (again, the same is the case for normal \c{Array} objects); in other words, it's perfectly fine to do something like this: - \snippet doc/src/snippets/code/doc_src_examples_qtscriptcustomclass.qdoc 4 + \snippet doc/src/snippets/code/doc_src_examples_qtscriptcustomclass.cpp 4 The above assignment won't affect the contents of the array, but will rather assign a value to the object property named "foo". @@ -78,7 +78,7 @@ \c{ByteArray} objects have a set of methods: chop(), equals(), left(), mid(), toBase64() and so on. These map directly onto the corresponding methods in QByteArray. - \snippet doc/src/snippets/code/doc_src_examples_qtscriptcustomclass.qdoc 5 + \snippet doc/src/snippets/code/doc_src_examples_qtscriptcustomclass.cpp 5 \section1 ByteArray Class Implementation diff --git a/doc/src/examples/rogue.qdoc b/doc/src/examples/rogue.qdoc index 94539ad..4df0910 100644 --- a/doc/src/examples/rogue.qdoc +++ b/doc/src/examples/rogue.qdoc @@ -190,8 +190,8 @@ \snippet examples/statemachine/rogue/movementtransition.h 2 When \c onTransition() is invoked, we know that we have a - \l{QEvent::}{KeyPress} event with 2, 4, 6, or 8, i.e., the event - is already unwrapped. + \l{QEvent::}{KeyPress} event with 2, 4, 6, or 8, and can ask \c + Window to move the player. \section1 The Roguelike Tradition diff --git a/doc/src/examples/simpledommodel.qdoc b/doc/src/examples/simpledommodel.qdoc index ea380bd..9b4d80e 100644 --- a/doc/src/examples/simpledommodel.qdoc +++ b/doc/src/examples/simpledommodel.qdoc @@ -53,7 +53,7 @@ snippet reads the contents of a file into a QDomDocument object and traverses the document, reading all the plain text that can be found: - \snippet doc/src/snippets/code/doc_src_examples_simpledommodel.qdoc 0 + \snippet doc/src/snippets/code/doc_src_examples_simpledommodel.cpp 0 In principle, the functions provided by QDomNode can be used to navigate from any given starting point in a document to the piece of data requested by another component. diff --git a/doc/src/examples/taskmenuextension.qdoc b/doc/src/examples/taskmenuextension.qdoc index 0200c2f..b557b8b 100644 --- a/doc/src/examples/taskmenuextension.qdoc +++ b/doc/src/examples/taskmenuextension.qdoc @@ -139,7 +139,7 @@ target path for the project and adding it to the list of items to install: - \snippet doc/src/snippets/code/doc_src_examples_taskmenuextension.qdoc 0 + \snippet doc/src/snippets/code/doc_src_examples_taskmenuextension.pro 0 The task menu extension is created as a library, and will be installed alongside the other \QD plugins when the project is diff --git a/doc/src/examples/textfinder.qdoc b/doc/src/examples/textfinder.qdoc index e92bb98..f5f41d7 100644 --- a/doc/src/examples/textfinder.qdoc +++ b/doc/src/examples/textfinder.qdoc @@ -70,7 +70,7 @@ QtUiTools module library. This is done in the \c{textfinder.pro} file that contains the following lines: - \snippet doc/src/snippets/code/doc_src_examples_textfinder.qdoc 0 + \snippet doc/src/snippets/code/doc_src_examples_textfinder.pro 0 \section1 TextFinder Class Definition diff --git a/doc/src/examples/trollprint.qdoc b/doc/src/examples/trollprint.qdoc index 3a77a71..a93811e 100644 --- a/doc/src/examples/trollprint.qdoc +++ b/doc/src/examples/trollprint.qdoc @@ -132,12 +132,12 @@ second argument "two-sided" in the appropriate \c tr() calls to the first pair of radio buttons: - \snippet doc/src/snippets/code/doc_src_examples_trollprint.qdoc 0 + \snippet doc/src/snippets/code/doc_src_examples_trollprint.cpp 0 and add the second argument "colors" in the appropriate \c tr() calls for the second pair of radio buttons: - \snippet doc/src/snippets/code/doc_src_examples_trollprint.qdoc 1 + \snippet doc/src/snippets/code/doc_src_examples_trollprint.cpp 1 Now run \c lupdate and open \c trollprint_pt.ts with \e {Qt Linguist}. You should now see two changes. @@ -177,7 +177,7 @@ the translations. This can be achieved by using a \c TRANSLATOR comment in the source code: - \snippet doc/src/snippets/code/doc_src_examples_trollprint.qdoc 2 + \snippet doc/src/snippets/code/doc_src_examples_trollprint.cpp 2 Try adding these comments to some source files, particularly to dialog classes, describing the navigation necessary to reach the @@ -192,7 +192,7 @@ correct. Comments that provide good navigation information can save them time: - \snippet doc/src/snippets/code/doc_src_examples_trollprint.qdoc 3 + \snippet doc/src/snippets/code/doc_src_examples_trollprint.cpp 3 \section1 Troll Print 1.1 diff --git a/doc/src/examples/undoframework.qdoc b/doc/src/examples/undoframework.qdoc index c5bc279..65104bd 100644 --- a/doc/src/examples/undoframework.qdoc +++ b/doc/src/examples/undoframework.qdoc @@ -199,8 +199,7 @@ \snippet examples/tools/undoframework/commands.cpp 8 - \c undo() removes the item from the scene. We need to update the - scene as ...(ask Andreas) + \c undo() removes the item from the scene. \snippet examples/tools/undoframework/commands.cpp 9 diff --git a/doc/src/examples/worldtimeclockplugin.qdoc b/doc/src/examples/worldtimeclockplugin.qdoc index 61a214c..8a17004 100644 --- a/doc/src/examples/worldtimeclockplugin.qdoc +++ b/doc/src/examples/worldtimeclockplugin.qdoc @@ -176,7 +176,7 @@ is searched by \QD. We do this by specifying a target path for the project and adding it to the list of items to install: - \snippet doc/src/snippets/code/doc_src_examples_worldtimeclockplugin.qdoc 0 + \snippet doc/src/snippets/code/doc_src_examples_worldtimeclockplugin.pro 0 The custom widget is created as a library, and will be installed alongside the other \QD plugins when the project is installed diff --git a/doc/src/external-resources.qdoc b/doc/src/external-resources.qdoc index 7639324..1abeae9 100644 --- a/doc/src/external-resources.qdoc +++ b/doc/src/external-resources.qdoc @@ -455,6 +455,31 @@ */ /*! + \externalpage https://developer.mozilla.org/en/JavaScript/Reference/Reserved_Words + \title JavaScript Reserved Words +*/ + +/*! \externalpage http://publicsuffix.org/ \title publicsuffix.org */ + +/*! + \externalpage http://wiki.forum.nokia.com/index.php/Capabilities + \title Symbian Capabilities +*/ + +/*! + \externalpage http://wiki.forum.nokia.com/ + \title Forum Nokia Wiki +*/ + +/*! + \externalpage http://wiki.forum.nokia.com/index.php/UID_Q&As_(Symbian_Signed) + \title UID Q&As (Symbian Signed) +*/ + +/*! + \externalpage http://www.symbiansigned.com + \title Symbian Signed +*/ diff --git a/doc/src/files-and-resources/resources.qdoc b/doc/src/files-and-resources/resources.qdoc index ecf343d..35e6a90 100644 --- a/doc/src/files-and-resources/resources.qdoc +++ b/doc/src/files-and-resources/resources.qdoc @@ -130,7 +130,7 @@ In the application, this resource would be registered with code like this: - \snippet doc/src/snippets/code/doc_src_resources.qdoc 4 + \snippet doc/src/snippets/code/doc_src_resources.cpp 4 \section2 Compiled-In Resources @@ -205,7 +205,7 @@ Q_INIT_RESOURCE() with the base name of the \c .qrc file. For example: - \snippet doc/src/snippets/code/doc_src_resources.qdoc 5 + \snippet doc/src/snippets/code/doc_src_resources.cpp 5 Similarly, if you must unload a set of resources explicitly (because a plugin is being unloaded or the resources are not valid diff --git a/doc/src/frameworks-technologies/accessible.qdoc b/doc/src/frameworks-technologies/accessible.qdoc index 1d15dbd..e7bf171 100644 --- a/doc/src/frameworks-technologies/accessible.qdoc +++ b/doc/src/frameworks-technologies/accessible.qdoc @@ -256,7 +256,7 @@ variable set to 1. For example, this is set in the following way with the bash shell: - \snippet doc/src/snippets/code/doc_src_qt4-accessibility.qdoc environment + \snippet doc/src/snippets/code/doc_src_qt4-accessibility.cpp environment Accessibility features are built into Qt by default when the libraries are configured and built. diff --git a/doc/src/frameworks-technologies/activeqt-container.qdoc b/doc/src/frameworks-technologies/activeqt-container.qdoc index 436f375..862408b 100644 --- a/doc/src/frameworks-technologies/activeqt-container.qdoc +++ b/doc/src/frameworks-technologies/activeqt-container.qdoc @@ -67,7 +67,7 @@ To build Qt applications that can host COM objects and ActiveX controls link the application against the QAxContainer module by adding - \snippet doc/src/snippets/code/doc_src_qaxcontainer.qdoc 0 + \snippet doc/src/snippets/code/doc_src_qaxcontainer.pro 0 to your application's \c .pro file. @@ -128,7 +128,7 @@ want to use, or integrate it into the build system by adding the type libraries to the \c TYPELIBS variable in your application's \c .pro file: - \snippet doc/src/snippets/code/doc_src_qaxcontainer.qdoc 1 + \snippet doc/src/snippets/code/doc_src_qaxcontainer.pro 1 Note that \l dumpcpp might not be able to expose all APIs in the type library. diff --git a/doc/src/frameworks-technologies/activeqt-server.qdoc b/doc/src/frameworks-technologies/activeqt-server.qdoc index 9af2b65..77cacf8 100644 --- a/doc/src/frameworks-technologies/activeqt-server.qdoc +++ b/doc/src/frameworks-technologies/activeqt-server.qdoc @@ -60,10 +60,10 @@ An out-of-process executable server is generated from a \c .pro file like this: - \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 0 + \snippet doc/src/snippets/code/doc_src_qaxserver.pro 0 To build an in-process server, use a \c .pro file like this: - \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 1 + \snippet doc/src/snippets/code/doc_src_qaxserver.pro 1 The files \c qaxserver.rc and \c qaxserver.def are part of the framework and can be used from their usual location (specify a @@ -91,7 +91,7 @@ Additionally you can specify a version number using the \c VERSION variable, e.g. - \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 2 + \snippet doc/src/snippets/code/doc_src_qaxserver.pro 2 The version number specified will be used as the version of the type library and of the server when registering. @@ -186,12 +186,12 @@ or any existing QObject subclass. If the class is a subclass of QWidget, the COM object will be an ActiveX control. - \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 3 + \snippet doc/src/snippets/code/doc_src_qaxserver.cpp 3 The Q_OBJECT macro is required to provide the meta object information about the widget to the ActiveQt framework. - \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 4 + \snippet doc/src/snippets/code/doc_src_qaxserver.cpp 4 Use the Q_CLASSINFO() macro to specify the COM identifiers for the COM object. \c ClassID and \c InterfaceID are required, while \c EventsID is @@ -201,7 +201,7 @@ You can specify additional attributes for each of your classes; see \l{Class Information and Tuning} for details. - \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 5 + \snippet doc/src/snippets/code/doc_src_qaxserver.cpp 5 Use the Q_PROPERTY() macro to declare properties for the ActiveX control. @@ -216,7 +216,7 @@ your implementation of QAxFactory::create. \endfootnote - \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 6 + \snippet doc/src/snippets/code/doc_src_qaxserver.cpp 6 The ActiveQt framework will expose properties and public slots as ActiveX properties and methods, and signals as ActiveX events, and convert between @@ -428,7 +428,7 @@ To make the properties bindable for the ActiveX client, use multiple inheritance from the QAxBindable class: - \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 7 + \snippet doc/src/snippets/code/doc_src_qaxserver.cpp 7 When implementing the property write functions, use the QAxBindable class's requestPropertyChange() and propertyChanged() @@ -453,7 +453,7 @@ an implementation of a QAxFactory. The easist way to do this is to use a set of macros: - \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 8 + \snippet doc/src/snippets/code/doc_src_qaxserver.cpp 8 This will export \c MyWidget and \c MyWidget2 as COM objects that can be created by COM clients, and will register \c MySubType as a type that can @@ -470,7 +470,7 @@ server. Use QAxFactory::isServer() to create and run a standard application interface, or to prevent a stand-alone execution: - \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 9 + \snippet doc/src/snippets/code/doc_src_qaxserver.cpp 9 This is however not necessary as ActiveQt provides a default implementation of a main function. The default implemenation calls QAxFactory::startServer(), @@ -512,7 +512,7 @@ macro, the QAxFactory subclass had no appropriate constructor. Provide a public class constructor like - \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 10 + \snippet doc/src/snippets/code/doc_src_qaxserver.cpp 10 for your factory class. @@ -560,7 +560,7 @@ your installer process, resolve the \c DllRegisterServer symbol and call the function: - \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 11 + \snippet doc/src/snippets/code/doc_src_qaxserver.cpp 11 \section3 Distributing Servers over the Internet @@ -766,7 +766,7 @@ own API, and is available in the "Insert Objects" dialog of Microsoft Office applications. - \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 15 + \snippet doc/src/snippets/code/doc_src_qaxserver.cpp 15 \section2 Developing Licensed Components @@ -782,7 +782,7 @@ To mark a Qt class as licensed specify a "LicenseKey" using the Q_CLASSINFO() macro. - \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 16 + \snippet doc/src/snippets/code/doc_src_qaxserver.cpp 16 The key is required to be able to create an instance of \c MyLicensedControl on a machine that is not licensed itself. The licensed developer can now @@ -805,12 +805,12 @@ Create a new subclass of QAxAggregated and use multiple inheritance to subclass additional COM interface classes. - \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 17 + \snippet doc/src/snippets/code/doc_src_qaxserver.cpp 17 Reimplement the QAxAggregated::queryInterface() function to support the additional COM interfaces. - \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 18 + \snippet doc/src/snippets/code/doc_src_qaxserver.cpp 18 Since \c ISomeCOMInterface is a subclass of \c IUnknown you will have to implement the \c QueryInterface(), \c AddRef(), and \c @@ -820,7 +820,7 @@ returned by the QAxAggregated::controllingUnknown() function, e.g. - \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 19 + \snippet doc/src/snippets/code/doc_src_qaxserver.cpp 19 Do not support the \c IUnknown interface itself in your \l{QAxAggregated::queryInterface()}{queryInterface()} @@ -833,5 +833,5 @@ QAxBindable::createAggregate() to return a new object of the QAxAggregated subclass. - \snippet doc/src/snippets/code/doc_src_qaxserver.qdoc 20 + \snippet doc/src/snippets/code/doc_src_qaxserver.cpp 20 */ diff --git a/doc/src/frameworks-technologies/containers.qdoc b/doc/src/frameworks-technologies/containers.qdoc index 991588e..f28e5dc 100644 --- a/doc/src/frameworks-technologies/containers.qdoc +++ b/doc/src/frameworks-technologies/containers.qdoc @@ -205,7 +205,7 @@ Here's an example custom data type that meets the requirement of an assignable data type: - \snippet doc/src/snippets/code/doc_src_containers.qdoc 0 + \snippet doc/src/snippets/code/doc_src_containers.cpp 0 If we don't provide a copy constructor or an assignment operator, C++ provides a default implementation that performs a @@ -306,7 +306,7 @@ Here's a typical loop for iterating through all the elements of a QList<QString> in order and printing them to the console: - \snippet doc/src/snippets/code/doc_src_containers.qdoc 1 + \snippet doc/src/snippets/code/doc_src_containers.cpp 1 It works as follows: The QList to iterate over is passed to the QListIterator constructor. At that point, the iterator is located @@ -319,7 +319,7 @@ Here's how to iterate backward in a QList: - \snippet doc/src/snippets/code/doc_src_containers.qdoc 2 + \snippet doc/src/snippets/code/doc_src_containers.cpp 2 The code is symmetric with iterating forward, except that we start by calling \l{QListIterator::toBack()}{toBack()} @@ -358,7 +358,7 @@ QMutableListIterator. Here's an example where we remove all odd numbers from a QList<int> using QMutableListIterator: - \snippet doc/src/snippets/code/doc_src_containers.qdoc 3 + \snippet doc/src/snippets/code/doc_src_containers.cpp 3 The next() call in the loop is made every time. It jumps over the next item in the list. The @@ -368,13 +368,13 @@ the iterator, so it is safe to continue using it. This works just as well when iterating backward: - \snippet doc/src/snippets/code/doc_src_containers.qdoc 4 + \snippet doc/src/snippets/code/doc_src_containers.cpp 4 If we just want to modify the value of an existing item, we can use \l{QMutableListIterator::setValue()}{setValue()}. In the code below, we replace any value larger than 128 with 128: - \snippet doc/src/snippets/code/doc_src_containers.qdoc 5 + \snippet doc/src/snippets/code/doc_src_containers.cpp 5 Just like \l{QMutableListIterator::remove()}{remove()}, \l{QMutableListIterator::setValue()}{setValue()} operates on the @@ -387,7 +387,7 @@ operations, we don't even need \l{QMutableListIterator::setValue()}{setValue()}: - \snippet doc/src/snippets/code/doc_src_containers.qdoc 6 + \snippet doc/src/snippets/code/doc_src_containers.cpp 6 As mentioned above, QLinkedList's, QVector's, and QSet's iterator classes have exactly the same API as QList's. We will now turn to @@ -410,7 +410,7 @@ The following example removes all (capital, country) pairs where the capital's name ends with "City": - \snippet doc/src/snippets/code/doc_src_containers.qdoc 7 + \snippet doc/src/snippets/code/doc_src_containers.cpp 7 QMapIterator also provides a key() and a value() function that operate directly on the iterator and that return the key and @@ -418,7 +418,7 @@ example, the following code copies the contents of a QMap into a QHash: - \snippet doc/src/snippets/code/doc_src_containers.qdoc 8 + \snippet doc/src/snippets/code/doc_src_containers.cpp 8 If we want to iterate through all the items with the same value, we can use \l{QMapIterator::findNext()}{findNext()} @@ -426,7 +426,7 @@ Here's an example where we remove all the items with a particular value: - \snippet doc/src/snippets/code/doc_src_containers.qdoc 9 + \snippet doc/src/snippets/code/doc_src_containers.cpp 9 \section2 STL-Style Iterators @@ -473,7 +473,7 @@ Here's a typical loop for iterating through all the elements of a QList<QString> in order and converting them to lowercase: - \snippet doc/src/snippets/code/doc_src_containers.qdoc 10 + \snippet doc/src/snippets/code/doc_src_containers.cpp 10 Unlike \l{Java-style iterators}, STL-style iterators point directly at items. The begin() function of a container returns an @@ -493,7 +493,7 @@ decrement the iterator \e before we access the item. This requires a \c while loop: - \snippet doc/src/snippets/code/doc_src_containers.qdoc 11 + \snippet doc/src/snippets/code/doc_src_containers.cpp 11 In the code snippets so far, we used the unary \c * operator to retrieve the item (of type QString) stored at a certain iterator @@ -504,7 +504,7 @@ For read-only access, you can use const_iterator, constBegin(), and constEnd(). For example: - \snippet doc/src/snippets/code/doc_src_containers.qdoc 12 + \snippet doc/src/snippets/code/doc_src_containers.cpp 12 The following table summarizes the STL-style iterators' API: @@ -536,7 +536,7 @@ value() function to retrieve the value. For example, here's how we would print all items in a QMap to the console: - \snippet doc/src/snippets/code/doc_src_containers.qdoc 13 + \snippet doc/src/snippets/code/doc_src_containers.cpp 13 Thanks to \l{implicit sharing}, it is very inexpensive for a function to return a container per value. The Qt API contains @@ -545,7 +545,7 @@ using an STL iterator, you should always take a copy of the container and iterate over the copy. For example: - \snippet doc/src/snippets/code/doc_src_containers.qdoc 14 + \snippet doc/src/snippets/code/doc_src_containers.cpp 14 This problem doesn't occur with functions that return a const or non-const reference to a container. @@ -567,35 +567,35 @@ statement. For example, here's how to use \c foreach to iterate over a QLinkedList<QString>: - \snippet doc/src/snippets/code/doc_src_containers.qdoc 15 + \snippet doc/src/snippets/code/doc_src_containers.cpp 15 The \c foreach code is significantly shorter than the equivalent code that uses iterators: - \snippet doc/src/snippets/code/doc_src_containers.qdoc 16 + \snippet doc/src/snippets/code/doc_src_containers.cpp 16 Unless the data type contains a comma (e.g., \c{QPair<int, int>}), the variable used for iteration can be defined within the \c foreach statement: - \snippet doc/src/snippets/code/doc_src_containers.qdoc 17 + \snippet doc/src/snippets/code/doc_src_containers.cpp 17 And like any other C++ loop construct, you can use braces around the body of a \c foreach loop, and you can use \c break to leave the loop: - \snippet doc/src/snippets/code/doc_src_containers.qdoc 18 + \snippet doc/src/snippets/code/doc_src_containers.cpp 18 With QMap and QHash, \c foreach accesses the value component of the (key, value) pairs. If you want to iterate over both the keys and the values, you can use iterators (which are fastest), or you can write code like this: - \snippet doc/src/snippets/code/doc_src_containers.qdoc 19 + \snippet doc/src/snippets/code/doc_src_containers.cpp 19 For a multi-valued map: - \snippet doc/src/snippets/code/doc_src_containers.qdoc 20 + \snippet doc/src/snippets/code/doc_src_containers.cpp 20 Qt automatically takes a copy of the container when it enters a \c foreach loop. If you modify the container as you are @@ -611,12 +611,12 @@ In addition to \c foreach, Qt also provides a \c forever pseudo-keyword for infinite loops: - \snippet doc/src/snippets/code/doc_src_containers.qdoc 21 + \snippet doc/src/snippets/code/doc_src_containers.cpp 21 If you're worried about namespace pollution, you can disable these macros by adding the following line to your \c .pro file: - \snippet doc/src/snippets/code/doc_src_containers.qdoc 22 + \snippet doc/src/snippets/code/doc_src_containers.cpp 22 \section1 Other Container-Like Classes @@ -736,7 +736,7 @@ Consider the following code, which builds a QString from another QString: - \snippet doc/src/snippets/code/doc_src_containers.qdoc 23 + \snippet doc/src/snippets/code/doc_src_containers.cpp 23 We build the string \c out dynamically by appending one character to it at a time. Let's assume that we append 15000 characters to diff --git a/doc/src/frameworks-technologies/dbus-adaptors.qdoc b/doc/src/frameworks-technologies/dbus-adaptors.qdoc index 7494f2d..82545db 100644 --- a/doc/src/frameworks-technologies/dbus-adaptors.qdoc +++ b/doc/src/frameworks-technologies/dbus-adaptors.qdoc @@ -85,14 +85,14 @@ using an adaptor. A sample usage of QDBusAbstractAdaptor is as follows: - \snippet doc/src/snippets/code/doc_src_qdbusadaptors.qdoc 0 + \snippet doc/src/snippets/code/doc_src_qdbusadaptors.cpp 0 The code above would create an interface that could be represented more or less in the following canonical representation: - \snippet doc/src/snippets/code/doc_src_qdbusadaptors.qdoc 1 + \snippet doc/src/snippets/code/doc_src_qdbusadaptors.cpp 1 This adaptor could be used in the application's main function as follows - \snippet doc/src/snippets/code/doc_src_qdbusadaptors.qdoc 2 + \snippet doc/src/snippets/code/doc_src_qdbusadaptors.cpp 2 Break-down analysis: \tableofcontents @@ -100,7 +100,7 @@ \section1 The header The header of the example is: - \snippet doc/src/snippets/code/doc_src_qdbusadaptors.qdoc 3 + \snippet doc/src/snippets/code/doc_src_qdbusadaptors.cpp 3 The code does the following: \list @@ -112,10 +112,10 @@ \section1 The properties The properties are declared as follows: - \snippet doc/src/snippets/code/doc_src_qdbusadaptors.qdoc 4 + \snippet doc/src/snippets/code/doc_src_qdbusadaptors.cpp 4 And are implemented as follows: - \snippet doc/src/snippets/code/doc_src_qdbusadaptors.qdoc 5 + \snippet doc/src/snippets/code/doc_src_qdbusadaptors.cpp 5 The code declares three properties: one of them is a read-write property called "caption" of string type. The other two are read-only, also of the string type. @@ -129,7 +129,7 @@ \section1 The constructor The constructor: - \snippet doc/src/snippets/code/doc_src_qdbusadaptors.qdoc 6 + \snippet doc/src/snippets/code/doc_src_qdbusadaptors.cpp 6 The constructor does the following: \list @@ -149,7 +149,7 @@ \section1 Slots/methods The public slots in the example (which will be exported as D-Bus methods) are the following: - \snippet doc/src/snippets/code/doc_src_qdbusadaptors.qdoc 7 + \snippet doc/src/snippets/code/doc_src_qdbusadaptors.cpp 7 This snippet of code defines 4 methods with different properties each: \list 1 @@ -176,7 +176,7 @@ \section1 Signals The signals in this example are defined as follows: - \snippet doc/src/snippets/code/doc_src_qdbusadaptors.qdoc 8 + \snippet doc/src/snippets/code/doc_src_qdbusadaptors.cpp 8 However, signal definition isn't enough: signals have to be emitted. One simple way of emitting signals is to connect another signal to them, so that Qt's signal handling system chains them @@ -187,7 +187,7 @@ When simple signal-to-signal connection isn't enough, one can use a private slot do do some work. This is what was done for the mainWindowHasFocus signal: - \snippet doc/src/snippets/code/doc_src_qdbusadaptors.qdoc 9 + \snippet doc/src/snippets/code/doc_src_qdbusadaptors.cpp 9 This private slot (which will not be exported as a method via D-Bus) was connected to the \c focusChanged signal in the adaptor's constructor. It is therefore able to shape the @@ -291,7 +291,7 @@ \l{QDBusMessage::setDelayedReply()}{QDBusMessage::setDelayedReply(true)} that the response will be sent later. - \snippet doc/src/snippets/code/doc_src_qdbusadaptors.qdoc 10 + \snippet doc/src/snippets/code/doc_src_qdbusadaptors.cpp 10 The use of \l{QDBusConnection::send()}{QDBusConnection::sessionBus().send(data->reply)} @@ -303,7 +303,7 @@ using the \c QDBusMessage object that was obtained. In our example, the reply code could be something as follows: - \snippet doc/src/snippets/code/doc_src_qdbusadaptors.qdoc 11 + \snippet doc/src/snippets/code/doc_src_qdbusadaptors.cpp 11 As can be seen in the example, when a delayed reply is in place, the return value(s) from the slot will be ignored by QtDBus. They @@ -473,7 +473,7 @@ You can use this macro in your own adaptors by placing it before your method's return value (which must be "void") in the class declaration, as shown in the example: - \snippet doc/src/snippets/code/doc_src_qdbusadaptors.qdoc 12 + \snippet doc/src/snippets/code/doc_src_qdbusadaptors.cpp 12 Its presence in the method implementation (outside the class declaration) is optional. diff --git a/doc/src/frameworks-technologies/graphicsview.qdoc b/doc/src/frameworks-technologies/graphicsview.qdoc index f689446..1903df5 100644 --- a/doc/src/frameworks-technologies/graphicsview.qdoc +++ b/doc/src/frameworks-technologies/graphicsview.qdoc @@ -95,7 +95,7 @@ descending stacking order (i.e., the first returned item is topmost, and the last item is bottom-most). - \snippet doc/src/snippets/code/doc_src_graphicsview.qdoc 0 + \snippet doc/src/snippets/code/doc_src_graphicsview.cpp 0 QGraphicsScene's event propagation architecture schedules scene events for delivery to items, and also manages propagation between items. If @@ -126,7 +126,7 @@ enable OpenGL support, you can set a QGLWidget as the viewport by calling QGraphicsView::setViewport(). - \snippet doc/src/snippets/code/doc_src_graphicsview.qdoc 1 + \snippet doc/src/snippets/code/doc_src_graphicsview.cpp 1 The view receives input events from the keyboard and mouse, and translates these to scene events (converting the coordinates used @@ -333,7 +333,7 @@ Here is an example of how to implement zoom and rotate slots in a subclass of QGraphicsView: - \snippet doc/src/snippets/code/doc_src_graphicsview.qdoc 2 + \snippet doc/src/snippets/code/doc_src_graphicsview.cpp 2 The slots could be connected to \l{QToolButton}{QToolButtons} with \l{QAbstractButton::autoRepeat}{autoRepeat} enabled. @@ -353,7 +353,7 @@ a QPainter to either of the rendering functions. This example shows how to print the whole scene into a full page, using QPrinter. - \snippet doc/src/snippets/code/doc_src_graphicsview.qdoc 3 + \snippet doc/src/snippets/code/doc_src_graphicsview.cpp 3 The difference between the scene and view rendering functions is that one operates in scene coordinates, and the other in view coordinates. @@ -364,7 +364,7 @@ is to render the exact contents of the viewport using the provided painter. - \snippet doc/src/snippets/code/doc_src_graphicsview.qdoc 4 + \snippet doc/src/snippets/code/doc_src_graphicsview.cpp 4 When the source and target areas' sizes do not match, the source contents are stretched to fit into the target area. By passing a @@ -390,7 +390,7 @@ so in mousePressEvent() or mouseMoveEvent(), you can get the originating widget pointer from the event. For example: - \snippet doc/src/snippets/code/doc_src_graphicsview.qdoc 5 + \snippet doc/src/snippets/code/doc_src_graphicsview.cpp 5 To intercept drag and drop events for the scene, you reimplement QGraphicsScene::dragEnterEvent() and whichever event handlers your @@ -449,7 +449,7 @@ Example: - \snippet doc/src/snippets/code/doc_src_graphicsview.qdoc 6 + \snippet doc/src/snippets/code/doc_src_graphicsview.cpp 6 \section2 Item Groups diff --git a/doc/src/frameworks-technologies/implicit-sharing.qdoc b/doc/src/frameworks-technologies/implicit-sharing.qdoc index 8938d9e..46567e9 100644 --- a/doc/src/frameworks-technologies/implicit-sharing.qdoc +++ b/doc/src/frameworks-technologies/implicit-sharing.qdoc @@ -109,7 +109,7 @@ data in all member functions that change the internal data. Code fragment: - \snippet doc/src/snippets/code/doc_src_groups.qdoc 0 + \snippet doc/src/snippets/code/doc_src_groups.cpp 0 \section1 List of Classes @@ -124,7 +124,7 @@ concern for the copying overhead. Example: - \snippet doc/src/snippets/code/doc_src_groups.qdoc 1 + \snippet doc/src/snippets/code/doc_src_groups.cpp 1 In this example, \c p1 and \c p2 share data until QPainter::begin() is called for \c p2, because painting a pixmap will modify it. diff --git a/doc/src/frameworks-technologies/model-view-programming.qdoc b/doc/src/frameworks-technologies/model-view-programming.qdoc index 92067b9..58b51e5 100644 --- a/doc/src/frameworks-technologies/model-view-programming.qdoc +++ b/doc/src/frameworks-technologies/model-view-programming.qdoc @@ -32,7 +32,7 @@ /*! \page model-view-programming.html - \ingroup qt-basic-concepts + \ingroup qt-basic-concepts \title Model/View Programming \brief A guide to Qt's extensible model/view architecture. @@ -328,7 +328,7 @@ contain a pointer to the model that created them, and this prevents confusion when working with more than one model. - \snippet doc/src/snippets/code/doc_src_model-view-programming.qdoc 0 + \snippet doc/src/snippets/code/doc_src_model-view-programming.cpp 0 Model indexes provide \e temporary references to pieces of information, and can be used to retrieve or modify data via the model. Since models may @@ -355,7 +355,7 @@ item by specifying its row and column numbers to the model, and we receive an index that represents the item: - \snippet doc/src/snippets/code/doc_src_model-view-programming.qdoc 1 + \snippet doc/src/snippets/code/doc_src_model-view-programming.cpp 1 Models that provide interfaces to simple, single level data structures like lists and tables do not need any other information to be provided but, as @@ -371,7 +371,7 @@ index that refers to an item of data by passing the relevant row and column numbers to the model. - \snippet doc/src/snippets/code/doc_src_model-view-programming.qdoc 2 + \snippet doc/src/snippets/code/doc_src_model-view-programming.cpp 2 Top level items in a model are always referenced by specifying \c QModelIndex() as their parent item. This is discussed in the next @@ -392,7 +392,7 @@ about the item's parent. Outside the model, the only way to refer to an item is through a model index, so a parent model index must also be given: - \snippet doc/src/snippets/code/doc_src_model-view-programming.qdoc 3 + \snippet doc/src/snippets/code/doc_src_model-view-programming.cpp 3 \table \row \i \inlineimage modelview-treemodel.png @@ -403,12 +403,12 @@ Items "A" and "C" are represented as top-level siblings in the model: - \snippet doc/src/snippets/code/doc_src_model-view-programming.qdoc 4 + \snippet doc/src/snippets/code/doc_src_model-view-programming.cpp 4 Item "A" has a number of children. A model index for item "B" is obtained with the following code: - \snippet doc/src/snippets/code/doc_src_model-view-programming.qdoc 5 + \snippet doc/src/snippets/code/doc_src_model-view-programming.cpp 5 \endtable \section3 Item roles @@ -423,7 +423,7 @@ corresponding to the item, and by specifying a role to obtain the type of data we want: - \snippet doc/src/snippets/code/doc_src_model-view-programming.qdoc 6 + \snippet doc/src/snippets/code/doc_src_model-view-programming.cpp 6 \table \row \i \inlineimage modelview-roles.png diff --git a/doc/src/frameworks-technologies/phonon.qdoc b/doc/src/frameworks-technologies/phonon.qdoc index 1456eae6..9eb56ea 100644 --- a/doc/src/frameworks-technologies/phonon.qdoc +++ b/doc/src/frameworks-technologies/phonon.qdoc @@ -165,7 +165,7 @@ The \c .pro file for a project needs the following line to be added: - \snippet doc/src/snippets/code/doc_src_phonon.qdoc 0 + \snippet doc/src/snippets/code/doc_src_phonon.pro 0 Phonon comes with several widgets that provide functionality commonly associated with multimedia players - notably SeekSlider diff --git a/doc/src/frameworks-technologies/plugins-howto.qdoc b/doc/src/frameworks-technologies/plugins-howto.qdoc index b332d57..15b1547 100644 --- a/doc/src/frameworks-technologies/plugins-howto.qdoc +++ b/doc/src/frameworks-technologies/plugins-howto.qdoc @@ -109,12 +109,12 @@ straightforward, here is the class definition (\c mystyleplugin.h): - \snippet doc/src/snippets/code/doc_src_plugins-howto.qdoc 0 + \snippet doc/src/snippets/code/doc_src_plugins-howto.cpp 0 Ensure that the class implementation is located in a \c .cpp file (including the class definition): - \snippet doc/src/snippets/code/doc_src_plugins-howto.qdoc 1 + \snippet doc/src/snippets/code/doc_src_plugins-howto.cpp 1 (Note that QStylePlugin is case insensitive, and the lower-case version of the key is used in our @@ -127,7 +127,7 @@ you might want to set a style explicitly in code. To apply a style, use code like this: - \snippet doc/src/snippets/code/doc_src_plugins-howto.qdoc 2 + \snippet doc/src/snippets/code/doc_src_plugins-howto.cpp 2 Some plugin classes require additional functions to be implemented. See the class documentation for details of the @@ -284,12 +284,12 @@ the required plugins to your build using \c QTPLUGIN. For example, in your \c main.cpp: - \snippet doc/src/snippets/code/doc_src_plugins-howto.qdoc 4 + \snippet doc/src/snippets/code/doc_src_plugins-howto.cpp 4 In the \c .pro file for your application, you need the following entry: - \snippet doc/src/snippets/code/doc_src_plugins-howto.qdoc 5 + \snippet doc/src/snippets/code/doc_src_plugins-howto.pro 5 It is also possible to create your own static plugins, by following these steps: diff --git a/doc/src/frameworks-technologies/qthelp.qdoc b/doc/src/frameworks-technologies/qthelp.qdoc index 42bc482..f4d75b6 100644 --- a/doc/src/frameworks-technologies/qthelp.qdoc +++ b/doc/src/frameworks-technologies/qthelp.qdoc @@ -218,7 +218,7 @@ we get the actual help contents by calling fileData() and display the document to the user. - \snippet doc/src/snippets/code/doc_src_qthelp.qdoc 6 + \snippet doc/src/snippets/code/doc_src_qthelp.cpp 6 For further information on how to use the API, have a look at the QHelpEngine class reference. diff --git a/doc/src/frameworks-technologies/richtext.qdoc b/doc/src/frameworks-technologies/richtext.qdoc index 089f84d..313cf46 100644 --- a/doc/src/frameworks-technologies/richtext.qdoc +++ b/doc/src/frameworks-technologies/richtext.qdoc @@ -145,11 +145,11 @@ Although QTextEdit makes it easy to display and edit rich text, documents can also be used independently of any editor widget, for example: - \snippet doc/src/snippets/code/doc_src_richtext.qdoc 0 + \snippet doc/src/snippets/code/doc_src_richtext.cpp 0 Alternatively, they can be extracted from an existing editor: - \snippet doc/src/snippets/code/doc_src_richtext.qdoc 1 + \snippet doc/src/snippets/code/doc_src_richtext.cpp 1 This flexibility enables applications to handle multiple rich text documents without the overhead of multiple editor widgets, or requiring @@ -728,24 +728,24 @@ A text editor widget can be constructed and used to display HTML in the following way: - \snippet doc/src/snippets/code/doc_src_richtext.qdoc 2 + \snippet doc/src/snippets/code/doc_src_richtext.cpp 2 By default, the text editor contains a document with a root frame, inside which is an empty text block. This document can be obtained so that it can be modified directly by the application: - \snippet doc/src/snippets/code/doc_src_richtext.qdoc 3 + \snippet doc/src/snippets/code/doc_src_richtext.cpp 3 The text editor's cursor may also be used to edit a document: - \snippet doc/src/snippets/code/doc_src_richtext.qdoc 4 + \snippet doc/src/snippets/code/doc_src_richtext.cpp 4 Although a document can be edited using many cursors at once, a QTextEdit only displays a single cursor at a time. Therefore, if we want to update the editor to display a particular cursor or its selection, we need to set the editor's cursor after we have modified the document: - \snippet doc/src/snippets/code/doc_src_richtext.qdoc 5 + \snippet doc/src/snippets/code/doc_src_richtext.cpp 5 \section1 Selecting Text @@ -833,7 +833,7 @@ We give an example of the latter technique from the list. We assume that the text edit is visible. - \snippet doc/src/snippets/code/doc_src_richtext.qdoc 6 + \snippet doc/src/snippets/code/doc_src_richtext.cpp 6 \omit Ideas for other sections: diff --git a/doc/src/frameworks-technologies/unicode.qdoc b/doc/src/frameworks-technologies/unicode.qdoc index b4a9347..d2a6500 100644 --- a/doc/src/frameworks-technologies/unicode.qdoc +++ b/doc/src/frameworks-technologies/unicode.qdoc @@ -125,12 +125,12 @@ QString provides implicit casting from \c{const char *} so that things like - \snippet doc/src/snippets/code/doc_src_unicode.qdoc 0 + \snippet doc/src/snippets/code/doc_src_unicode.cpp 0 will work. There is also a function, QObject::tr(), that provides translation support, like this: - \snippet doc/src/snippets/code/doc_src_unicode.qdoc 1 + \snippet doc/src/snippets/code/doc_src_unicode.cpp 1 QObject::tr() maps from \c{const char *} to a Unicode string, and uses installable QTranslator objects to do the mapping. @@ -151,11 +151,11 @@ fast functions for mapping to and from them. For example, to open an application's icon one might do this: - \snippet doc/src/snippets/code/doc_src_unicode.qdoc 2 + \snippet doc/src/snippets/code/doc_src_unicode.cpp 2 or - \snippet doc/src/snippets/code/doc_src_unicode.qdoc 3 + \snippet doc/src/snippets/code/doc_src_unicode.cpp 3 Regarding output, Qt will do a best-effort conversion from Unicode to whatever encoding the system and fonts provide. diff --git a/doc/src/getting-started/examples.qdoc b/doc/src/getting-started/examples.qdoc index ad97836..ede8a5b 100644 --- a/doc/src/getting-started/examples.qdoc +++ b/doc/src/getting-started/examples.qdoc @@ -699,6 +699,7 @@ /*! \page examples-linguist.html \ingroup all-examples + \ingroup internationalization \title Qt Linguist Examples \brief Using Qt Linguist to internationalize your Qt application. diff --git a/doc/src/getting-started/gettingstartedqml.qdoc b/doc/src/getting-started/gettingstartedqml.qdoc index ccb9771..8054fc8 100644 --- a/doc/src/getting-started/gettingstartedqml.qdoc +++ b/doc/src/getting-started/gettingstartedqml.qdoc @@ -631,7 +631,7 @@ Now that we have our text editor layout, we may now implement the text editor functionalities in C++. Using QML with C++ enables us to create our application logic using Qt. We can create a QML context in a C++ application using the - \l {Using QML in C++ Applications}{Qt's Declarative} classes and display the QML + \l {Using QML Bindings in C++ Applications}{Qt's Declarative} classes and display the QML elements using a Graphics Scene. Alternatively, we can export our C++ code into a plugin that the \l {QML Viewer}{qmlviewer} tool can read. For our application, we shall implement the load and save functions in C++ and export it as a plugin. diff --git a/doc/src/getting-started/how-to-learn-qt.qdoc b/doc/src/getting-started/how-to-learn-qt.qdoc index 239c8a1..8d9508b 100644 --- a/doc/src/getting-started/how-to-learn-qt.qdoc +++ b/doc/src/getting-started/how-to-learn-qt.qdoc @@ -51,7 +51,7 @@ key overviews to deepen your understanding of Qt: The Qt \l{Object Model} and \l{Signals and Slots}. - \div{float-left} + \div {class="float-left"} \inlineimage qtdemo-small.png \enddiv diff --git a/doc/src/getting-started/installation.qdoc b/doc/src/getting-started/installation.qdoc index 6d0256e..26ccf88 100644 --- a/doc/src/getting-started/installation.qdoc +++ b/doc/src/getting-started/installation.qdoc @@ -1009,78 +1009,113 @@ We hope you will enjoy using Qt. \image x11_dependencies.png Qt for X11 Dependencies - \raw HTML - <style type="text/css" id="colorstyles"> - #QtGuiColor { background-color: #98fd00; color: black } - #QtCoreColor { background-color: #9c9cff; color: black } - #DefaultColor { background-color: #f6f6dc; color: black } - #FreetypeColor { background-color: #e6e6fa; color: black } - #GLColor { background-color: #ffc0cb; color: black } - #PthreadColor { background-color: #bdb76b; color: black } - #OptionalColor { background-color: #cae1ff; color: black } - #SMColor { background-color: #c2fafa; color: black } - #MiscColor { background-color: #f0f9ff; color: black } - #GlibColor { background-color: #b3b3b3; color: black } - </style> - \endraw - The QtGui module and the QtCore module, which provides the non-GUI features required by QtGui, depend on the libraries described in the following table. To build Qt from its source code, you will also need to install the development packages for these libraries for your system. - \raw HTML - <table class="generic"> - <thead><tr class="qt-style topAlign"><th>Name</th><th>Library</th><th>Notes</th><th>Configuration options</th><th>Minimum working version - <tr id="OptionalColor"> - <td> XRender </td><td> libXrender </td><td> X Rendering Extension; used for anti-aliasing</td> - <td><tt>-xrender</tt> or auto-detected</td><td>0.9.0</td> - </tr><tr id="OptionalColor"> - <td> Xrandr </td><td> libXrandr </td><td> X Resize and Rotate Extension</td> - <td><tt>-xrandr</tt> or auto-detected</td><td>1.0.2</td> - </tr><tr id="OptionalColor"> - <td> Xcursor </td><td> libXcursor </td><td> X Cursor Extension</td> - <td><tt>-xcursor</tt> or auto-detected</td><td>1.1.4</td> - </tr><tr id="OptionalColor"> - <td> Xfixes </td><td> libXfixes </td><td> X Fixes Extension</td> - <td><tt>-xfixes</tt> or auto-detected</td><td>3.0.0</td> - </tr><tr id="OptionalColor"> - <td> Xinerama </td><td> libXinerama </td><td> Multi-head support</td> - <td><tt>-xinerama</tt> or auto-detected</td><td>1.1.0</td> - - </tr><tr id="OptionalColor"> - <td> Fontconfig </td><td> libfontconfig </td><td> Font customization and configuration</td> - <td><tt>-fontconfig</tt> or auto-detected</td><td>2.1</td> - </tr><tr id="OptionalColor"> - <td> FreeType </td><td> libfreetype </td><td> Font engine</td> - <td></td><td>2.1.3</td> - - </tr><tr id="DefaultColor"> - <td> Xi </td><td> libXi </td><td> X11 Input Extensions</td> - <td><tt>-xinput</tt> or auto-detected</td><td>1.3.0</td> - </tr><tr id="DefaultColor"> - <td> Xt </td><td> libXt </td><td> Xt Intrinsics</td><td></td><td>0.99</td> - </tr><tr id="DefaultColor"> - <td> Xext </td><td> libXext </td><td> X Extensions</td><td></td><td>6.4.3</td> - </tr><tr id="DefaultColor"> - <td> X11 </td><td> libX11 </td><td> X11 Client-Side Library</td><td></td><td>6.2.1</td> - - </tr><tr id="SMColor"> - <td> SM </td><td> libSM </td><td> X Session Management</td> - <td><tt>-sm</tt> or auto-detected</td><td>6.0.4</td> - </tr><tr id="SMColor"> - <td> ICE </td><td> libICE </td><td> Inter-Client Exchange</td> - <td><tt>-sm</tt> or auto-detected</td><td>6.3.5</td> - - </tr><tr id="GlibColor"> - <td> glib </td><td> libglib-2.0 </td><td> Common event loop handling</td> - <td><tt>-glib</tt> or auto-detected</td><td>2.8.3</td> - </tr><tr id="PthreadColor"> - <td> pthread </td><td> libpthread </td><td> Multithreading</td> - <td></td><td>2.3.5</td> - </tr></th></tr></thead> - </table> - \endraw + \table 100% + \header + \o Name + \o Library + \o Notes + \o Configuration options + \o Minimum working version + \row {id="OptionalColor"} + \o XRender + \o libXrender + \o X Rendering Extension; used for anti-aliasing + \o \tt{-xrender} or auto-detected + \o 0.9.0 + \row {id="OptionalColor"} + \o Xrandr + \o libXrandr + \o X Resize and Rotate Extension + \o \tt{-xrandr} or auto-detected + \o 1.0.2 + \row {id="OptionalColor"} + \o Xcursor + \o libXcursor + \o X Cursor Extension + \o \tt{-xcursor} or auto-detected + \o 1.1.4 + \row {id="OptionalColor"} + \o Xfixes + \o libXfixes + \o X Fixes Extension + \o \tt{-xfixes} or auto-detected + \o 3.0.0 + \row {id="OptionalColor"} + \o Xinerama + \o libXinerama + \o Multi-head support + \o \tt{-xinerama} or auto-detected + \o 1.1.0 + + \row {id="OptionalColor"} + \o Fontconfig + \o libfontconfig + \o Font customization and configuration + \o \tt{-fontconfig} or auto-detected + \o 2.1 + \row {id="OptionalColor"} + \o FreeType + \o libfreetype + \o Font engine + \o + \o 2.1.3 + + \row {id="DefaultColor"} + \o Xi + \o libXi + \o X11 Input Extensions + \o \tt{-xinput} or auto-detected + \o 1.3.0 + \row {id="DefaultColor"} + \o Xt + \o libXt + \o Xt Intrinsics + \o + \o 0.99 + \row {id="DefaultColor"} + \o Xext + \o libXext + \o X Extensions + \o + \o 6.4.3 + \row {id="DefaultColor"} + \o X11 + \o libX11 + \o X11 Client-Side Library + \o + \o 6.2.1 + + \row {id="SMColor"} + \o SM + \o libSM + \o X Session Management + \o \tt{-sm} or auto-detected + \o 6.0.4 + \row {id="SMColor"} + \o ICE + \o libICE + \o Inter-Client Exchange + \o \tt{-sm} or auto-detected + \o 6.3.5 + + \row {id="GlibColor"} + \o glib + \o libglib-2.0 + \o Common event loop handling + \o \tt{-glib} or auto-detected + \o 2.8.3 + \row {id="PthreadColor"} + \o pthread + \o libpthread + \o Multithreading + \o + \o 2.3.5 + \endtable \note You must compile with XRender support to get alpha transparency support for pixmaps and images. @@ -1142,7 +1177,7 @@ We hope you will enjoy using Qt. \brief Setting up the Windows CE environment for Qt. \previouspage General Qt Requirements - Qt is known to work with Visual Studio 2005/2008 and the following SDKs for + Qt is known to work with Visual Studio 2005/2008/2010 and the following SDKs for Windows CE development on Windows XP and Windows Vista: \list @@ -1180,14 +1215,37 @@ We hope you will enjoy using Qt. \endlist \endtable - Device manufacturers may prefer to make their own customized version of Windows CE using Platform Builder. In order for Qt for Windows CE to support a custom SDK, a build specification needs to be created. More information on Windows CE Customization can be found \l{Windows CE - Working with Custom SDKs}{here}. - \sa {Known Issues} + \section3 Requirements + \list + \o Development environment: + \list + \o Microsoft Visual Studio 2005 (Standard Edition) or higher + \o ActivePerl + \endlist + \o Footprint + \list + \o Lean configuration - 4.8 MB + \o Full configuration - 8.4 MB + \endlist + \o Operating Systems + \list + \o Windows CE 5 or higher + \o Windows Mobile 5 or higher + \endlist + \o Hardware Platform + \list + \o Supported on ARM, x86 + \o (Compiles on SH4 and MIPS) + \endlist + \endlist + + \sa {Known Issues} */ /*! @@ -1332,7 +1390,7 @@ We hope you will enjoy using Qt. load those that have a matching <key>. \o \row \o \c {-release } \o Compile and link Qt with debugging turned off. \o \row \o \c {-debug } \o Compile and link Qt with debugging turned on. - \o Defualt value. + \o Default value. \row \o \c {-debug-and-release} \o Compile and link two Qt libraries, with and without debugging turned on. \o This option denotes a default value and needs to be evaluated. If the evaluation succeeds, the @@ -1343,28 +1401,28 @@ We hope you will enjoy using Qt. of Qt. \o \row \o \c {-developer-build} \o Compile and link Qt with Qt developer options including auto-tests exporting) \o - \row \o \c {-shared} \o Create and use shared Qt libraries. \o Defualt + \row \o \c {-shared} \o Create and use shared Qt libraries. \o Default value. \row \o \c {-static} \o Create and use static Qt libraries. \o \row \o \c {-ltcg} \o Use Link Time Code Generation. \o Apply to release builds only. - \row \o \c {-no-ltcg} \o Do not use Link Time Code Generation. \o Defualt + \row \o \c {-no-ltcg} \o Do not use Link Time Code Generation. \o Default value. \row \o \c {-no-fast} \o Configure Qt normally by generating Makefiles for - all project files. \o Defualt value. + all project files. \o Default value. \row \o \c {-fast} \o Configure Qt quickly by generating Makefiles only for library and subdirectory targets. \o All other Makefiles are created as wrappers which will in turn run qmake. \row \o \c {-no-exceptions} \o Disable exceptions on platforms that support it. \o \row \o \c {-exceptions} \o Enable exceptions on platforms that support it. - \o Defualt value. + \o Default value. \row \o \c {-no-accessibility} \o Do not compile Windows Active Accessibility support. \o \row \o \c {-accessibility} \o Compile Windows Active Accessibility - support. \o Defualt value. + support. \o Default value. \row \o \c {-no-stl} \o Do not compile STL support. \o - \row \o \c {-stl} \o Compile STL support. \o Defualt value. + \row \o \c {-stl} \o Compile STL support. \o Default value. \row \o \c {-no-sql-<driver>} \o Disable SQL <driver> entirely, by default none are turned on. \o \row \o \c {-qt-sql-<driver>} \o Enable a SQL <driver> in the Qt Library. @@ -1380,14 +1438,14 @@ We hope you will enjoy using Qt. version. \o Available values for <api>: desktop - Enable support for Desktop OpenGL (Default), es1 - Enable support for OpenGL ES Common Profile, es2 - Enable support for OpenGL ES 2.0. - \row \o \c {-no-openvg} \o Disables OpenVG functionality \o Defualt value. + \row \o \c {-no-openvg} \o Disables OpenVG functionality \o Default value. \row \o \c {-openvg} \o Enables OpenVG functionality \o Requires EGL support, typically supplied by an OpenGL or other graphics implementation. \row \o \c {-platform <spec> } \o The operating system and compiler you are building on. \o The default value is %QMAKESPEC%. \row \o \c {-xplatform <spec> } \o The operating system and compiler you - are cross compiling to. \o See the README file for a list of supported + are cross compiling for. \o See the README file for a list of supported operating systems and compilers. \row \o \c {-qtnamespace <namespace>} \o Wraps all Qt library code in 'namespace name {..} \o @@ -1399,7 +1457,7 @@ We hope you will enjoy using Qt. \row \o \c {-L <librarypath>} \o Add an explicit library path. \o \row \o \c {-l <libraryname>} \o Add an explicit library name, residing in a librarypath. \o - \row \o \c {-graphicssystem <sys>} \o Specify which graphicssystem should + \row \o \c {-graphicssystem <sys>} \o Specify which graphics system should be used. \o Available values for <sys>: * raster - Software rasterizer, opengl - Using OpenGL acceleration, experimental!, openvg - Using OpenVG acceleration, experimental! @@ -1428,7 +1486,7 @@ We hope you will enjoy using Qt. succeeds, the feature is included. \row \o \c {-qt-libmng} \o Use the libmng bundled with Qt. \o \row \o \c {-system-libmng} \o Use libmng from the operating system. - \o See See http://www.libmng.com + \o See http://www.libmng.com \row \o \c {-no-libtiff} \o Do not compile TIFF support. \o This option denotes a default value and needs to be evaluated. If the evaluation succeeds, the feature is included. @@ -1450,10 +1508,10 @@ We hope you will enjoy using Qt. \header \o Option \o Description \o Note \row \o \c {-no-dsp} \o Do not generate VC++ .dsp files. \o \row \o \c {-dsp} \o Generate VC++ .dsp files, only if spec "win32-msvc". - \o Defualt value. + \o Default value. \row \o \c {-no-vcproj} \o Do not generate VC++ .vcproj files. \o \row \o \c {-vcproj} \o Generate VC++ .vcproj files, only if platform - "win32-msvc.net". \o Defualt value. + "win32-msvc.net". \o Default value. \row \o \c {-no-incredibuild-xge} \o Do not add IncrediBuild XGE distribution commands to custom build steps. \o \row \o \c {-incredibuild-xge} \o Add IncrediBuild XGE distribution commands @@ -1464,14 +1522,14 @@ We hope you will enjoy using Qt. If the evaluation succeeds, the feature is included. \row \o \c {-no-plugin-manifests} \o Do not embed manifests in plugins. \o \row \o \c {-plugin-manifests} \o Embed manifests in plugins. - \o Defualt value. + \o Default value. \row \o \c {-no-qmake} \o Do not compile qmake. \o - \row \o \c {-qmake} \o Compile qmake. \o Defualt value + \row \o \c {-qmake} \o Compile qmake. \o Default value \row \o \c {-dont-process} \o Do not generate Makefiles/Project files. This will override -no-fast if specified. \o - \row \o \c {-process} \o Generate Makefiles/Project files. \o Defualt value. + \row \o \c {-process} \o Generate Makefiles/Project files. \o Default value. \row \o \c {-no-rtti} \o Do not compile runtime type information. \o - \row \o \c {-rtti} \o Compile runtime type information. \o Defualt value. + \row \o \c {-rtti} \o Compile runtime type information. \o Default value. \row \o \c {-no-mmx} \o Do not compile with use of MMX instructions \o \row \o \c {-mmx} \o Compile with use of MMX instructions \o This option denotes a default value and needs to be evaluated. If the evaluation @@ -1506,9 +1564,9 @@ We hope you will enjoy using Qt. \row \o \c {-no-phonon-backend} \o Do not compile the platform-specific Phonon backend-plugin \o \row \o \c {-phonon-backend} \o Compile in the platform-specific Phonon - backend-plugin \o Defualt value. + backend-plugin \o Default value. \row \o \c {-no-multimedia} \o Do not compile the multimedia module \o - \row \o \c {-multimedia} \o Compile in multimedia module \o Defualt value. + \row \o \c {-multimedia} \o Compile in multimedia module \o Default value. \row \o \c {-no-audio-backend} \o Do not compile in the platform audio backend into QtMultimedia \o \row \o \c {-audio-backend} \o Compile in the platform audio backend into @@ -1536,7 +1594,7 @@ We hope you will enjoy using Qt. \row \o \c {-no-declarative-debug} \o Do not build the declarative debugging support \o \row \o \c {-declarative-debug} \o Build the declarative debugging support - \o Defualt value. + \o Default value. \row \o \c {-arch <arch>} \o Specify an architecture. \o Available values for <arch>: * windows, windowsce, symbian, boundschecker, generic. \row \o \c {-no-style-<style>} \o Disable <style> entirely. \o @@ -1547,9 +1605,9 @@ We hope you will enjoy using Qt. \row \o \c {-no-native-gestures} \o Do not use native gestures on Windows 7. \o \row \o \c {-native-gestures} \o Use native gestures on Windows 7. - \o Defualt value. + \o Default value. \row \o \c {-no-mp} \o Do not use multiple processors for compiling with MSVC - \o Defualt value. + \o Default value. \row \o \c {-mp} \o Use multiple processors for compiling with MSVC (-MP) \o \row \o \c {-loadconfig <config>} \o Run configure with the parameters from file configure_<config>.cache. \o @@ -1566,7 +1624,7 @@ We hope you will enjoy using Qt. for Qt for Windows CE on Arm only. This option denotes a default value and needs to be evaluated. If the evaluation succeeds, the feature is included. \row \o \c {-no-crt} \o Do not add the C runtime to default deployment rules. - \o Defualt value. + \o Default value. \row \o \c {-qt-crt} \o Qt identifies C runtime during project generation \o \row \o \c {-crt <path>} \o Specify path to C runtime used for project generation. \o @@ -1576,20 +1634,20 @@ We hope you will enjoy using Qt. succeeds, the feature is included. \row \o \c {-signature <file>} \o Use file for signing the target project \o \row \o \c {-phonon-wince-ds9} \o Enable Phonon Direct Show 9 backend for - Windows CE \o Defualt value + Windows CE \o Default value \endtable \section2 Qt for Symbian OS only: \table \header \o Option \o Description \o Note \row \o \c {-no-freetype} \o Do not compile in Freetype2 support. - \o Defualt value. + \o Default value. \row \o \c {-qt-freetype} \o Use the libfreetype bundled with Qt. \o \row \o \c {-fpu <flags>} \o VFP type on ARM, supported options: softvfp(default) |vfpv2 | softvfp+vfpv2 \o \row \o \c {-no-s60} \o Do not compile in S60 support. \o \row \o \c {-s60} \o Compile with support for the S60 UI Framework - \o Defualt value. + \o Default value. \row \o \c {-no-usedeffiles} \o Disable the usage of DEF files. \o \row \o \c {-usedeffiles} \o Enable the usage of DEF files. \o \endtable diff --git a/doc/src/getting-started/tutorials.qdoc b/doc/src/getting-started/tutorials.qdoc index 5cde056..9fc6699 100644 --- a/doc/src/getting-started/tutorials.qdoc +++ b/doc/src/getting-started/tutorials.qdoc @@ -61,7 +61,7 @@ \o{2,1} \l{A Quick Start to Qt Designer}{\bold{Qt Designer}} \o{2,1} \l{Qt Linguist Manual: Programmers#Tutorials}{\bold {Qt Linguist}} \row - \o \image designer-examples.png QtDesigner + \o \image designer-examples.png \o A quick guide through \QD showing the basic steps to create a form with this interactive tool. @@ -72,17 +72,18 @@ tools provided for developers, translators and release managers. - \row +\row \o{2,1} \l{modelview.html}{\bold{ModelView}} - \o{2,1} - + \o{2,1} \l{thread-basics.html}{\bold {Threads}} \row \o \image treeview_sml.png ModelView - \o This tutorial gives an introduction to ModelView programming using the Qt cross-platform framework - \o + This tutorial gives an introduction to ModelView programming using the Qt cross-platform framework + + \o \image threads-examples.png Threads \o - + A short tutorial about thread concepts in general and basic Qt classes to handle threads. + \row \o{2,1} \l{QML Tutorial}{\bold QML Tutorial} \o{2,1} \l{QML Advanced Tutorial}{\bold SameGame} diff --git a/doc/src/howtos/appicon.qdoc b/doc/src/howtos/appicon.qdoc index 86934bc..6d86b22 100644 --- a/doc/src/howtos/appicon.qdoc +++ b/doc/src/howtos/appicon.qdoc @@ -62,7 +62,7 @@ Finally, assuming you are using \c qmake to generate your makefiles, add this line to your \c myapp.pro file: - \snippet doc/src/snippets/code/doc_src_appicon.qdoc 1 + \snippet doc/src/snippets/code/doc_src_appicon.pro 1 Regenerate your makefile and your application. The \c .exe file will now be represented with your icon in Explorer. @@ -96,7 +96,7 @@ if the name of your icon file is \c{myapp.icns}, and your project file is \c{myapp.pro}, add this line to \c{myapp.pro}: - \snippet doc/src/snippets/code/doc_src_appicon.qdoc 2 + \snippet doc/src/snippets/code/doc_src_appicon.pro 2 This will ensure that \c qmake puts your icons in the proper place and creates an \c{Info.plist} entry for the icon. @@ -213,6 +213,6 @@ icon file is \c{myapp.svg}, and your project file is \c{myapp.pro}, add this line to \c{myapp.pro}: - \snippet doc/src/snippets/code/doc_src_appicon.qdoc 5 + \snippet doc/src/snippets/code/doc_src_appicon.pro 5 */ diff --git a/doc/src/howtos/developmentsteps.qdoc b/doc/src/howtos/developmentsteps.qdoc new file mode 100644 index 0000000..e898bf5 --- /dev/null +++ b/doc/src/howtos/developmentsteps.qdoc @@ -0,0 +1,186 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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:FDL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Free Documentation License +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of this +** file. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! +\page qtdevelopment-steps.html +\title Qt Development: The Steps from Challenge to Achievement + +\section1 The Challenge + +One day, your boss runs into your cubicle and exclaims to you, "The board blew +millions on a new enterprise HelloWorld application. The new one does not work +and we need a solution quickly before this disaster brings down the company! I'm +putting you in charge of the whole project while I go on vacation -- see you in +2 weeks." + +\section1 Brainstorming Ideas - It is time to play! + +Never one to shy away from a challenge (especially when your job might be on the +line), you first set out try come up with an idea about what your options are. + +You ask around a bit and discover that the broken application was intended to +replace one that has been living on a dusty mainframe for the past 25 years. The +machine is nearing end of life and, rather than invest in replacement hardware +to run a legacy HelloWorld program, the board decided to invest in new software +that could be run on desktops, web, mobile devices and embedded into the +company's main product line -- a pocket size device with a small LCD screen, +which flashes the message "Hello World" every full moon. + +The vendor that was chosen to handle this task was a well known multinational +company that specialized in enterprise CRM/ERP systems. The project missed +several delivery deadlines over a 2 year period, and was 500% over budget. There +was not going to be much margin for error trying to fix the problem, and there +would likely be no budget either. + +You begin researching dozens of possible possible approaches to the problem. One +of the biggest challenges is that there are very few options that will allow you +to create native applications that use the same framework for targeting +\l{qt-creator-configure-target}{multiple platforms}. + +Some years ago you had coded a small desktop application using the Qt framework, +without realizing that it also can be used for targeting the web, mobile devices +and embedded devices. Since that time, Qt has added a new feature called \l{Qt +Quick}, which provides the ability to easily design applications with intuitive, +modern-looking, fluid user interfaces. + +\section1 Creating an Objective + +You quickly realize that you might need two, three, or more interfaces for your +application -- one for each of the target platforms you are aiming for. +Thankfully Qt has options well suited for each of them. + +For your mobile application the choice seems obvious enough. The new Qt Quick +technology looks very promising, but you do not know QML; the declarative +language that helps define the interface in a Qt Quick program. You still want +to give it a try, but worry that you might not have something complete before +your boss returns from vacation in two weeks. You also wonder if Qt Quick is +applicable to desktop and embedded targets -- and then of course there is the +need for something targeting the web. You decide to give Qt Quick a try first +and \l{QML Examples and Demos}{see where it takes you}. + +\section1 Developing Plans + +One thing you realize after reading up on \l{Qt Quick} is that things are very +different from the desktop when designing an interface. Qt Quick doesn't contain +ready made UI 'chrome'; the widgets and other design elements that define the +application interface. A new technology, called Qt Quick Components, looks like +a promising solution, but the components will only be available at a later date. +For now you'll have to come up with something on your own -- but you are keen to +give your design skills a work out, and learning to use Qt Quick seems to be a +great way to do it. + +Not knowing a better place to start, you begin by taking a cue from web design +and plan a wireframe, which helps +\l{http://doc.qt.nokia.com/qtcreator-snapshot/creator-visual-editor.html}{define the application layout}, +content and user interaction. You decide on breaking the field of the screen +space into three roughly equal size parts. There will be one section across the +top, which will span the width of the screen, and two sections in the lower +have, which will be approximately as tall as the top section is wide (when in +portrait mode). + +The top section will be a simple text representation of the phrase "Hello World" +in English. In the lower left you would like to place some kind of audio +playback feature that repeats back the phrase in the top section of the screen. +Finally, in the lower right hand side of the screen will be four links to +similar views for additional languages -- Mandarin Chinese, Brazilian +Portuguese, Arabic, and Russian. When the user clicks one of the links the text +at the top is then translated, and the playback corresponds to the appropriate +language. + +While the wireframe is effective in dealing with one part of the design +challenge, it does not cover visual aspects other than layout and content. This +means that you still need to define colours, white space, and typography (among +other things). This is where a style guide would come in handy, if your company +already had one that is. In the absence of one you decide to again get some +inspiration from the web, and you mimic some of the company's website design +into your application -- a sans-serif font for white text on a blue field across +the top, black text on white for the bottom two sections, and a small company +logo to the left of the "Hello World" message. + + +\section1 Execution: The Coding Begins! + +At long last you sit down to \l{qt-technologies}{implement} your plans and +designs. The first few steps go according to plan, and creating the basic layout +and text goes fairly smoothly -- but you run into a few challenges quite +quickly: + +Devising a user friendly interface to audio playback is not as intuitive as you +first thought. Since there exist a ready made component for +\l{http://doc.qt.nokia.com/qtmobility-1.1.0/qml-multimedia.html}{multimedia}, +you remove the bottom left field and now have the screen split in two. You add +textual links for each of the five target languages, and when the user clicks +one of them the message text changes and the appropriate audio plays back. It is +a small sacrifice to make for now, and you are sure there is a solution to be +found once you have become more proficient with QML. + +The next challenge you run into is that \l{qt-deployment}{deploying} the +application to a Symbian phone is not as clearly understood as you expected. +Again you are sure there is something you are missing, but for the time being +you manually copy the .sis file to the "Installs" directory on the phone +(connected to the development machine by USB) and then install it through the +Application Manager. + +When you finally manage to install the application on the device you notice +something that looks rather peculiar, and something you had not thought of. When +the phone is turned into landscape mode, your text remains at the same absolute +coordinates as when it was in portrait mode. You had not realized you needed to +anchor it in order to achieve the centering you wanted. There was an +\l{qt-testing}{easy fix} for this, but you were glad you saw this earlier rather +than later. + + +\section1 Innovating + +After the ups and downs of learning to develop a basic application +using Qt Quick, you start to see greater possibilities for using Qt technologies +for your current and future projects: + +\list +\o Extending HTML5 based applications that tie Javascript to a Qt C++ back end +using \l{Qt WebKit} +\o An \l{qt-rendering-painting-system}{OpenGL} based UI for embedded platforms +\o \l{Gestures Programming}{Touch} screen support +\o \l{http://doc.qt.nokia.com/qtmobility-1.1.0/location-overview.html}{Location} based applications +\o \l{qt-technologies}{Much, much more} +\endlist + + +\section1 The Achievement + +After your boss returned from vacation you presented him with the finished Qt +Quick application, demonstrating it on both a mobile device as well as desktop +(it happened to work well on both with little modification). You also provided +him a presentation that detailed your road map for taking things to the next +level -- targeting other platforms, such as the web, as well as improving on the +existing application you just completed. + +Even though the final product did not turn out the way you originally planned, +your boss was still sufficiently impressed. Not only was the go ahead given for +future projects, but ramping up a small team of developers and designers was +also suggested to help support your efforts. + +*/ diff --git a/doc/src/howtos/exceptionsafety.qdoc b/doc/src/howtos/exceptionsafety.qdoc index c4b5ebc..b3795d6 100644 --- a/doc/src/howtos/exceptionsafety.qdoc +++ b/doc/src/howtos/exceptionsafety.qdoc @@ -100,8 +100,9 @@ if any allocation fails. Allocations can fail if the system runs out of memory or doesn't have enough continuous memory to allocate the requested size. - Exceptions to that rule are documented. As an example, \l QImage::create() - returns false if not enough memory exists instead of throwing an exception. + Exceptions to that rule are documented. As an example, QImage constructors will + create a \l{QImage::isNull()}{null} image if not enough memory exists instead + of throwing an exception. \section1 Recovering from exceptions diff --git a/doc/src/howtos/qmlbestpractices/qmlbestpractices-coding.qdoc b/doc/src/howtos/qmlbestpractices/qmlbestpractices-coding.qdoc new file mode 100644 index 0000000..246c4e4 --- /dev/null +++ b/doc/src/howtos/qmlbestpractices/qmlbestpractices-coding.qdoc @@ -0,0 +1,97 @@ +/**************************************************************************** +** +** 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:FDL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Free Documentation License +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of this +** file. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! +\page qml-best-practices-coding.html +\ingroup qml-best-practices +\contentspage QML Best Practices Guides +\previouspage QML Best Practices Guides +\startpage QML Best Practices Guides +\title QML Best Practices: Coding Conventions + +\brief QML Coding Conventions and Importing Files + +There are many different ways to code using QML. These are a set of +guidelines to help your code look better and consistent. + +\section1 Coding Conventions + +The official QML Coding Conventions may be found at +\l {QML Coding Conventions}. This is the recommended convention that will be +used throughout the QML documentation. + +In addition, Qt's official code style may be found at the \l {Qt Coding Style}. + +\section1 Importing Files into QML + +To import items such as directories, use the "import" keyword, similar to +the way the \c {import QtQuick 1.0} statement is used. + +\snippet doc/src/snippets/declarative/imports/best-practices.qml imports + +To facilitate the import of QML components, it is best to begin the QML +file with an uppercase character. This way, the user can simply declare the +component using the file name as the component name. For example, if a QML +component is in a file named \c Button.qml, then the user may import the +component by declaring a \c {Button {}}. Note that this method only works if +the QML files are in the same directory. + +It is also possible to import QML files which have file names that begin in +lower case or files in a different directory by using a \c qmldir file. + +A \c qmldir file tells your QML application which QML components, plugins, +or directories to import. The \c qmldir file must reside in an imported +directory. By using the \c qmldir file, users may import any QML file and assign any +valid QML component name to the component. + +For more information, read the section on +\l{qml-loading-components}{Loading a Component}. + +\section1 Commenting Code + +Commenting code allows others to read the source code better. As well, comments +allow the programmer to think about his or her code; a confusing comment may +mean the code is confusing. + +Similar to JavaScript or C++, there are two ways of commenting QML code: +\list +\o Single line comments start with \c{//} and finish at the end of the line +\o Multiline comments start with \c{/*} and finish with *\/ +\endlist + +\section1 Group Properties + +Many QML properties are \l{attached-properties}{attached} or +\l {qml-grouped-properties}{group} properties. For convenience, you may treat +them as another element when dealing with multiple properties belonging to the +same group. + +\snippet doc/src/snippets/declarative/bestpractices/group.qml not grouped +Treating groups of properties as a block can ease confusion and help relate the +properties with other properties. +\snippet doc/src/snippets/declarative/bestpractices/group.qml grouped +*/ diff --git a/doc/src/howtos/qmlbestpractices/qmlbestpractices-datatypes.qdoc b/doc/src/howtos/qmlbestpractices/qmlbestpractices-datatypes.qdoc new file mode 100644 index 0000000..0f6d74b --- /dev/null +++ b/doc/src/howtos/qmlbestpractices/qmlbestpractices-datatypes.qdoc @@ -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:FDL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Free Documentation License +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of this +** file. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ +/*! + \page qml-best-practices-datatypes.html + \ingroup qml-best-practices + \contentspage QML Best Practices Guides + \previouspage QML Best Practices Guides + \startpage QML Best Practices Guides + \title QML Best Practices: Data Types + + \brief Using Basic Data Types and Custom Types in QML + + QML supports many basic data types, Qt data types, and custom data types. + + \section1 Basic Data Types + + \section1 Qt Data Types + + \section1 Exporting Qt Types to QML + + Programmers may create C++ data structures and expose them to QML, making + data accessible from QML. + + \section2 Using QStringLists in QML +*/ diff --git a/doc/src/howtos/scalabilityintro.qdoc b/doc/src/howtos/scalabilityintro.qdoc new file mode 100644 index 0000000..5b4e58b --- /dev/null +++ b/doc/src/howtos/scalabilityintro.qdoc @@ -0,0 +1,324 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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:FDL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Free Documentation License +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of this +** file. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \title Scalability + \page scalability.html + \preliminary + + \omit preliminary docs for next SDK release \endomit + \omit Somewhere I need to mention applications with more than + one page (top-level layouts). \endomit + + A scalable application is an application that can run on more than + one form factor. In particular, it can cope with different screen + sizes, DPI, and aspect ratios. You need to consider scalability + when: + + \list + \o your application will be deployed to more than one device + handset, or more than one device form factor. + \o your application will be deployed for a long period of time, + so that new device handsets might appear on the market after + your initial deployment. + \endlist + + This document discusses how scalable applications can be created. + + \section1 Developing Scalable UIs + + This section shows the basics of how we advice scalable + applications to be implemented using QML. We recommend that you + follow these techniques: + + \list + \o Create separate top-level layout + definitions for each form factor. + \o Keep the layouts small and let components + scale relative to their immediate parent. + \o Define device independent measurements, such as dp + (device independent pixels), and use + these to scale components and for layout measurement. + \o Define layouts in a + proportional way using the built-in layout features of QML. + \endlist + + Using small top-level layouts makes your codebase smaller and + easier to maintain. Also, components that scales relative to their + parent are more reusable. The layouts should be children of the + application's root item. You can change between them by, for + instance, using the opacity property of Item; that is, if your + application has more tham one top-level layout. Such a top-level + layout is also often referred to as a page, i.e., a layout that + uses the entire screen. For instance, an organizer application + will typically have separate pages for showing the calender and + editing todo items. + + You should define the measurements separate from the UI, for + instance by using a JavaScript object that you fill in with a + script on application start up. + + QML provides several ways of laying out components, e.g, using + anchor based layout, the more classic Grid; Column; and Row + elements, and by setting the dimensions of Items directly. When + laying out components in scalable applications, you should + generally prefer using anchors and set width and height based on + parent size where possible. Layouts are not only relevant to + top-level layouts; components often contain child Items. + + The following sections describe in more detail the different + aspects of scalability that should be considered in order to + achieve the desired level of flexibility within your application. + + \section1 Implementing the Top-Level Layouts + + As mentioned, each application should use separate top-level + layout QML definitions to support separate layout configurations / + form factors. + + Consider an application that has to be deployed to at least two + devices, which both have very different screen sizes and DPI + values. The two form factors of the application will share many + common components and attributes, and will most likely connect to + the same data model. + + Therefore, the top-level definitions should be quite + straightforward and short, with the majority of the functionality + refactored into contained Components. It is important to try to + avoid unnecessary duplication between these top-level definitions, + in order to improve maintainability. + + There are some patterns that you might consider when designing + your top level layouts: + + \list + \o In some cases, the contents of an entire page in a smaller + handset could form a component element of a layout in a + larger device. Therefore, consider making that a separate + component (i.e. defined in a separate QML file), and in the + smaller handset, the Page will simply contain an instance of + that component. On the larger device, there may be enough + space to show two separate items. For example, in an email + viewer, if the screen is large enough, it may be possible to + show the email list view, and the email reader view side by + side. + \o In some cases, the contents of a view might be quite similar + on all screen sizes, but with an expanded content area. In + this case, it may be possible to re-use the same layout + definition, if defined appropriately using anchors. + \endlist + + The \l{Loader} component can be used to load separate QML files + based on some criteria, such as Device Profile (configuration of + screen pixel resolution and DPI density). In the case of form + factor, this information will not change during the application's + lifetime, therefore there is no issue with memory usage or + performance. + + \section1 Defining Measurements + + When you are defining the measurements within an application or + component layout, there are a number aspects to consider: + + \list + \o The layout structure, the high-level relationship between + items. Which item is the parent? How are the items arranged + relatively on the screen? Are they in a grid or column? + \o The layout measurements. How big is an item, or a margin + inside the edge of an item, or an anchor between items? + \o The implicit size of contained items. Some child items will + require a certain amount of space, such as a button + containing a text. That may also depend on the current + platform and style. How do you ensure that you leave enough + space, and what happens if your children change size? + \endlist + + These aspects combine together to resolve the final layout for a + given Device Profile. However, although there are dependencies + between them, it is important to manage and control the different + aspects separately. + + It is strongly recommended that Layout measurements should be + stored in a separate place from the component layout structure + definition files. The reason for this is that layout structure, + for a given form factor, can be re-used for different Device + Profiles. However, measurements will almost always vary between + Device Profiles or Device Categories. + + If the opposite approach (complete duplication of entire QML + files) was taken, then all of the layout states and structure + definitions would be duplicated between the copied QML files, and + only the measurement values would change. + + The main benefit of using separate measurement definition files + are: + + \list + \o To reduce the amount of duplication, and hence increase + maintainability. + \o It becomes much easier to change the layout structure, + perhaps due to subsequent specification changes. In that + case, the layout structure can be modified once, and many or + all of the layout measurements would remain unchanged. + \o It becomes much easier to add support for additional Device + Profiles, simply by adding another measurement definition + file. + \endlist + + \section1 Using QML's Layout Features + + For a given form factor, top-level Layouts structure definitions, + or component layout structure definitions, should in general be + defined in a proportional way using a combination of + + \list + \o \l{Item::anchors.top}{anchors} within an Item + \o \l{Row} / \l{Column} / \l{Grid} + \o simple javascript expressions such as width: Math.round(parent.width / 3.0). + \endlist + + These basic building blocks, along with the powerful evaluation + capabilities of javascript expressions within every QML binding, + are designed to allow the majority of the layout structure + definition to be defined in a Device Profile independent way. + + There are some limitations of the basic grid type layouts. They + are designed to accommodate a number of Items, but use the current + sizes of those items. There is a similar issue with the basic + anchor type layout. In particular, it can be difficult to spread a + number of child items proportionately across an area of their + container. + + By combining the features of the layout managers with simple + javascript expressions, a richer variety of designs can be + expressed, without having to resort to additional layout + measurement parameters or measurement values. + + Here are some things not to do with layouts: + + \list + \o Don't define complex javascript functions that are regularly + evaluated. This will cause poor performance, particularly + during animated transitions. + \o Don't define all of your layouts using x, y, width and + height. Reserve this for items that cannot easily be defined + using anchors (anchors are evaluated in a more efficient + way). + \o Don't make assumptions about the container size, or about + the size of child items. Try to make flexible layout + definitions that can absorb changes in the available space. + \endlist + + \section1 Orientation Switches + + Application top-level page definitions, and reusable component + definitions, should use one QML layout definition for the layout + structure. This single definition should include the layout design + for separate Device Orientations and Aspect Ratios. The reason for + this is that performance during an orientation switch is critical, + and it is therefore a good idea to ensure that all of the + components needed by both orientations are loaded when the + orientation changes. + + On the contrary, you should perform thorough tests if you choose + to use a \l{Loader} to load additional QML that is needed in separate + orientations, as this will affect the performance of the + orientation change. + + In order to enable layout animations between the orientations, the + anchor definitions must reside within the same containing + component. Therefore the structure of a page or a component + should consist of a common set of child components, a common set + of anchor definitions, and a collection of states (defined in a + StateGroup) representing the different aspect ratios supported by + the component. (However note that orientation change animations + are not possible on Symbian due to compatibility support for S60 + applications). + + If a component contained within a page needs to be + hosted in numerous different form factor definitions, then the + layout states of the view should depend on the aspect ratio of the + page (its immediate container). Similarly, different instances of + a component might be situated within numerous different containers + in a UI, and so its layout states should be determined by the + aspect ratio of its parent. The conclusion is that layout states + should always follow the aspect ratio of the direct container (not + the "orientation" of the current device screen). + + Within each layout \l{State}, you should define the relationships + between items using native QML layout definitions. See below for + more information. During transitions between the states (triggered + by the top level orientation change), in the case of anchor + layouts, AnchorAnimation elements can be used to control the + transitions. In some cases, you can also use a NumberAnimation on + e.g. the width of an item. Remember to avoid complex javascript + calculations during each frame of animation. Using simple anchor + definitions and anchor animations can help with this in the + majority of cases. + + There are a few additional cases to consider: + + \list + \o What if you have a single page that looks completely + different between landscape and portrait, i.e. all of the + child items are different? For each page, have two child + components, with separate layout definitions, and make one + or other of the items have zero opacity in each state. You + can use a cross-fade animation by simply applying a + NumberAnimation transition to the opacity. + \o What if you have a single page that shares 30% or more of + the same layout contents between portrait and landscape? In + that case, consider having one component with landscape and + portrait states, and a collection of separate child items + whose opacity (or position) depends on the orientation + state. This will enable you to use layout animations for the + items that are shared between the orientations, whilst the + other items are either faded in/out, or animated on/off + screen. + \o What if you have two pages on a handheld device that need to + be on screen at the same time, for example on a larger form + factor device? In this case, notice that your view component + will no longer be occupying the full screen. Therefore it's + important to remember in all components (in particular, list + delegate items) should depend on the size of the containing + component width, not on the screen width. It may be + necessary to set the width in a Component.onCompleted() + handler in this case, to ensure that the list item delegate + has been constructed before the value is set. + \o What if the two orientations take up too much memory to have + them both in memory at once? Use a \l{Loader} if necessary, if + you cannot keep both versions of the view in memory at once, + but beware performance on the cross-fade animation during + layout switch. One solution could be to have two "splash + screen" items that are children of the Page, then you cross + fade between those during rotation. Then you can use a + \l{Loader} to load another child component that loads the actual + model data to another child Item, and cross-fade to that + when the \l{Loader} has completed. + \endlist + */ + diff --git a/doc/src/howtos/unix-signal-handlers.qdoc b/doc/src/howtos/unix-signal-handlers.qdoc index 2fa558e..20beb38 100644 --- a/doc/src/howtos/unix-signal-handlers.qdoc +++ b/doc/src/howtos/unix-signal-handlers.qdoc @@ -59,7 +59,7 @@ sigaction(2) man pages before plowing through the following code snippets. - \snippet doc/src/snippets/code/doc_src_unix-signal-handlers.qdoc 0 + \snippet doc/src/snippets/code/doc_src_unix-signal-handlers.cpp 0 In the MyDaemon constructor, use the socketpair(2) function to initialize each file descriptor pair, and then create the @@ -68,24 +68,24 @@ appropriate slot function, which effectively converts the Unix signal to the QSocketNotifier::activated() signal. - \snippet doc/src/snippets/code/doc_src_unix-signal-handlers.qdoc 1 + \snippet doc/src/snippets/code/doc_src_unix-signal-handlers.cpp 1 Somewhere else in your startup code, you install your Unix signal handlers with sigaction(2). - \snippet doc/src/snippets/code/doc_src_unix-signal-handlers.qdoc 2 + \snippet doc/src/snippets/code/doc_src_unix-signal-handlers.cpp 2 In your Unix signal handlers, you write a byte to the \e write end of a socket pair and return. This will cause the corresponding QSocketNotifier to emit its activated() signal, which will in turn cause the appropriate Qt slot function to run. - \snippet doc/src/snippets/code/doc_src_unix-signal-handlers.qdoc 3 + \snippet doc/src/snippets/code/doc_src_unix-signal-handlers.cpp 3 In the slot functions connected to the QSocketNotifier::activated() signals, you \e read the byte. Now you are safely back in Qt with your signal, and you can do all the Qt stuff you weren'tr allowed to do in the Unix signal handler. - \snippet doc/src/snippets/code/doc_src_unix-signal-handlers.qdoc 4 + \snippet doc/src/snippets/code/doc_src_unix-signal-handlers.cpp 4 */ diff --git a/doc/src/images/guide.png b/doc/src/images/guide.png Binary files differnew file mode 100644 index 0000000..f4b0df1 --- /dev/null +++ b/doc/src/images/guide.png diff --git a/doc/src/images/listview-decorations.png b/doc/src/images/listview-decorations.png Binary files differnew file mode 100644 index 0000000..445c648 --- /dev/null +++ b/doc/src/images/listview-decorations.png diff --git a/doc/src/images/listview-section.png b/doc/src/images/listview-section.png Binary files differnew file mode 100644 index 0000000..a3664fc --- /dev/null +++ b/doc/src/images/listview-section.png diff --git a/doc/src/images/listview-setup.png b/doc/src/images/listview-setup.png Binary files differnew file mode 100644 index 0000000..5293d05 --- /dev/null +++ b/doc/src/images/listview-setup.png diff --git a/doc/src/images/mobile.png b/doc/src/images/mobile.png Binary files differnew file mode 100644 index 0000000..af460e2 --- /dev/null +++ b/doc/src/images/mobile.png diff --git a/doc/src/images/qml-dial.png b/doc/src/images/qml-dial.png Binary files differdeleted file mode 100644 index da5c031..0000000 --- a/doc/src/images/qml-dial.png +++ /dev/null diff --git a/doc/src/images/qml-intro-anchors1.png b/doc/src/images/qml-intro-anchors1.png Binary files differdeleted file mode 100644 index fdb301e..0000000 --- a/doc/src/images/qml-intro-anchors1.png +++ /dev/null diff --git a/doc/src/images/qml-intro-anchors2.png b/doc/src/images/qml-intro-anchors2.png Binary files differdeleted file mode 100644 index 84f43bd..0000000 --- a/doc/src/images/qml-intro-anchors2.png +++ /dev/null diff --git a/doc/src/images/qml-intro-anchors3.png b/doc/src/images/qml-intro-anchors3.png Binary files differdeleted file mode 100644 index 21ae97b..0000000 --- a/doc/src/images/qml-intro-anchors3.png +++ /dev/null diff --git a/doc/src/images/qml-intro-helloa.png b/doc/src/images/qml-intro-helloa.png Binary files differdeleted file mode 100644 index 00b34b0..0000000 --- a/doc/src/images/qml-intro-helloa.png +++ /dev/null diff --git a/doc/src/images/qml-listview-snippet.png b/doc/src/images/qml-listview-snippet.png Binary files differdeleted file mode 100644 index 0ee0ffc..0000000 --- a/doc/src/images/qml-listview-snippet.png +++ /dev/null diff --git a/doc/src/images/qml.png b/doc/src/images/qml.png Binary files differnew file mode 100644 index 0000000..b1e4ab6 --- /dev/null +++ b/doc/src/images/qml.png diff --git a/doc/src/images/qmldesigner-visual-editor.png b/doc/src/images/qmldesigner-visual-editor.png Binary files differnew file mode 100644 index 0000000..9cd4b8b --- /dev/null +++ b/doc/src/images/qmldesigner-visual-editor.png diff --git a/doc/src/images/qt-logo_large.png b/doc/src/images/qt-logo_large.png Binary files differnew file mode 100644 index 0000000..4e230bd --- /dev/null +++ b/doc/src/images/qt-logo_large.png diff --git a/doc/src/images/qtcreator-target-selector.png b/doc/src/images/qtcreator-target-selector.png Binary files differnew file mode 100644 index 0000000..1f26138 --- /dev/null +++ b/doc/src/images/qtcreator-target-selector.png diff --git a/doc/src/images/thread_clock.png b/doc/src/images/thread_clock.png Binary files differnew file mode 100644 index 0000000..b8a8aa0 --- /dev/null +++ b/doc/src/images/thread_clock.png diff --git a/doc/src/images/threads-examples.png b/doc/src/images/threads-examples.png Binary files differnew file mode 100644 index 0000000..b6e4bcc --- /dev/null +++ b/doc/src/images/threads-examples.png diff --git a/doc/src/images/threadvisual-example.png b/doc/src/images/threadvisual-example.png Binary files differnew file mode 100644 index 0000000..2a49874 --- /dev/null +++ b/doc/src/images/threadvisual-example.png diff --git a/doc/src/images/tools.png b/doc/src/images/tools.png Binary files differnew file mode 100644 index 0000000..4d717b5 --- /dev/null +++ b/doc/src/images/tools.png diff --git a/doc/src/index.qdoc b/doc/src/index.qdoc index be59c2f..079a03b 100644 --- a/doc/src/index.qdoc +++ b/doc/src/index.qdoc @@ -26,94 +26,141 @@ ****************************************************************************/ /*! - \page index.html - \keyword Qt Reference Documentation +\page index.html +\keyword Qt Reference Documentation - \div {indexbox guide} - \div {heading} - Qt Developer Guide - \enddiv - \div {indexboxcont indexboxbar} - \div {section indexIcon} \emptyspan - \enddiv - \div {section} - Qt is a cross-platform application and UI - framework. Using Qt, you can write web-enabled - applications once and deploy them across desktop, - mobile and embedded operating systems without - rewriting the source code. - \enddiv - \div {section sectionlist} - \list - \o \l{Getting Started Guides}{Getting started} - \o \l{Installation}{Installation} - \o \l{how-to-learn-qt.html}{How to learn Qt} - \o \l{tutorials.html}{Tutorials} - \o \l{Qt Examples}{Examples} - \o \l{qt4-7-intro.html}{What's new in Qt 4.7} - \endlist - \enddiv +\div {class="indexbox guide"} + \div {class="heading"} + Qt Developer Guide + \enddiv +\enddiv +\div {class="indexbox tools"} + \div {class="indexboxcont indexboxbar"} + \div {class="sectionlist normallist"} + \div {class="heading"} + What is Qt + \enddiv + \image qt-logo_large.png + Qt is a cross-platform application and UI framework. Using Qt, you can + write applications once and deploy them across desktop, mobile, and + embedded operating systems without rewriting the source code. + \enddiv + \div {class="sectionlist normallist"} + \list + \o \l{http://doc.qt.nokia.com/nokia-qtsdk-1.0/index.html}{Qt SDK} + \o \l{http://developer.qt.nokia.com/wiki/QtCreatorWhitepaper}{Qt Creator} + \o \l{http://doc.qt.nokia.com/qtsimulator-1.1/index.html}{Qt Simulator} + \endlist + \list + \o \l{http://developer.qt.nokia.com/wiki/QtWhitepaper}{Qt C++ Framework} + \o \l{Qt Quick} + \o \l{http://doc.qt.nokia.com/qtmobility-1.1.0/index.html}{Qt Mobility} + \o \l{Qt WebKit} + \endlist + \list + \o \l{Supported Platforms}{Platform Support} + \o \l{What's New in Qt 4.7} - latest release + \endlist + \enddiv + \div {class="sectionlist normallist"} + \div {class="heading"} + See Qt \enddiv - \enddiv - \div {indexbox api} - \div {heading} - Qt API - \enddiv - \div {indexboxcont indexboxbar } - \div {sectionlist tricol} - \list - \o \l{All Classes}{All Classes} - \o \l{All Functions}{All Functions} - \o \l{All Modules}{All Modules} - \o \l{All Namespaces}{All Namespaces} - \o \l{Global Qt Declarations}{Global Declarations} - \o \l{Qt Licenses and Credits}{Licenses and Credits} - \endlist - \enddiv - \div {sectionlist tricol} - \list - \o \l{Programming with Qt} - \o \l{UI Design with Qt} - \o \l{Cross-Platform and Platform-Specific Development} - \o \l{Qt and Key Technologies} - \o \l{Best Practice Guides} - \endlist - \enddiv - \div {sectionlist} - \list - \o \l{qtquick.html}{Qt Quick} - \o \l{qdeclarativeintroduction.html}{Introduction to QML} - \o \l{qdeclarativeelements.html}{QML Elements} - \o \l{qdeclarativeexamples.html}{QML Examples and Demos} - \endlist - \enddiv + \image mobile.png + \list + \o \l{Qt Demonstrations}{Application Gallery} + \o \l{Tutorials} + \o \l{Qt Examples}{Examples} + \o \l{QML Examples and Demos} + \endlist + \enddiv + \enddiv +\enddiv +\div {class="indexbox tools"} + \div {class="indexboxcont indexboxbar"} + \div {class="sectionlist normallist"} + \div {class="heading"} + Develop with Qt \enddiv - \enddiv - \div {indexbox tools} - \div {heading} - Qt Tools - \enddiv - \div {indexboxcont} - \div {section indexIcon} \emptyspan - \enddiv - \div {section} - Qt offers a selection of development tools for - different tasks. Use Qt Creator for project and code - management as well as building powerfull UIs. - \enddiv - \div {section sectionlist} - \list - \o \l{http://doc.qt.nokia.com/qtcreator-2.0/index.html}{Qt Creator} - \o \l{designer-manual.html}{Qt Designer} - \o \l{linguist-manual.html}{Qt Linguist} - \o \l{assistant-manual.html}{Qt Assistant} - \o \l{qmake-manual.html}{Qt qmake} - \o \l{http://doc.qt.nokia.com/qtsimulator-1.0/index.html}{Qt Simulator} - \o \l{http://qt.nokia.com/developer/eclipse-integration}{Eclipse Integration} - \o \l{http://qt.nokia.com/products/appdev}{Add-On Products and Services} - \o \l{qvfb.html}{Virtual Framebuffer} - \endlist - \enddiv + \image tools.png + \list + \o \l{Develop with Qt}{Steps to Programming Qt Applications} + \o \l{qt-creator-configure-target}{Configure Qt and Creator for Platforms} + \o \l{qt-technologies}{Qt Features and Technologies} + \o \l{qt-utilities}{Utilities and Testing} + \o \l{qt-deployment}{Deploying Applications and Publish to Ovi Store} + \endlist + \enddiv + \div {class="sectionlist normallist"} + \div {class="heading"} + Featured Articles \enddiv - \enddiv + \image guide.png + \list + \o \l{Scalability}{How to Create Scalable Applications} + \o \l{http://doc.qt.nokia.com/nokia-qtsdk-1.0/creator-developing-symbian.html}{Setting Up Development Environment for Symbian} + \o \l{http://doc.qt.nokia.com/nokia-qtsdk-1.0/creator-developing-maemo.html}{Setting Up Development Environment for Maemo} + \o \l{http://doc.qt.nokia.com/qtcreator-snapshot/creator-publish-ovi.html}{Publishing Qt Applications to Ovi Store} + \endlist + \list + \o \l{Qt Development: The Steps from Challenge to Achievement}{The Steps from Challenge to Achievement} + A case analysis of a business development problem and a search for +innovative solutions using Qt. + \endlist + \enddiv + \div {class="sectionlist normallist"} + \div {class="heading"} + UI Creation with Qt + \enddiv + \image qml.png + \list + \o \l{qt-ui-creation}{Create UI with Qt} + \o \l{qt-rendering-painting-system}{Qt's Rendering and Painting Systems} + \o \l{Qt Quick} - develop fluid UIs with QML + \o \l{Widgets and Layouts} - elements for C++ interfaces + \endlist + \enddiv + \enddiv +\enddiv +\div {class="indexbox tools"} + \div {class="heading"} + Reference + \enddiv + \div {class="indexboxcont indexboxbar"} + \div {class="sectionlist normallist"} + \div {class="heading"} + Qt API + \enddiv + \list + \o \l{All Classes}{All Classes} + \o \l{All Functions}{All Functions} + \o \l{All Modules}{All Modules} + \o \l{All Namespaces}{All Namespaces} + \o \l{Global Qt Declarations}{Global Declarations} + + \endlist + \enddiv + \div {class="sectionlist normallist"} + \list + \o \l{Qt Quick} + \o \l{QML Elements} + \endlist + \list + \o \l{http://doc.qt.nokia.com/qtmobility-1.1.0/index.html}{Qt Mobility APIs} + \o \l{http://doc.qt.nokia.com/qtmobility-1.1.0/qml-plugins.html}{Mobility QML Plugins} + \endlist + \enddiv + \div {class="sectionlist normallist"} + \div {class="heading"} + Qt Manuals + \enddiv + \list + \o \l{http://doc.qt.nokia.com/qtcreator-2.0/index.html}{Qt Creator} + \o \l{http://doc.qt.nokia.com/qtsimulator/index.html}{Qt Simulator} + \o \l{linguist-manual.html}{Qt Linguist} + \o \l{assistant-manual.html}{Qt Assistant} + \endlist + \enddiv + \enddiv +\enddiv */ diff --git a/doc/src/internationalization/i18n.qdoc b/doc/src/internationalization/i18n.qdoc index e22f953..f58a9a5 100644 --- a/doc/src/internationalization/i18n.qdoc +++ b/doc/src/internationalization/i18n.qdoc @@ -34,13 +34,13 @@ */ /*! - \page internationalization.html \title Internationalization with Qt \brief Information about Qt's support for internationalization and multiple languages. \nextpage Writing Source Code for Translation \ingroup qt-basic-concepts - + \group internationalization + \keyword internationalization \keyword i18n @@ -192,7 +192,7 @@ to achieve this is to use QObject::tr(). For example, assuming the \c LoginWidget is a subclass of QWidget: - \snippet doc/src/snippets/code/doc_src_i18n.qdoc 0 + \snippet doc/src/snippets/code/doc_src_i18n.cpp 0 This accounts for 99% of the user-visible strings you're likely to write. @@ -202,7 +202,7 @@ appropriate class, or the QCoreApplication::translate() function directly: - \snippet doc/src/snippets/code/doc_src_i18n.qdoc 1 + \snippet doc/src/snippets/code/doc_src_i18n.cpp 1 If you need to have translatable text completely outside a function, there are two macros to help: QT_TR_NOOP() @@ -212,11 +212,11 @@ Example of QT_TR_NOOP(): - \snippet doc/src/snippets/code/doc_src_i18n.qdoc 2 + \snippet doc/src/snippets/code/doc_src_i18n.cpp 2 Example of QT_TRANSLATE_NOOP(): - \snippet doc/src/snippets/code/doc_src_i18n.qdoc 3 + \snippet doc/src/snippets/code/doc_src_i18n.cpp 3 If you disable the \c{const char *} to QString automatic conversion by compiling your software with the macro \c @@ -244,13 +244,13 @@ The QString::arg() functions offer a simple means for substituting arguments: - \snippet doc/src/snippets/code/doc_src_i18n.qdoc 4 + \snippet doc/src/snippets/code/doc_src_i18n.cpp 4 In some languages the order of arguments may need to change, and this can easily be achieved by changing the order of the % arguments. For example: - \snippet doc/src/snippets/code/doc_src_i18n.qdoc 5 + \snippet doc/src/snippets/code/doc_src_i18n.cpp 5 produces the correct output in English and Norwegian: \snippet doc/src/snippets/code/doc_src_i18n.qdoc 6 @@ -325,7 +325,7 @@ Typically, your application's \c main() function will look like this: - \snippet doc/src/snippets/code/doc_src_i18n.qdoc 8 + \snippet doc/src/snippets/code/doc_src_i18n.cpp 8 Note the use of QLibraryInfo::location() to locate the Qt translations. Developers should request the path to the translations at run-time by @@ -346,7 +346,7 @@ need to output Cyrillic in the ISO 8859-5 encoding. Code for this would be: - \snippet doc/src/snippets/code/doc_src_i18n.qdoc 9 + \snippet doc/src/snippets/code/doc_src_i18n.cpp 9 For converting Unicode to local 8-bit encodings, a shortcut is available: the QString::toLocal8Bit() function returns such 8-bit @@ -360,7 +360,7 @@ demonstrated by this conversion from ISO 8859-5 Cyrillic to Unicode conversion: - \snippet doc/src/snippets/code/doc_src_i18n.qdoc 10 + \snippet doc/src/snippets/code/doc_src_i18n.cpp 10 Ideally Unicode I/O should be used as this maximizes the portability of documents between users around the world, but in reality it is @@ -392,7 +392,7 @@ formats. Such localizations can be accomplished using appropriate tr() strings. - \snippet doc/src/snippets/code/doc_src_i18n.qdoc 11 + \snippet doc/src/snippets/code/doc_src_i18n.cpp 11 In the example, for the US we would leave the translation of "AMPM" as it is and thereby use the 12-hour clock branch; but in @@ -417,7 +417,7 @@ the text displayed by widgets using the \l{QObject::tr()}{tr()} function in the usual way. For example: - \snippet doc/src/snippets/code/doc_src_i18n.qdoc 12 + \snippet doc/src/snippets/code/doc_src_i18n.cpp 12 All other change events should be passed on by calling the default implementation of the function. @@ -511,7 +511,7 @@ /*! \page i18n-source-translation.html \title Writing Source Code for Translation - \ingroup i18n + \ingroup internationalization \previouspage Internationalization with Qt \contentspage Internationalization with Qt \nextpage Translation Rules for Plurals @@ -708,7 +708,7 @@ Typically, your application's \c main() function will look like this: - \snippet doc/src/snippets/code/doc_src_i18n.qdoc 8 + \snippet doc/src/snippets/code/doc_src_i18n.cpp 8 Note the use of QLibraryInfo::location() to locate the Qt translations. Developers should request the path to the translations at run-time by @@ -723,7 +723,7 @@ /*! \page i18n-plural-rules.html \title Translation Rules for Plurals - \ingroup i18n + \ingroup internationalization \previouspage Writing Source Code for Translation \contentspage Internationalization with Qt \brief A summary of the translation rules for plurals produced by Qt's i18n tools. diff --git a/doc/src/internationalization/linguist-manual.qdoc b/doc/src/internationalization/linguist-manual.qdoc index 1f413f9..7932fe8 100644 --- a/doc/src/internationalization/linguist-manual.qdoc +++ b/doc/src/internationalization/linguist-manual.qdoc @@ -29,6 +29,7 @@ \page linguist-manual.html \title Qt Linguist Manual \ingroup qttools + \ingroup internationalization \startpage {index.html}{Qt Reference Documentation} \nextpage Qt Linguist Manual: Release Manager @@ -46,10 +47,10 @@ at the person with overall responsibility for the release of the application. They will typically coordinate the work of the software engineers and the translator. The chapter describes the - use of two tools. The \l{lupdate} tool is used to synchronize - source code and translations. The \l{lrelease} tool is used to - create run-time translation files for use by the released - application. + use of two tools. The \l{linguist-manager.html#lupdate}{lupdate} + tool is used to synchronize source code and translations. The + \l{linguist-manager.html#lrelease}{lrelease} tool is used to create + run-time translation files for use by the released application. The \l{linguist-translators.html}{Translators} chapter is for translators. It describes the use of the \QL tool. @@ -77,7 +78,7 @@ programmer is able to add additional context information to phrases when necessary. The release manager generates a set of translation files that are produced from the source files and passes these to the - translator. The translator opens the translation files using \QL, + translator. The translator opens the translation files using \QL, enters their translations and saves the results back into the translation files, which they pass back to the release manager. The release manager then generates fast compact versions of these @@ -144,25 +145,22 @@ /*! \page linguist-manager.html \title Qt Linguist Manual: Release Manager + \ingroup internationalization \contentspage {Qt Linguist Manual}{Contents} \previouspage Qt Linguist Manual \nextpage Qt Linguist Manual: Translators - \keyword lupdate - \keyword lrelease - Two tools are provided for the release manager, \l lupdate and \l lrelease. These tools can process \l qmake project files, or operate directly on the file system. \section1 Qt Project Files - The easiest method to use \l{#lupdate} {lupdate} and \l{#lrelease} - {lrelease} is by specifying a \c .pro Qt project file. There must - be an entry in the \c TRANSLATIONS section of the project file for - each language that is additional to the native language. A typical - entry looks like this: + The easiest method to use \l lupdate and \l lrelease is by specifying + a \c .pro Qt project file. There must be an entry in the \c TRANSLATIONS + section of the project file for each language that is additional to + the native language. A typical entry looks like this: \snippet examples/linguist/arrowpad/arrowpad.pro 1 @@ -173,8 +171,8 @@ An example of a complete \c .pro file with four translation source files: - \snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 0 - \snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 1 + \snippet doc/src/snippets/code/doc_src_linguist-manual.pro 0 + \snippet doc/src/snippets/code/doc_src_linguist-manual.pro 1 QTextCodec::setCodecForTr() makes it possible to choose a 8-bit encoding for literal strings that appear within \c tr() calls. @@ -186,14 +184,14 @@ application, \QL needs you to set the \c CODECFORTR entry in the \c .pro file as well. For example: - \snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 1 + \snippet doc/src/snippets/code/doc_src_linguist-manual.pro 1 Also, if your compiler uses a different encoding for its runtime system as for its source code and you want to use non-ASCII characters in string literals, you will need to set the \c CODECFORSRC. For example: - \snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 2 + \snippet doc/src/snippets/code/doc_src_linguist-manual.pro 2 Microsoft Visual Studio 2005 .NET appears to be the only compiler for which this is necessary. However, if you want to write @@ -201,9 +199,8 @@ in your source files. You can still specify non-ASCII characters portably using escape sequences, for example: - \snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 3 + \snippet doc/src/snippets/code/doc_src_linguist-manual.cpp 3 - \target lupdate manual \section1 lupdate Usage: \c {lupdate myproject.pro} @@ -238,8 +235,8 @@ can also process Localization Interchange File Format (XLIFF) format files; files in this format typically have file names that end with the \c .xlf suffix. - - \note The minimum supported version for XLIFF format files is + + \note The minimum supported version for XLIFF format files is 1.1. XLIFF 1.0 version files are not supported. Pass the \c -help option to \c lupdate to obtain the list of @@ -271,7 +268,7 @@ are available the application will detect them and use them automatically. - Note that lrelease will only incorporate translations that are + Note that \l lrelease will only incorporate translations that are marked as "finished". Otherwise the original text will be used instead. @@ -285,12 +282,13 @@ Both \l lupdate and \l lrelease may be used with TS translation source files which are incomplete. Missing translations will be replaced with the native language phrases at - runtime. + runtime. */ /*! \page linguist-translators.html \title Qt Linguist Manual: Translators + \ingroup internationalization \contentspage {Qt Linguist Manual}{Contents} \previouspage Qt Linguist Manual: Release Manager @@ -315,7 +313,7 @@ arranged around a central \l{The Translation Area} {translation area}. The \l{Context Window} {context list} is normally shown on the left, and the \l{Sources and Forms Window} {source code}, - \l{Strings Window} {string list}, and either the \l{Phrases and + \l{Strings Window} {string list}, and either the \l{Phrases and Guesses Window} {phrases and guesses}, or the \l{Warnings Window} {warnings} are shown above and below the \l{The Translation Area} {translations area}. @@ -331,9 +329,9 @@ \key{tick mark} button on the toolbar, or click the icon to the left of the selected source string in the string list. Repeat this process until all strings in the string list are marked with - \inlineimage linguist-check-on.png + \inlineimage linguist-check-on.png or - \inlineimage linguist-check-warning.png + \inlineimage linguist-check-warning.png . Then select the next context and continue. Translation options are shown in the \l{Phrases and Guesses @@ -389,17 +387,17 @@ that aren't in a subclass of QObject. To the left of the \e{Context} column is a column labeled - \inlineimage linguist-check-obsolete.png + \inlineimage linguist-check-obsolete.png . This column uses the following list of icons to summarize the current translation state for each context: \list - \o \inlineimage linguist-check-on.png + \o \inlineimage linguist-check-on.png All strings in the context have been translated, and all the translations passed the \l{Validation Tests} {validation tests}. - \o \inlineimage linguist-check-warning.png + \o \inlineimage linguist-check-warning.png All strings in the context have been translated or marked as translated, but at least one translation failed the \l{Validation Tests} {validation tests}. @@ -427,19 +425,19 @@ selected. Its \e{Items} entry shows \bold{18/18}, which means it has 18 translatable strings and all 18 strings currently have translations. However, the context has been marked with the - \inlineimage linguist-check-warning.png - icon, which means that at least one of the current translations - failed a \l{Validation Tests} {validation test}. In the - \l{Strings Window} {strings window} to the right, we see that one - of the strings is indeed marked with the - \inlineimage linguist-check-warning.png + \inlineimage linguist-check-warning.png + icon, which means that at least one of the current translations + failed a \l{Validation Tests} {validation test}. In the + \l{Strings Window} {strings window} to the right, we see that one + of the strings is indeed marked with the + \inlineimage linguist-check-warning.png icon. The context window is a dockable window. It can be dragged to another position in the main window, or dragged out of the main window to be a separate window. If you move the context window, \QL remembers the new position and puts the context window there - whenever you start the program. If the context window has been + whenever you start the program. If the context window has been closed, it can be restored by pressing \key{F6}. \section2 Strings Window @@ -475,16 +473,16 @@ \o The source string has a translation (possibly empty); the user has accepted the translation, and the translation passes all the \l{Validation Tests} {validation tests}. If the translation is - empty, the user has chosen to leave it empty. Click the icon to - revoke acceptance of the translation and decrement the number of + empty, the user has chosen to leave it empty. Click the icon to + revoke acceptance of the translation and decrement the number of accepted translations in the \e{Items} column of the \l{Context - Window} {context list} by 1. The state is reset to - \inlineimage linguist-check-off.png + Window} {context list} by 1. The state is reset to + \inlineimage linguist-check-off.png if the string has a translation, or to \inlineimage linguist-check-empty.png - if the string's translation is empty. If \c{lupdate} changes the - contents of a string, its acceptance state is automatically reset - to \inlineimage linguist-check-off.png + if the string's translation is empty. If \c{lupdate} changes the + contents of a string, its acceptance state is automatically reset + to \inlineimage linguist-check-off.png . \row @@ -493,44 +491,44 @@ \o The user has accepted the translation, but the translation does not pass all the \l{Validation Tests} {validation tests}. The validation test failures are shown in the \l{Warnings Window} - {warnings window}. Click the icon to revoke acceptance of the - translation. The state is reset to \inlineimage linguist-danger.png - , and the number of accepted translations in the \e{Items} column - of the \l{Context Window} {context list} is decremented by 1. + {warnings window}. Click the icon to revoke acceptance of the + translation. The state is reset to \inlineimage linguist-danger.png + , and the number of accepted translations in the \e{Items} column + of the \l{Context Window} {context list} is decremented by 1. \row \o Not Accepted \o \inlineimage linguist-check-off.png - \o The string has a non-empty translation that passes all the - \l{Validation Tests} {validation tests}, but the user has not yet + \o The string has a non-empty translation that passes all the + \l{Validation Tests} {validation tests}, but the user has not yet accepted the translation. Click the icon or press \key{Ctrl+Enter} - to accept the translation. The state is reset to + to accept the translation. The state is reset to \inlineimage linguist-check-on.png - , and the number of accepted translations in the \e{Items} column - of the \l{Context Window} {context list} is incremented by 1. + , and the number of accepted translations in the \e{Items} column + of the \l{Context Window} {context list} is incremented by 1. \row \o No Translation \o \inlineimage linguist-check-empty.png - \o The string does not have a translation. Click the icon to - accept the empty translation anyway. The state is reset to + \o The string does not have a translation. Click the icon to + accept the empty translation anyway. The state is reset to \inlineimage linguist-check-on.png - , and the number of accepted translations in the \e{Items} column + , and the number of accepted translations in the \e{Items} column of the \l{Context Window} {context list} is incremented by 1. \row \o Validation Failures \o \inlineimage linguist-danger.png - \o The string has a translation, but the translation does not - pass all the \l{Validation Tests} {validation tests}. Validation - test failures are shown in the \l{Warnings Window} {warnings} - window. Click on the icon or press \key{Ctrl+Return} to accept - the translation even with validation failures. The state is + \o The string has a translation, but the translation does not + pass all the \l{Validation Tests} {validation tests}. Validation + test failures are shown in the \l{Warnings Window} {warnings} + window. Click on the icon or press \key{Ctrl+Return} to accept + the translation even with validation failures. The state is reset to \inlineimage linguist-check-warning.png - . We recommended editing the translation to fix the causes of + . We recommended editing the translation to fix the causes of the validation failures. The state will reset automatically to \inlineimage linguist-check-off.png - , when all the failures have been fixed. + , when all the failures have been fixed. \row \o Obsolete @@ -558,12 +556,12 @@ If the developer provides a \l{QObject::tr()} {disambiguating comment}, it will appear below the source text area, under the - label \menu{Developer comments}. + label \menu{Developer comments}. Below the source text and optional developer comments are two text entry widgets for the translator, one for entering the translation of the current string, and one for the translator to enter an - optional comment to be read by other translators. + optional comment to be read by other translators. When \l{Translating Multiple Languages Simultaneously} {multiple languages} are being translated, this sequence of fields is @@ -578,7 +576,7 @@ translation(s) will be listed in this window. If the current string is the same as, or similar to, another string that has already been translated, that other string and its translation - will also be listed in this window. + will also be listed in this window. To use a translation from the Phrases and Guesses Window, you can double click the translation, and it will be copied into the @@ -607,7 +605,7 @@ If the source context shows the wrong source line, it probably means the translation file is out of sync with the source files. To re-sync the translation file with the source files, see the - \l{lupdate manual} {lupdate manual}. + \l{linguist-manager.html#lupdate}{lupdate} manual. The Sources and Forms window is a dockable window. If it has been closed, it can be made visible again by pressing the \e{Sources @@ -638,12 +636,12 @@ and you are given an application's Polish translation file and asked to update the application's Japanese translation file. You are more comfortable translating Polish to Japanese than you are - translating English to Japanese. + translating English to Japanese. Below is the UI snapshot shown earlier, but this time with both \e{Polish} and \e{Japanese} translation files loaded. - \image linguist-linguist_2.png + \image linguist-linguist_2.png The first thing to notice is that the \l{The Translation Area} {translation area} has text editing areas for both Polish and @@ -662,18 +660,18 @@ selected in the snapshot shown above. Recall that in the first UI snapshot (Polish only), the numbers for this context were \e{18/18}, meaning 18 translatable strings had been found in the - context, and all 18 strings had accepted translations. In the UI + context, and all 18 strings had accepted translations. In the UI snapshot above, the numbers for the \bold{MessageEditor} context are now \e{1/18}, meaning that both languages have 18 translatable strings for that context, but for Japanese, only 1 of the 18 - strings has an accepted translation. The - \inlineimage linguist-check-off.png + strings has an accepted translation. The + \inlineimage linguist-check-off.png icon in the Japanese column means that at least one string in the - context doesn't have an accepted Japanese translation yet. In fact, - 17 of the 18 strings don't have accepted Japanese translations yet. - We will see \e{18/18} in the \e{Items} column when all 18 strings - have accepted translations for all the loaded translation files, - e.g., both Polish and Japanese in the snapshot. + context doesn't have an accepted Japanese translation yet. In fact, + 17 of the 18 strings don't have accepted Japanese translations yet. + We will see \e{18/18} in the \e{Items} column when all 18 strings + have accepted translations for all the loaded translation files, + e.g., both Polish and Japanese in the snapshot. \section1 Common Tasks @@ -726,7 +724,7 @@ key in the translation text ("File") precede it with an ampersand, e.g. \e{\&File}. If a string to be translated has an ampersand in it, then the translation for that string should also have an - ampersand in it, preferably in front of the same character. + ampersand in it, preferably in front of the same character. The meaning of an Alt key accelerator can be determined from the phrase in which the ampersand is embedded. The translator can @@ -810,7 +808,7 @@ If the translated text is similar to the source text, choose the \e {Copy from source text} entry in the \menu Translation menu (press - \key{Ctrl+B}) which will copy the source text into the + \key{Ctrl+B}) which will copy the source text into the \l{The Translation Area} {translation area}. \QL automatically lists possible translations from any open @@ -839,9 +837,9 @@ A \QL phrase book is a set of source phrases, target (translated) phrases, and optional definitions. Typically one phrase book - will be created per language and family of applications. Phrase books - are used to provide a common set of translations to help ensure consistency. - They can also be used to avoid duplication of effort since the translations + will be created per language and family of applications. Phrase books + are used to provide a common set of translations to help ensure consistency. + They can also be used to avoid duplication of effort since the translations for a family of applications can be produced once in the phrase book. If the translator reaches an non-translated phrase that is the same as a source phrase in a phrase book, \QL will show the @@ -861,25 +859,25 @@ The phrase book contents can be displayed and changed by selecting \menu{Phrase|Edit Phrase Book}, and then activating the phrase book you want to work on. This will pop up the Phrase Book Dialog as shown - in the image above. To add a new phrase click the \gui{New Phrase} - button (or press Alt+N) and type in a new source phrase. Press Tab and - type in the translation. Optionally press Tab and enter a definition -- - this is useful to distinguish different translations of the same source - phrase. This process may be repeated as often as necessary. You can delete + in the image above. To add a new phrase click the \gui{New Phrase} + button (or press Alt+N) and type in a new source phrase. Press Tab and + type in the translation. Optionally press Tab and enter a definition \mdash + this is useful to distinguish different translations of the same source + phrase. This process may be repeated as often as necessary. You can delete a phrase by selecting it in the phrases list and clicking - Remove Phrase. Click the \gui Close button (press Esc) once you've finished + Remove Phrase. Click the \gui Close button (press Esc) once you've finished adding (and removing) phrases. \section2 Shortcuts for Editing Phrase Books You can also create a new phrase book entry directly out of the translation you are working on: Clicking \menu{Phrases|Add to Phrase Book} or pressing - \key{Ctrl+T} will add the source text and the content of the first translation + \key{Ctrl+T} will add the source text and the content of the first translation field to the current phrase book. If multiple phrase books are loaded, you have to specify the phrase book to add the entry to in a dialogue. - If you detect an error in a phrase book entry that is shown in the - \l{Phrases and Guesses Window}, you can also edit it in place by right - clicking on the entry, and selecting \menu{Edit}. After fixing the error + If you detect an error in a phrase book entry that is shown in the + \l{Phrases and Guesses Window}, you can also edit it in place by right + clicking on the entry, and selecting \menu{Edit}. After fixing the error press \key{Return} to leave the editing mode. \section2 Batch Translation @@ -890,7 +888,7 @@ translate source texts that are also in a phrase book. Selecting \menu{Tools|Batch Translation} will show you the batch translation dialog, which let you configure which phrase books to use in what order during the - batch translation process. Furthermore you can set whether only entries + batch translation process. Furthermore you can set whether only entries with no present translation should be considered, and whether batch translated entries should be set to finished (see also \l {String Translation States}). @@ -929,7 +927,7 @@ Forms created by \e{Qt Designer} are stored in special UI files. \QL can make use of these UI files to show the translations done so far on the form itself. This of course requires access to the UI - files during the translation process. Activate + files during the translation process. Activate \menu{Tools|Open/Refresh Form Preview} to open the window shown above. The list of UI files \QL has detected are displayed in the Forms List on the left hand. If the path to the files has changed, you can load @@ -947,17 +945,18 @@ \list \o TS \e {translation source files} \BR are human-readable XML files containing source phrases and their translations. These files are - usually created and updated by \l lupdate and are specific to an - application. + usually created and updated by \l{linguist-manager.html#lupdate}{lupdate} + and are specific to an application. \o \c .xlf \e {XLIFF files} \BR are human-readable XML files that adhere to the international XML Localization Interchange File Format. \QL - can be used to edit XLIFF files generated by other programs. However, for - standard Qt projects, only the TS file format is used. \note The minimum - supported version for XLIFF format files is 1.1. XLIFF 1.0 version files + can be used to edit XLIFF files generated by other programs. However, for + standard Qt projects, only the TS file format is used. \note The minimum + supported version for XLIFF format files is 1.1. XLIFF 1.0 version files are not supported. \o QM \e {Qt message files} \BR are binary files that contain translations used by an application at run-time. These files are - generated by \l lrelease, but can also be generated by \QL. + generated by \l{linguist-manager.html#lrelease}{lrelease}, but can also + be generated by \QL. \o \c .qph \e {Qt phrase book files} \BR are human-readable XML files containing standard phrases and their translations. These files are created and updated by \QL and may be used by any @@ -982,13 +981,15 @@ name, format and/or put in a different location. \o \gui {Release} \BR create a Qt message QM file with the same base name as the current translation source file. The release manager's - command line tool \l lrelease performs the same function on - \e all of an application's translation source files. + command line tool \l{linguist-manager.html#lrelease}{lrelease} + performs the same function on \e all of an application's translation + source files. \o \gui {Release As...} \BR pops up a save as file dialog. The filename entered will be a Qt message QM file of the translation based on the current translation source file. The release manager's - command line tool \l lrelease performs the same function on - \e all of an application's translation source files. + command line tool \l{linguist-manager.html#lrelease}{lrelease} + performs the same function on \e all of an application's translation + source files. \o \gui {Print... Ctrl+P} \BR pops up a print dialog. If you click OK the translation source and the translations will be printed. \o \gui {Exit Ctrl+Q} \BR closes \QL. @@ -1018,10 +1019,10 @@ Source phrases, translations and comments may be searched. \o \gui {Find Next F3} \BR finds the next occurrence of the text that was last entered in the Find dialog. - \o \gui {Search and Translate...} \BR pops up the Search and + \o \gui {Search and Translate...} \BR pops up the Search and Replace Dialog. Use this dialog to translate the same text in multiple items. \o \gui {Translation File Settings...} \BR let you configure the target - language and the country/region of a translation source file. + language and the country/region of a translation source file. \endlist \o \gui {Translation} @@ -1123,7 +1124,7 @@ \o \gui {Manual F1} \BR opens this manual. \o \gui {About Qt Linguist} \BR Shows information about \QL. \o \gui {About Qt} \BR Shows information about \e{Qt}. - \o \gui {What's This? Shift+F1} \BR Click on one item in the main window + \o \gui {What's This? Shift+F1} \BR Click on one item in the main window to get additional information about it. \endlist @@ -1219,6 +1220,7 @@ /*! \page linguist-programmers.html \title Qt Linguist Manual: Programmers + \ingroup internationalization \contentspage {Qt Linguist Manual}{Contents} \previouspage Qt Linguist Manual: Translators @@ -1262,28 +1264,31 @@ Translation files are created as follows: \list 1 - \o Run \l lupdate initially to generate the first set of TS - translation source files with all the user-visible text but no - translations. + \o Run \l {linguist-manager.html#lupdate}{lupdate} initially to + generate the first set of TS translation source files with all the + user-visible text but no translations. \o The TS files are given to the translator who adds translations using \QL. \QL takes care of any changed or deleted source text. - \o Run \l lupdate to incorporate any new text added to the - application. \l lupdate synchronizes the user-visible text from the - application with the translations; it does not destroy any data. + \o Run \l{linguist-manager.html#lupdate}{lupdate} to incorporate any new + text added to the application. \l{linguist-manager.html#lupdate}{lupdate} + synchronizes the user-visible text from the application with the + translations; it does not destroy any data. \o Steps 2 and 3 are repeated as often as necessary. - \o When a release of the application is needed \l lrelease is run to + \o When a release of the application is needed + \l{linguist-manager.html#lrelease}{lrelease} is run to read the TS files and produce the QM files used by the application at runtime. \endlist - For \l lupdate to work successfully, it must know which translation - files to produce. The files are simply listed in the application's \c - .pro Qt project file, for example: + For \l{linguist-manager.html#lupdate}{lupdate} to work successfully, + it must know which translation files to produce. The files are simply + listed in the application's \c .pro Qt project file, for example: \snippet examples/linguist/arrowpad/arrowpad.pro 1 - If your sources contain genuine non-Latin1 strings, \l lupdate needs + If your sources contain genuine non-Latin1 strings, + \l{linguist-manager.html#lupdate}{lupdate} needs to be told about it in the \c .pro file by using, for example, the following line: @@ -1291,7 +1296,8 @@ CODECFORTR = UTF-8 \endcode - See the \l lupdate and \l lrelease sections. + See the \l{linguist-manager.html#lupdate}{lupdate} and + \l{linguist-manager.html#lrelease}{lrelease} sections. \section2 Loading Translations @@ -1333,11 +1339,11 @@ User-visible strings are marked as translation targets by wrapping them in a \c tr() call, for example: - \snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 6 + \snippet doc/src/snippets/code/doc_src_linguist-manual.cpp 6 would become - \snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 7 + \snippet doc/src/snippets/code/doc_src_linguist-manual.cpp 7 All QObject subclasses that use the \c Q_OBJECT macro implement the \c tr() function. @@ -1346,29 +1352,29 @@ usually called as a member function of a QObject subclass, in other cases an explicit class name can be supplied, for example: - \snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 8 + \snippet doc/src/snippets/code/doc_src_linguist-manual.cpp 8 or - \snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 9 + \snippet doc/src/snippets/code/doc_src_linguist-manual.cpp 9 \section2 Distinguishing Between Identical Translatable Strings - The \l lupdate program automatically provides a \e context for every - source text. This context is the class name of the class that contains - the \c tr() call. This is sufficient in the vast majority of cases. - Sometimes however, the translator will need further information to - uniquely identify a source text; for example, a dialog that contained - two separate frames, each of which contained an "Enabled" option would - need each identified because in some languages the translation would - differ between the two. This is easily achieved using the + The \l{linguist-manager.html#lupdate}{lupdate} program automatically + provides a \e context for every source text. This context is the class + name of the class that contains the \c tr() call. This is sufficient in + the vast majority of cases. Sometimes however, the translator will need + further information to uniquely identify a source text; for example, + a dialog that contained two separate frames, each of which contained an + "Enabled" option would need each identified because in some languages the + translation would differ between the two. This is easily achieved using the two argument form of the \c tr() call, e.g. - \snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 10 + \snippet doc/src/snippets/code/doc_src_linguist-manual.cpp 10 and - \snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 11 + \snippet doc/src/snippets/code/doc_src_linguist-manual.cpp 11 Ctrl key accelerators are also translatable: @@ -1385,44 +1391,46 @@ solved by adding a comment using the keyword \e TRANSLATOR which describes the navigation steps to reach the text in question; e.g. - \snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 12 + \snippet doc/src/snippets/code/doc_src_linguist-manual.cpp 12 These comments are particularly useful for widget classes. \section2 Handling Plural Forms - Qt includes a \c tr() overload that will make it very easy to - write "plural-aware" internationalized applications. This overload + Qt includes a \c tr() overload that will make it very easy to + write "plural-aware" internationalized applications. This overload has the following signature: - \snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 17 + \snippet doc/src/snippets/code/doc_src_linguist-manual.cpp 17 - Depending on the value of \c n, the \c tr() function will return a different - translation, with the correct grammatical number for the target language. + Depending on the value of \c n, the \c tr() function will return a different + translation, with the correct grammatical number for the target language. Also, any occurrence of \c %n is replaced with \c{n}'s value. For example: - \snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 18 + \snippet doc/src/snippets/code/doc_src_linguist-manual.cpp 18 - If a French translation is loaded, this will expand to "0 item - remplac\unicode{233}", "1 item remplac\unicode{233}", "2 items - remplac\unicode{233}s", etc., depending on \c{n}'s value. - And if no translation is loaded, the original string is used, with \c %n + If a French translation is loaded, this will expand to "0 item + remplac\unicode{233}", "1 item remplac\unicode{233}", "2 items + remplac\unicode{233}s", etc., depending on \c{n}'s value. + And if no translation is loaded, the original string is used, with \c %n replaced with count's value (e.g., "6 item(s) replaced"). - To handle plural forms in the native language, you need to load a - translation file for this language, too. \l lupdate has the + To handle plural forms in the native language, you need to load a + translation file for this language, too. + \l{linguist-manager.html#lupdate}{lupdate} has the \c -pluralonly command line option, which allows the creation of TS files containing only entries with plural forms. - See the \l{http://doc.qt.nokia.com/qq/}{Qt Quarterly} Article + See the \l{http://doc.qt.nokia.com/qq/}{Qt Quarterly} Article \l{http://doc.qt.nokia.com/qq/qq19-plurals.html}{Plural Forms in Translations} for further details on this issue. \section2 Coping With C++ Namespaces C++ namespaces and the \c {using namespace} statement can confuse - \l lupdate. It will interpret \c MyClass::tr() as meaning just - that, not as \c MyNamespace::MyClass::tr(), even if \c MyClass is + \l{linguist-manager.html#lupdate}{lupdate}. It will interpret + \c MyClass::tr() as meaning just that, not as + \c MyNamespace::MyClass::tr(), even if \c MyClass is defined in the \c MyNamespace namespace. Runtime translation of these strings will fail because of that. @@ -1430,7 +1438,7 @@ comment at the beginning of the source files that use \c MyClass::tr(): - \snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 13 + \snippet doc/src/snippets/code/doc_src_linguist-manual.cpp 13 After the comment, all references to \c MyClass::tr() will be understood as meaning \c MyNamespace::MyClass::tr(). @@ -1443,20 +1451,21 @@ use either the tr() function of an appropriate class, or the QCoreApplication::translate() function directly: - \snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 14 + \snippet doc/src/snippets/code/doc_src_linguist-manual.cpp 14 \section3 Using QT_TR_NOOP() and QT_TRANSLATE_NOOP() If you need to have translatable text completely outside a function, there are two macros to help: QT_TR_NOOP() and QT_TRANSLATE_NOOP(). - These macros merely mark the text for extraction by \l{lupdate}. + These macros merely mark the text for extraction by + \l{linguist-manager.html#lupdate}{lupdate}. The macros expand to just the text (without the context). Example of QT_TR_NOOP(): - \snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 15 + \snippet doc/src/snippets/code/doc_src_linguist-manual.cpp 15 Example of QT_TRANSLATE_NOOP(): - \snippet doc/src/snippets/code/doc_src_linguist-manual.qdoc 16 + \snippet doc/src/snippets/code/doc_src_linguist-manual.cpp 16 \section1 Tutorials @@ -1484,8 +1493,9 @@ applications for translation. At the beginning of a project add the translation source files to be - used to the project file and add calls to \l lupdate and \l lrelease to - the makefile. + used to the project file and add calls to + \l{linguist-manager.html#lupdate}{lupdate} and + \l{linguist-manager.html#lrelease}{lrelease} to the Makefile. During the project all the programmer must do is wrap any user-visible text in \c tr() calls. They should also use the two argument form for @@ -1498,6 +1508,7 @@ /*! \page linguist-ts-file-format.html \title Qt Linguist Manual: TS File Format + \ingroup internationalization \contentspage {Qt Linguist Manual}{Contents} \previouspage Qt Linguist Manual: Programmers @@ -1508,5 +1519,5 @@ may change in future Qt releases. \quotefile tools/linguist/shared/ts.dtd - + */ diff --git a/doc/src/ja_JP/development/qmake-manual.qdoc b/doc/src/ja_JP/development/qmake-manual.qdoc index a6cfe3d..3b908f7 100644 --- a/doc/src/ja_JP/development/qmake-manual.qdoc +++ b/doc/src/ja_JP/development/qmake-manual.qdoc @@ -58,16 +58,16 @@ 新しい行を作り、\c{SOURCES +=}、続いて hello.cpp を入力します。 つまり、以下のようになります: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 108 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 108 これを以下のようになるまでプロジェクトの各ソースファイルに対して行います: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 109 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 109 make に似たシンタックスを使いたい場合は、 以下のように改行をエスケープしてすべてのファイルを 1 行に書きます: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 110 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 110 ソースファイルの一覧をプロジェクトファイルに追加しました。 次にヘッダファイルを追加します。 @@ -77,7 +77,7 @@ これを終えると、プロジェクトファイルは以下のようになるでしょう: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 111 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 111 ターゲットの名前は自動的に設定され、 プロジェクトファイルと同じ名前になります。 @@ -86,7 +86,7 @@ ターゲットは Windows では \c hello.exe 、Unix では \c hello になります。 プロジェクトファイルで別の名前を指定することもできます: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 112 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 112 最後に \l{qmake Variable Reference#CONFIG}{CONFIG} 変数を設定します。 このアプリケーションは Qt アプリケーションなので \c CONFIG に @@ -96,19 +96,19 @@ 最終的なプロジェクトファイルは以下のようになります: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 113 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 113 \c qmake を使って、このアプリケーションのための Makefile を生成します。 プロジェクトのディレクトリでコマンドラインに次のように入力します: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 114 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 114 そして、使用するコンパイラによって \c make または \c nmake を入力します。 Visual Studio ユーザの場合、\c qmake は、以下のように \c .dsp ファイルまたは \c .vcproj ファイルも作成できます: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 115 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 115 \section1 アプリケーションをデバッグできるようにする @@ -119,7 +119,7 @@ たとえば: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 116 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 116 直前の例と同様に、Makefile を生成するには \c qmake を使います。 アプリケーションをデバッグ環境で実行する際に役に立つ情報を得られるようになります。 @@ -137,7 +137,7 @@ Windows 用のファイルを追加するシンプルなスコープは以下のようになります: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 117 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 117 \c qmake が Windows 上で実行されると、ソースファイルのリストに \c hellowin.cpp が追加されます。 @@ -146,7 +146,7 @@ これを終えると、プロジェクトファイルは以下のようになります: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 118 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 118 これまでと同様に、Makefile を生成するには \c qmake を使います。 @@ -159,13 +159,13 @@ 使い方はスコープの条件をこれらの関数で置き換えるだけです。 \c main.cpp ファイルの確認は以下のようになります : - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 119 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 119 記号 \c{!} はテストを否定します。 つまり \c{exists( main.cpp )} はファイルが存在する場合に真になり、 \c{!exists( main.cpp )} はファイルが存在しない場合に真になります。 - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 120 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 120 前と同様に、\c qmake を実行して Makefile を生成します。 仮に \c main.cpp の名前を変更すると、上記のメッセージが表示され、 @@ -185,12 +185,12 @@ まず 1 つのスコープを作成し、その中にもう 1 つスコープを作成します。 そして 2 つのスコープの中に設定を書きます。例えば: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 121 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 121 ネストされたスコープはコロンを使ってつなぐことができます。 最終的なプロジェクトファイルは以下のようになります: - \snippet doc/src/snippets/code/doc_src_qmake-manual.qdoc 122 + \snippet doc/src/snippets/code/doc_src_qmake-manual.pro 122 以上です。\c qmake のチュートリアルが終了しました。 それでは、あなたの開発プロジェクトのプロジェクトファイルを作成してみましょう。 diff --git a/doc/src/ja_JP/development/qtestlib.qdoc b/doc/src/ja_JP/development/qtestlib.qdoc index c1001dc..3ff1f36 100644 --- a/doc/src/ja_JP/development/qtestlib.qdoc +++ b/doc/src/ja_JP/development/qtestlib.qdoc @@ -71,7 +71,7 @@ 次に、テスト関数を実装します。実装は以下のようになります: - \snippet doc/src/snippets/code/doc_src_qtestlib.qdoc 8 + \snippet doc/src/snippets/code/doc_src_qtestlib.cpp 8 \l QVERIFY() マクロは、引数として渡される式を評価します。 式が真と評価されるとテスト関数の実行が継続されます。 @@ -131,7 +131,7 @@ これまでは、テストデータをテスト関数にハードコードしていました。 この場合、テストデータを追加した関数は以下のようになります: - \snippet doc/src/snippets/code/doc_src_qtestlib.qdoc 11 + \snippet doc/src/snippets/code/doc_src_qtestlib.cpp 11 関数が繰り返しを行うコードによって分散するのを防ぐために、 QTestLib はテストデータのテスト関数への追加をサポートします。 diff --git a/doc/src/ja_JP/examples/arrowpad.qdoc b/doc/src/ja_JP/examples/arrowpad.qdoc index 9085654..56f14a1 100644 --- a/doc/src/ja_JP/examples/arrowpad.qdoc +++ b/doc/src/ja_JP/examples/arrowpad.qdoc @@ -71,7 +71,7 @@ \c Q_OBJECT のマクロは、以下の内容で \c ArrowPad に \c tr(x) を定義します: - \snippet doc/src/snippets/code/doc_src_examples_arrowpad.qdoc 0 + \snippet doc/src/snippets/code/doc_src_examples_arrowpad.cpp 0 各ソーステキストが表示されるクラスを把握しておくと、 \e {Qt Linguist} で論理的に関連のある文字列をグループ化することが出来ます。 diff --git a/doc/src/ja_JP/examples/trollprint.qdoc b/doc/src/ja_JP/examples/trollprint.qdoc index dfe7eaa..ddc6880 100644 --- a/doc/src/ja_JP/examples/trollprint.qdoc +++ b/doc/src/ja_JP/examples/trollprint.qdoc @@ -136,12 +136,12 @@ 変更すべき行は4行あります。 ラジオボタンの最初のペアの \c tr() 呼び出しに、2つ目の引数 "two-sided"(両面) をに追加します: - \snippet doc/src/snippets/code/doc_src_examples_trollprint.qdoc 0 + \snippet doc/src/snippets/code/doc_src_examples_trollprint.cpp 0 そして、ラジオボタンの2番目のペアの \c tr() 呼び出しに、 2つ目の引数 "colors"(色) を追加します。 - \snippet doc/src/snippets/code/doc_src_examples_trollprint.qdoc 1 + \snippet doc/src/snippets/code/doc_src_examples_trollprint.cpp 1 ここで、\c lupdate を実行し、\e {Qt Linguist} で \c trollprint_pt.ts を開きます。2 つの変更個所がわかるはずです。 @@ -184,7 +184,7 @@ これは、ソースコードで \c TRANSLATOR コメントを使用して行います: - \snippet doc/src/snippets/code/doc_src_examples_trollprint.qdoc 2 + \snippet doc/src/snippets/code/doc_src_examples_trollprint.cpp 2 一部のソースファイル、特にダイアログクラスのコメントに ダイアログに到達するまでに必要な操作を記述します。 @@ -201,7 +201,7 @@ コメントは役立つナビゲーション情報を提供するため、 翻訳に要する時間を節約できます: - \snippet doc/src/snippets/code/doc_src_examples_trollprint.qdoc 3 + \snippet doc/src/snippets/code/doc_src_examples_trollprint.cpp 3 \section1 Troll Print 1.1 diff --git a/doc/src/legal/qtquicklicense.qdoc b/doc/src/legal/qtquicklicense.qdoc new file mode 100644 index 0000000..aa9e201 --- /dev/null +++ b/doc/src/legal/qtquicklicense.qdoc @@ -0,0 +1,40 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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:FDL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Free Documentation License +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of this +** file. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page qtquicklicense.html + \title Qt Quick Licensing Information + \ingroup licensing + \brief Qt Quick and QtDeclarative Licensing Information. + + +Applications created using Qt Quick are subject to the terms and conditions of the GNU Lesser General Public License as Qt Quick includes dependencies to QtScript and JavaScriptCore which are licensed under the terms of the GNU Library General Public License ("LGPL"). Qt Commercial Edition licensees that wish to distribute applications that use the Qt Quick need to be aware of their obligations under the LGPL. Individual contributor names and copyright dates can be found inline in the code. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +On the Qt web site, you can find a +\l{Qt Licensing Overview} and information on \l{Qt License Pricing} +for commercial editions of Qt and other Qt-related products. +*/ diff --git a/doc/src/mainpage.qdoc b/doc/src/mainpage.qdoc new file mode 100644 index 0000000..269dc52 --- /dev/null +++ b/doc/src/mainpage.qdoc @@ -0,0 +1,232 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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:FDL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Free Documentation License +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of this +** file. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! +\page gettingstarted-develop.html +\title Develop with Qt +\ingroup gettingstarted + +\div {class="indexboxcont indexboxbar"} +Developing a Qt application involves many different steps and stages. From +configuring Creator to distributing binaries to different platforms, Qt provides +many options along the way. +\image quick_screens.png +\enddiv + +\div {class="indexboxcont indexboxbar normallist"} +\keyword qt-creator-configure-target +\section1 Configuring Qt and Creator Targets +Qt and Creator are configurable to compile applications on many platform targets +and multiple platforms. + +\section2 Configuring Creator for Qt Development: +Creator is the integrated development environment for developing Qt applications. +Creator encompasses every step of application development from interface design +to application testing and deployment. +\list +\o \l{http://doc.qt.nokia.com/qtcreator-snapshot/creator-project-managing.html}{Creating Qt Projects} +\o \l{http://doc.qt.nokia.com/qtcreator-snapshot/creator-building-running.html}{Building and Running Applications} + \list + \o \l{http://doc.qt.nokia.com/qtcreator-snapshot/creator-running-targets.html}{Targets} - edit and set compiler targets + \o \l{http://doc.qt.nokia.com/qtcreator-snapshot/creator-build-settings.html}{Build Settings} - edit and set build configurations + \o \l{http://doc.qt.nokia.com/qtcreator-snapshot/creator-run-settings.html}{Run Settings} - edit and set application run settings + \endlist +\o \l{http://doc.qt.nokia.com/nokia-qtsdk-1.0/creator-developing-symbian.html}{Setting Up Development Environment for Symbian} +\o \l{http://doc.qt.nokia.com/nokia-qtsdk-1.0/creator-developing-maemo.html}{Setting Up Development Environment for Maemo} +\endlist + +\keyword qt-platform-support +\section2 Qt Platform Support +Alternatively, Qt may be installed on its own without the Nokia Qt SDK. + +Information regarding Qt Support on Different Platforms: +\list +\o \l{Installing Qt for the Symbian platform}{Symbian and Mobile Development} +\o \l{Support for Windows}{Microsoft Windows} +\o \l{Support for Windows CE and Windows Mobile}{Microsoft Windows CE} +\o \l{Support for Mac OS X}{Apple Mac OS X} +\o \l{Support for Linux/X11}{Linux and X11 Platforms} +\o \l{Support for Embedded Linux}{Qt for Embedded Linux} +\endlist +For more information about the platforms supported +and their installation pages, view the \l {Supported Platforms} and the +\l {Cross-Platform and Platform-Specific Development} pages. +\enddiv + +\div {class="indexboxcont indexboxbar normallist"} +\keyword qt-technologies +\section1 Qt Technologies + +Qt introduces an innovative alternative for inter-object communication, called +"signals and slots", that replaces the old and unsafe callback technique used in +many legacy frameworks. Qt also provides a conventional event model for handling +mouse clicks, key presses, and other user input. Qt's cross-platform GUI +applications can support all the user interface functionality required by modern +applications, such as menus, context menus, drag and drop, and dockable +toolbars. Desktop integration features provided by Qt can be used to extend +applications into the surrounding desktop environment, taking advantage of some +of the services provided on each platform. + +The \l{All Modules}{Qt Modules} page has a listing of the technology modules offered by Qt. + +\keyword qt-desktop-meta-object-system +\section2 Qt's Meta-Object System +Qt offers a unique event system based on meta-objects, signals and slots, and property systems. +\list +\o \l{The Meta-Object System}{Qt's Meta-Object System} - Qt's mechanism for signals and slots, inter-object communication, run-time type information, and dynamic property system +\o \l{The Event System}{Event System} - event handling and delivery +\o \l{The Property System}{Property System} - dynamic object properties +\endlist + +\keyword qt-ui-creation +\section2 UI Creation +Qt offers several options with regards to user interface creation: widget based +applications using layouts and Qt Quick interfaces with QML. +\list +\o \l{Qt Quick} - create UIs using QML + \list + \o \l{http://doc.qt.nokia.com/qtcreator-snapshot/creator-visual-editor.html}{Creator's QML Design Mode} - design Qt Quick interfaces using Creator's design mode + \endlist +\o \l{Widgets and Layouts} - primary elements for C++ based interfaces + \list + \o \l{http://doc.qt.nokia.com/qtcreator-snapshot/creator-using-qt-designer.html}{Creator's Designer} - design interfaces using Qt Designer. + \endlist +\o \l{UI Design with Qt} - covers many Qt features for UI creation +\endlist + +\section2 Inter-Process Communication, Threading, and Networking +In addition to \l{qt-desktop-meta-object-system}{Qt's Meta-Object System}, Qt has several technologies +that deal with inter-process communication. +\list +\o \l{Inter-Process Communication in Qt}{Inter-Process Communication} - various overviews of protocols implemented in Qt +\o \l{Network programming with Qt}{Network Programming} - various overviews to network APIs +\o \l{D-Bus} - D-Bus implementation in Qt +\o \l{Thread Support in Qt}{Thread Support} - overview of threading APIs and concurrent programming topics +\endlist + +\keyword qt-rendering-painting-system +\section2 Rendering and Paint System +Qt has various support for different rendering and painting methods. +\list +\o \l{Coordinate System} - Information about the coordinate system used by the paint system +\o \l{Graphics View Framework} - manages a large number of 2D items and visualizes the items +\o \l{Paint System} - A system for painting on the screen or on print devices using the same API +\o \l{QtSvg Module} - module for displaying and creating SVG files +\o Rendering APIs: + \list + \o \l{QtOpenGL Module} - module for rendering with the OpenGL API + \o \l{OpenVG Rendering in Qt}{QtOpenVG Module} - provides support for OpenVG painting + \endlist +\o \l{Printing with Qt} - A guide to producing printed output with Qt's paint system and widgets. +\endlist + +\keyword qt-webkit +\section2 QtWebKit Module +Web applications are increasing in importance and abundance and Qt has +\l{http://www.webkit.org/}{WebKit} support. +\list +\o \l{WebKit in Qt} - WebKit Module +\endlist + +\keyword qt-utilities +\section2 Utilities +Qt supports many utilities that work on multiple platforms. +\list +\o \l{Container Classes}{Containers} - Qt's implementation of various data structures such as linked lists and hash maps +\o \l{Rich Text Processing} - for manipulating structured rich text documents +\o \l{XML Processing} - high level manipulation of XML data using different interfaces +\o \l{Making Applications Scriptable} - provides Qt applications with ECMAScript processor. +\o \l{Qt Linguist Manual}{Qt Linguist} - for translating applications into local languages. +\endlist +For more information, visit the \l{Qt's Tools}{Qt Tools} page. +\enddiv +\div {class="indexboxcont indexboxbar normallist"} +\keyword qt-testing +\section1 Testing Qt Applications +Testing and debugging are part of the development process and Qt offers the +developer multiple methods of testing their code. +\list +\o \l{http://doc.qt.nokia.com/qtcreator-snapshot/creator-debugging.html} {Debugging Applications in Creator} - various debugging options in Creator +\o \l {http://doc.qt.nokia.com/qtsimulator/index.html}{Simulator} - testing mobile applications by simulating a mobile environment +\o \l {QML Viewer} - an executable that is able to run QML files +\o \l{QTestLib Manual}{QTestLib} - a unit testing framework built into Qt +\endlist +\enddiv + +\div {class="indexboxcont indexboxbar normallist"} +\keyword qt-deployment +\section1 Deployment +Symbian phones, Maemo devices, desktop environments, embedded Linux devices -- Qt applications are deployable to many environments. +To deploy Qt applications onto multiple platforms, there are special +considerations that each platform introduce. +\list +\o \l{Deploying Qt Applications}{Deploying Qt Libraries} - compares static versus shared libraries and deploying Qt libraries +\o \l{Deploying Qt Applications#licensing}{Deploying Third Party Libraries} - deployment of libraries that are not under Qt's dual-license model. +\o Platform-Specific Deployment: + \list + \o \l{Deploying an Application on X11 Platforms}{X11} - deploying Qt applications on X11 platforms + \o \l{Deploying an Application on Windows}{Windows} - deploying Qt applications on Windows operating systems + \o \l{Deploying an Application on Mac OS X}{Mac OS X} - deploying Qt applications on Mac OS X + \o \l{Deploying Qt for Embedded Linux Applications}{Embedded Linux} - deploying Qt applications on embedded Linux + \o \l{Deploying an Application on the Symbian Platform}{Symbian} - deploying Qt applications on the Symbian platform + \endlist +\o \l{http://doc.qt.nokia.com/qtcreator-snapshot/creator-deployment-symbian.html}{Symbian Deployment in Creator} - Symbian application deployment built into Creator +\o \l{http://doc.qt.nokia.com/qtcreator-snapshot/creator-deployment-maemo.html}{ Deploying Qt Applications on Maemo Devices} +\endlist + +\section1 Ovi Store Publishing +Creator can publish applications to Ovi Store directly. +\list +\o \l{http://doc.qt.nokia.com/qtcreator-snapshot/creator-publish-ovi.html}{Publishing Qt Applications to Ovi Store} +\endlist +For additional information, visit the \l{Cross-Platform and Platform-Specific Development} +and the \l {Supported Platforms} page. + +\enddiv +\div {class="indexboxcont indexboxbar normallist"} +\section1 Where to Go from Here + +Qt Demos and Examples +\list +\o \l{Qt Demonstrations}{Application Gallery} +\o \l{Tutorials} +\o \l {Qt Examples} +\o \l {QML Examples and Demos} +\endlist + +Qt Information +\list +\o \l{Programming with Qt} +\o \l{UI Design with Qt} +\o \l{Cross-platform and Platform-specific Development} +\o \l{Qt and Key Technologies} +\o \l{Best Practice Guides} +\o \l{Qt Licenses and Credits}{Licenses and Credits} +\endlist +\enddiv +*/ + diff --git a/doc/src/modules.qdoc b/doc/src/modules.qdoc index 38a7a8b..30b0f16 100644 --- a/doc/src/modules.qdoc +++ b/doc/src/modules.qdoc @@ -70,7 +70,7 @@ modules are included by default. To link only against QtCore, add the following line to your \c .pro file: - \snippet doc/src/snippets/code/doc_src_modules.qdoc 0 + \snippet doc/src/snippets/code/doc_src_modules.pro 0 On Windows, if you do not use \l qmake or other build tools such as CMake, you also need to link against @@ -91,7 +91,7 @@ All other Qt modules rely on this module. To include the definitions of the module's classes, use the following directive: - \snippet doc/src/snippets/code/doc_src_qtcore.qdoc 0 + \snippet doc/src/snippets/code/doc_src_qtcore.cpp 0 */ @@ -105,7 +105,7 @@ To include the definitions of both modules' classes, use the following directive: - \snippet doc/src/snippets/code/doc_src_qtgui.qdoc 0 + \snippet doc/src/snippets/code/doc_src_qtgui.pro 0 */ /*! @@ -118,12 +118,12 @@ To include the definitions of the module's classes, use the following directive: - \snippet doc/src/snippets/code/doc_src_qtmultimedia.qdoc 1 + \snippet doc/src/snippets/code/doc_src_qtmultimedia.cpp 1 To link against the module, add this line to your \l qmake \c .pro file: - \snippet doc/src/snippets/code/doc_src_qtmultimedia.qdoc 0 + \snippet doc/src/snippets/code/doc_src_qtmultimedia.pro 0 The functionality provided by the \l{Phonon Module} is on a higher level and in many cases more suitable for application developers. @@ -140,12 +140,12 @@ To include the definitions of the module's classes, use the following directive: - \snippet doc/src/snippets/code/doc_src_qtnetwork.qdoc 1 + \snippet doc/src/snippets/code/doc_src_qtnetwork.cpp 1 To link against the module, add this line to your \l qmake \c .pro file: - \snippet doc/src/snippets/code/doc_src_qtnetwork.qdoc 0 + \snippet doc/src/snippets/code/doc_src_qtnetwork.pro 0 */ /*! @@ -175,12 +175,12 @@ To include the definitions of the module's classes, use the following directive: - \snippet doc/src/snippets/code/doc_src_qtopengl.qdoc 0 + \snippet doc/src/snippets/code/doc_src_qtopengl.cpp 0 To link against the module, add this line to your \l qmake \c .pro file: - \snippet doc/src/snippets/code/doc_src_qtopengl.qdoc 1 + \snippet doc/src/snippets/code/doc_src_qtopengl.pro 1 The Qt OpenGL module is implemented as a platform-independent Qt/C++ wrapper around the platform-dependent GLX (version 1.3 or later), @@ -266,11 +266,11 @@ To include the definitions of the module's classes, use the following directive: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 0 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 0 To link against the module, add this line to your \l qmake \c .pro file: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 1 + \snippet doc/src/snippets/code/doc_src_qtscript.pro 1 For detailed information on how to make your application scriptable with QtScript, see \l{Making Applications @@ -323,11 +323,11 @@ To include the definitions of the module's classes, use the following directive: - \snippet doc/src/snippets/code/doc.src.qtscripttools.qdoc 0 + \snippet doc/src/snippets/code/doc_src_qtscripttools.cpp 0 To link against the module, add this line to your \l qmake \c .pro file: - \snippet doc/src/snippets/code/doc.src.qtscripttools.qdoc 1 + \snippet doc/src/snippets/code/doc_src_qtscripttools.pro 1 */ /*! @@ -338,12 +338,12 @@ To include the definitions of the module's classes, use the following directive: - \snippet doc/src/snippets/code/doc_src_qtsql.qdoc 0 + \snippet doc/src/snippets/code/doc_src_qtsql.cpp 0 To link against the module, add this line to your \l qmake \c .pro file: - \snippet doc/src/snippets/code/doc_src_qtsql.qdoc 1 + \snippet doc/src/snippets/code/doc_src_qtsql.pro 1 See the \l{SQL Programming} guide for information about using this module in your applications. @@ -362,12 +362,12 @@ To include the definitions of the module's classes, use the following directive: - \snippet doc/src/snippets/code/doc_src_qtsvg.qdoc 0 + \snippet doc/src/snippets/code/doc_src_qtsvg.cpp 0 To link against the module, add this line to your \l qmake \c .pro file: - \snippet doc/src/snippets/code/doc_src_qtsvg.qdoc 1 + \snippet doc/src/snippets/code/doc_src_qtsvg.pro 1 \section1 License Information @@ -412,12 +412,12 @@ To include the definitions of the module's classes, use the following directive: - \snippet doc/src/snippets/code/doc_src_qtxml.qdoc 0 + \snippet doc/src/snippets/code/doc_src_qtxml.cpp 0 To link against the module, add this line to your \l qmake \c .pro file: - \snippet doc/src/snippets/code/doc_src_qtxml.qdoc 1 + \snippet doc/src/snippets/code/doc_src_qtxml.pro 1 Further XML support is provided by the \l{Qt Solutions} group who provide, for example, classes that support SOAP and MML with the @@ -437,12 +437,12 @@ To include the definitions of the module's classes, use the following directive: - \snippet doc/src/snippets/code/doc_src_qtxmlpatterns.qdoc 0 + \snippet doc/src/snippets/code/doc_src_qtxmlpatterns.cpp 0 To link against the module, add this line to your \l qmake \c .pro file: - \snippet doc/src/snippets/code/doc_src_qtxmlpatterns.qdoc 1 + \snippet doc/src/snippets/code/doc_src_qtxmlpatterns.pro 1 \section1 Further Reading @@ -523,7 +523,7 @@ The following declaration in a \c qmake project file ensures that an application is compiled and linked appropriately: - \snippet doc/src/snippets/code/doc_src_phonon.qdoc 1 + \snippet doc/src/snippets/code/doc_src_phonon.pro 0 \section1 Qt Backends @@ -586,12 +586,12 @@ To include the definitions of the module's classes, use the following directive: - \snippet doc/src/snippets/code/doc_src_qt3support.qdoc 0 + \snippet doc/src/snippets/code/doc_src_qt3support.cpp 0 To link against the module, add this line to your \l qmake \c .pro file: - \snippet doc/src/snippets/code/doc_src_qt3support.qdoc 1 + \snippet doc/src/snippets/code/doc_src_qt3support.pro 1 \note Since this module provides compatibility classes for diverse parts of the Qt 3 API, it has dependencies on the QtCore, @@ -615,12 +615,12 @@ To include the definitions of the module's classes, use the following directive: - \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 0 + \snippet doc/src/snippets/code/doc_src_qtdesigner.cpp 0 To link against the module, add this line to your \c qmake .pro file: - \snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 1 + \snippet doc/src/snippets/code/doc_src_qtdesigner.pro 1 */ /*! @@ -640,7 +640,7 @@ in a \c qmake project file to ensure that the application is compiled and linked appropriately. - \snippet doc/src/snippets/code/doc_src_qtuiloader.qdoc 0 + \snippet doc/src/snippets/code/doc_src_qtuiloader.pro 0 A form loader object, provided by the QUiLoader class, is used to construct the user interface. This user interface can @@ -652,7 +652,7 @@ To include the definitions of the module's classes, use the following directive: - \snippet doc/src/snippets/code/doc_src_qtuiloader.qdoc 1 + \snippet doc/src/snippets/code/doc_src_qtuiloader.cpp 1 \sa{Calculator Builder Example}, {World Time Clock Builder Example} */ @@ -672,7 +672,7 @@ To include the definitions of the module's classes, use the following directive: - \snippet doc/src/snippets/code/doc_src_qthelp.qdoc 0 + \snippet doc/src/snippets/code/doc_src_qthelp.cpp 0 To link against the module, add this line to your \l qmake \c .pro file: @@ -731,12 +731,12 @@ To include the definitions of the module's classes, use the following directive: - \snippet doc/src/snippets/code/doc_src_qttest.qdoc 0 + \snippet doc/src/snippets/code/doc_src_qttest.cpp 0 To link against the module, add this line to your \l qmake \c .pro file: - \snippet doc/src/snippets/code/doc_src_qttest.qdoc 1 + \snippet doc/src/snippets/code/doc_src_qttest.pro 1 See the \l{QTestLib Manual} for a detailed introduction on how to use Qt's unit testing features with your applications. @@ -865,13 +865,13 @@ To use this module, use the following code in your application: - \snippet doc/src/snippets/code/doc_src_qtdbus.qdoc 0 + \snippet doc/src/snippets/code/doc_src_qtdbus.cpp 0 If you're using qmake to build your application, you can add this line to your .pro file to make it link against the QtDBus libraries: - \snippet doc/src/snippets/code/doc_src_qtdbus.qdoc 1 + \snippet doc/src/snippets/code/doc_src_qtdbus.pro 1 \note The source code for this module is located in the \c{src/qdbus} directory. When installing Qt from source, this module is built when Qt's diff --git a/doc/src/objectmodel/objecttrees.qdoc b/doc/src/objectmodel/objecttrees.qdoc index ba677b9..cb63c17 100644 --- a/doc/src/objectmodel/objecttrees.qdoc +++ b/doc/src/objectmodel/objecttrees.qdoc @@ -77,7 +77,7 @@ behavior applies. Normally, the order of destruction still doesn't present a problem. Consider the following snippet: - \snippet doc/src/snippets/code/doc_src_objecttrees.qdoc 0 + \snippet doc/src/snippets/code/doc_src_objecttrees.cpp 0 The parent, \c window, and the child, \c quit, are both \l {QObject} {QObjects} because QPushButton inherits QWidget, and QWidget inherits @@ -91,7 +91,7 @@ But now consider what happens if we swap the order of construction, as shown in this second snippet: - \snippet doc/src/snippets/code/doc_src_objecttrees.qdoc 1 + \snippet doc/src/snippets/code/doc_src_objecttrees.cpp 1 In this case, the order of destruction causes a problem. The parent's destructor is called first because it was created last. It then calls diff --git a/doc/src/objectmodel/properties.qdoc b/doc/src/objectmodel/properties.qdoc index 7d1ecec..92c182e 100644 --- a/doc/src/objectmodel/properties.qdoc +++ b/doc/src/objectmodel/properties.qdoc @@ -46,12 +46,12 @@ To declare a property, use the \l {Q_PROPERTY()} {Q_PROPERTY()} macro in a class that inherits QObject. - \snippet doc/src/snippets/code/doc_src_properties.qdoc 0 + \snippet doc/src/snippets/code/doc_src_properties.cpp 0 Here are some typical examples of property declarations taken from class QWidget. - \snippet doc/src/snippets/code/doc_src_properties.qdoc 1 + \snippet doc/src/snippets/code/doc_src_properties.cpp 1 A property behaves like a class data member, but it has additional features accessible through the \l {Meta-Object System}. @@ -83,6 +83,10 @@ existing signal in that class that is emitted whenever the value of the property changes. + \o A \c REVISION number is optional. If included, it defines the + the property and its notifier signal to be used in a particular + revision of the API that is exposed to QML. + \o The \c DESIGNABLE attribute indicates whether the property should be visible in the property editor of GUI design tool (e.g., \l {Qt Designer}). Most properties are \c DESIGNABLE (default @@ -131,7 +135,7 @@ be a user-defined type. In this example, class QDate is considered to be a user-defined type. - \snippet doc/src/snippets/code/doc_src_properties.qdoc 2 + \snippet doc/src/snippets/code/doc_src_properties.cpp 2 Because QDate is user-defined, you must include the \c{<QDate>} header file with the property declaration. @@ -152,7 +156,7 @@ the code snippet below, the call to QAbstractButton::setDown() and the call to QObject::setProperty() both set property "down". - \snippet doc/src/snippets/code/doc_src_properties.qdoc 3 + \snippet doc/src/snippets/code/doc_src_properties.cpp 3 Accessing a property through its \c WRITE accessor is the better of the two, because it is faster and gives better diagnostics at @@ -162,7 +166,7 @@ can \e discover a class's properties at run time by querying its QObject, QMetaObject, and \l {QMetaProperty} {QMetaProperties}. - \snippet doc/src/snippets/code/doc_src_properties.qdoc 4 + \snippet doc/src/snippets/code/doc_src_properties.cpp 4 In the above snippet, QMetaObject::property() is used to get \l {QMetaProperty} {metadata} about each property defined in some @@ -189,7 +193,7 @@ for the \c READ and \c WRITE functions. The declaration of MyClass then might look like this: - \snippet doc/src/snippets/code/doc_src_properties.qdoc 5 + \snippet doc/src/snippets/code/doc_src_properties.cpp 5 The \c READ function is const and returns the property type. The \c WRITE function returns void and has exactly one parameter of @@ -200,7 +204,7 @@ QObject that is an instance of MyClass, we have two ways to set its priority property: - \snippet doc/src/snippets/code/doc_src_properties.qdoc 6 + \snippet doc/src/snippets/code/doc_src_properties.cpp 6 In the example, the enumeration type that is the property type is declared in MyClass and registered with the \l{Meta-Object System} @@ -262,7 +266,7 @@ Q_CLASSINFO(), that can be used to attach additional \e{name}--\e{value} pairs to a class's meta-object, for example: - \snippet doc/src/snippets/code/doc_src_properties.qdoc 7 + \snippet doc/src/snippets/code/doc_src_properties.cpp 7 Like other meta-data, class information is accessible at run-time through the meta-object; see QMetaObject::classInfo() for details. diff --git a/doc/src/objectmodel/signalsandslots.qdoc b/doc/src/objectmodel/signalsandslots.qdoc index 4c018b5..8b52df5 100644 --- a/doc/src/objectmodel/signalsandslots.qdoc +++ b/doc/src/objectmodel/signalsandslots.qdoc @@ -440,7 +440,7 @@ You can even use both mechanisms in the same project. Just add the following line to your qmake project (.pro) file. - \snippet doc/src/snippets/code/doc_src_containers.qdoc 22 + \snippet doc/src/snippets/code/doc_src_containers.cpp 22 It tells Qt not to define the moc keywords \c{signals}, \c{slots}, and \c{emit}, because these names will be used by a 3rd party diff --git a/doc/src/overviews.qdoc b/doc/src/overviews.qdoc index f51e320..eb9b2be 100644 --- a/doc/src/overviews.qdoc +++ b/doc/src/overviews.qdoc @@ -42,8 +42,8 @@ Qt is a cross-platform application and UI framework for writing web-enabled applications for desktop, mobile, and embedded operating systems. This page contains links to articles and overviews - explaining key components and techniques used in Qt development. - + explaining key components and techniques used in Qt development. + \generatelist {related} */ @@ -62,7 +62,7 @@ /*! \group qt-graphics - \ingroup qt-basic-concepts + \ingroup qt-basic-concepts \title Qt Graphics and Printing \brief The Qt components for doing graphics. @@ -112,7 +112,7 @@ \ingroup technology-apis \ingroup best-practices \ingroup qt-basic-concepts - + These pages document Qt's API's for using SQL database systems in Qt applications. @@ -133,7 +133,7 @@ \generatelist{related} */ -/*! +/*! \group licensing \title Qt Licenses and Credits @@ -146,3 +146,56 @@ \generatelist {related} */ + +/*! + \group qml-best-practices + \title QML Best Practices Guides + + \brief QML Programming Best Practices Guides + + These documents provide guidelines and best practices for using QML and Qt + to solve specific technical problems. + + \generatelist {related} +*/ +/*! + \group qml-features + \title QML Features + + \brief Features of the QML Language + +These are overviews of the many features of the QML language and \l{Qt Quick}. + +\list +\o \l{QML Basic Elements}{Basic Elements} +\o \l{QML Basic Types}{Data Types} +\o \l{Property Binding} +\o \l{Using QML Positioner and Repeater Items}{Component Layouts} +\o \l{Anchor-based Layout in QML}{Layouts using Anchors} +\o \l{QML Mouse Events}{Mouse Events} +\o \l{QML Text Handling and Validators}{Text Handling and Validators} +\o \l{Keyboard Focus in QML}{Keyboard Focus} +\o \l{QML Signal and Handler Event System}{Signal and Handler Event System} +\o \l{Importing Reusable Components} +\o \l{QML States}{States} +\o \l{QML Animation and Transitions}{Animation and Transitions} +\o \l{QML Data Models}{Structuring Data with Models} +\o \l{Presenting Data with Views} +\o \l{Extending QML Functionalities using C++} +\o \l{Using QML Bindings in C++ Applications} +\o \l{Integrating QML Code with Existing Qt UI Code} +\o \l{Dynamic Object Management in QML}{Dynamic Object Management} +\o \l{Network Transparency}{Loading Resources in QML} +\o \l{QML Internationalization}{Internationalization} +\endlist +*/ +/*! + \group qml-architecture + \title QML Architecture + + \brief QML Architecture + + These are overviews of the architecture of QML and Qt Declarative Module. + + \generatelist {related} +*/ diff --git a/doc/src/painting-and-printing/coordsys.qdoc b/doc/src/painting-and-printing/coordsys.qdoc index 252159e..d0906d8 100644 --- a/doc/src/painting-and-printing/coordsys.qdoc +++ b/doc/src/painting-and-printing/coordsys.qdoc @@ -97,10 +97,10 @@ \row \o - \snippet doc/src/snippets/code/doc_src_coordsys.qdoc 0 + \snippet doc/src/snippets/code/doc_src_coordsys.cpp 0 \o - \snippet doc/src/snippets/code/doc_src_coordsys.qdoc 1 + \snippet doc/src/snippets/code/doc_src_coordsys.cpp 1 \endtable When rendering with a pen with an even number of pixels, the @@ -163,10 +163,10 @@ \row \o - \snippet doc/src/snippets/code/doc_src_coordsys.qdoc 2 + \snippet doc/src/snippets/code/doc_src_coordsys.cpp 2 \o - \snippet doc/src/snippets/code/doc_src_coordsys.qdoc 3 + \snippet doc/src/snippets/code/doc_src_coordsys.cpp 3 \endtable \section1 Transformations @@ -319,7 +319,7 @@ -50) to (50, 50) with (0, 0) in the center by calling the QPainter::setWindow() function: - \snippet doc/src/snippets/code/doc_src_coordsys.qdoc 4 + \snippet doc/src/snippets/code/doc_src_coordsys.cpp 4 Now, the logical coordinates (-50,-50) correspond to the paint device's physical coordinates (0, 0). Independent of the paint @@ -333,7 +333,7 @@ viewport and "window" maintain the same aspect ratio to prevent deformation: - \snippet doc/src/snippets/code/doc_src_coordsys.qdoc 5 + \snippet doc/src/snippets/code/doc_src_coordsys.cpp 5 If we make the logical coordinate system a square, we should also make the viewport a square using the QPainter::setViewport() diff --git a/doc/src/platforms/emb-performance.qdoc b/doc/src/platforms/emb-performance.qdoc index 1ae35bc..6c96921 100644 --- a/doc/src/platforms/emb-performance.qdoc +++ b/doc/src/platforms/emb-performance.qdoc @@ -103,7 +103,7 @@ operators. Improved memory allocation and performance may be gained by re-implementing these functions: - \snippet doc/src/snippets/code/doc_src_emb-performance.qdoc 1 + \snippet doc/src/snippets/code/doc_src_emb-performance.cpp 1 The example above shows the necessary code to switch to the plain C memory allocators. diff --git a/doc/src/platforms/emb-pointer.qdoc b/doc/src/platforms/emb-pointer.qdoc index b580077..941cba2 100644 --- a/doc/src/platforms/emb-pointer.qdoc +++ b/doc/src/platforms/emb-pointer.qdoc @@ -144,7 +144,7 @@ its headers using -L and -I options in the \c qmake.conf file in your \c mkspec. Also it can be helpful to add a -rpath-link: - \snippet doc/src/snippets/code/doc_src_emb-pointer.qdoc 7 + \snippet doc/src/snippets/code/doc_src_emb-pointer.pro 7 In order to use this mouse driver, tslib must also be correctly installed on the target machine. This includes providing a \c diff --git a/doc/src/platforms/mac-differences.qdoc b/doc/src/platforms/mac-differences.qdoc index 251e900..1f71270 100644 --- a/doc/src/platforms/mac-differences.qdoc +++ b/doc/src/platforms/mac-differences.qdoc @@ -99,7 +99,7 @@ If you use \c qmake and Makefiles, use the \c QMAKE_LFLAGS_SONAME setting: - \snippet doc/src/snippets/code/doc_src_mac-differences.qdoc 0 + \snippet doc/src/snippets/code/doc_src_mac-differences.pro 0 Alternatively, you can modify the install name using the install_name_tool(1) on the command line. See its manpage for more @@ -165,7 +165,7 @@ the bundle resides on the disk. The following code returns the path of the application bundle: - \snippet doc/src/snippets/code/doc_src_mac-differences.qdoc 1 + \snippet doc/src/snippets/code/doc_src_mac-differences.cpp 1 Note: When OS X is set to use Japanese, a bug causes this sequence to fail and return an empty string. Therefore, always test the diff --git a/doc/src/platforms/supported-platforms.qdoc b/doc/src/platforms/supported-platforms.qdoc index b58d1d7..f1e8004 100644 --- a/doc/src/platforms/supported-platforms.qdoc +++ b/doc/src/platforms/supported-platforms.qdoc @@ -26,10 +26,688 @@ ****************************************************************************/ /*! + \page windows-support.html + \title Support for Windows + \brief Platform support for Windows. + \ingroup platform-specific + \ingroup platform-details + + \section1 Qt on Windows + + Qt is a comprehensive application and UI framework for developing Windows + applications that can also be deployed across many other desktop and + embedded operating systems without rewriting the source code. Use the + code from one single code-base and rebuild for all + \l{Supported Platforms}{supported Windows versions and other platforms}. + + \section1 Getting Started on Windows + + \list + \o \l{Supported Platforms}{Supported Windows platforms} - Qt + supports a wide range of Windows platforms. + \o \l{Qt for Windows Requirements}{Qt for Windows Requirements} + - Requirements for developing with Qt on Windows. + \o \l{Installing Qt for Windows}{Installing Qt for Windows} + - Build Qt for Windows development. + \o \l{Platform and Compiler Notes - Windows}{Platform and Compiler Notes - Windows} + - Windows platform specific notes. + \o \l{Getting Started Guides}{Getting started} - Getting started developing for Windows + \endlist + + \section1 Key Features for Windows Development + + \section2 Rich Class Library + + The Qt class library includes all the functionality needed to build + advanced GUI applications. + + \list + \o Complete set of customizable \l{UI Design with Qt}{UI + controls/widgets} + \o 3D graphics support with \l{QtOpenGL Module}{OpenGL} + or Direct3D + \o Powerful \l{Thread Support in Qt}{multi-threading} features + \o \l{Graphics View Framework}{2D graphics canvas} capable of + handling millions of items + \o Integrated \l{Phonon multimedia framework}{Phonon multimedia + framework} + \o \l{WebKit in Qt}{WebKit} integration + \o \l{Network programming with Qt}{Networking}, \l{QtXml Module} + {XML} and \l{SQL in Qt}{database} functionality + \o \l{ECMAScript Reference}{ECMA standard} scripting engine + \endlist + + \section2 Integrated Development Tools + + Qt includes a set of integrated development tools to speed + development on the Windows platform. + + \list + \o \l{Qt Designer Manual}{Qt Designer} provides a drag and drop + visual GUI builder. + \o \l{Qt Linguist Manual}{Qt Linguist} provides internationalization + and translation features. + \o \l{Qt Assistant Manual}{Qt Assistant} is a customizable HTML help + file reader providing the complete Qt documentation offline. + \endlist + + \section2 Cross-Platform Development using Qt Creator + + \l{http://doc.qt.nokia.com/qtcreator-snapshot/index.html}{Qt Creator} is + a complete Cross-platform IDE included in the Qt SDK. The IDE allows + programmers to create, build, debug and run Qt applications accross all + supported platforms. + + \section2 Visual Studio Add-in. + + The Qt Visual Studio Add-in allows programmers to create, build, debug + and run Qt applications from within Microsoft Visual Studio 2005, 2008 + and 2010. The add-in contains project wizards, Qt project import/export + support, integrated Qt resource manager and automated build setup for + the Qt Meta-Object Compiler, User Interface Compiler, and Resource + Compiler. + + Additional \l{Cross-Platform and Platform-Specific Development} + information. +*/ + +/*! + \page linuxX11-support.html + \title Support for Linux/X11 + \brief Platform support for Linux/X11. + \ingroup platform-specific + \ingroup platform-details + + \section1 Qt on Linux/X11 + + Qt is a comprehensive application and UI framework for developing + Linux/X11 applications that can also be deployed across many other + desktop and embedded operating systems without rewriting the source code. + Use the code from one single code-base and rebuild for all + \l{Supported Platforms}{supported X11 versions and other platforms}. + + \section1 Getting Started on Linux/X11 + + \list + \o \l{Supported Platforms}{Supported Linux/X11 platforms} - Qt + supports a wide range of Linux/X11 platforms. + \o \l{Qt for X11 Requirements}{Qt for X11 Requirements} + - Software required to run Qt on Linux/X11. + \o \l{Installing Qt for X11 Platforms}{Installing Qt for X11 Platforms} + - Build Qt for Linux/X11 development. + \o \l{Platform and Compiler Notes - X11}{Platform and Compiler Notes - X11} + - Platform specific notes. + \o \l{Getting Started Guides}{Getting started} + \endlist + + \section1 Key Features for Linux/X11 Development + + \section2 Integrated Development Tools + + Qt includes a set of integrated development tools to speed development + on X11 platforms. + + \list + \o \l{Qt Designer Manual}{Qt Designer} provides a drag and drop + visual GUI builder. + \o \l{Qt Linguist Manual}{Qt Linguist} provides internationalization + and translation features. + \o \l{Qt Assistant Manual}{Qt Assistant} is a customizable HTML help + file reader providing the complete Qt documentation offline. + \o Integration with + \l{http://doc.qt.nokia.com/qt-eclipse-1.6/index.html}{Eclipse} + and KDevelop IDEs are also available. + \endlist + + \section2 Cross-Platform Development using Qt Creator + + \l{http://doc.qt.nokia.com/qtcreator-snapshot/index.html}{Qt Creator} is + a complete Cross-platform IDE included in the Qt SDK. The IDE allows + programmers to create, build, debug and run Qt applications accross all + supported platforms. + + \section2 Rich Class Library + + The Qt class library includes all the functionality needed to build + advanced GUI applications. + + \list + \o Complete set of customizable \l{UI Design with Qt}{UI + controls/widgets} + \o 3D graphics support with \l{QtOpenGL Module}{OpenGL + integration} + \o Powerful \l{Thread Support in Qt}{multi-threading} features + \o \l{Graphics View Framework}{2D graphics canvas} capable of + handling millions of items + \o Integrated \l{Phonon multimedia framework}{Phonon multimedia + framework} + \o \l{WebKit in Qt}{WebKit} integration + \o \l{Network programming with Qt}{Networking}, \l{QtXml Module} + {XML} and \l{SQL in Qt}{database} functionality + \o \l{ECMAScript Reference}{ECMA standard} scripting engine + \endlist + + \section2 Qt is the Foundation of KDE + + Qt is best known in the Linux community as the basis for the KDE + desktop environment. Almost everything in KDE is based on Qt, and + Qt forms the foundation for thousands of open source KDE applications + developed by community members worldwide. + + Additional \l{Cross-Platform and Platform-Specific Development} + information. + +*/ + +/*! + \page mac-support.html + \title Support for Mac OS X + \brief Platform support for Mac OS X. + \ingroup platform-specific + \ingroup platform-details + + \section1 Qt on Mac OS X + + Qt is a comprehensive application and UI framework for developing Mac + applications that can also be deployed across many other desktop and + embedded operating systems without rewriting the source code. Use the + code from one single code-base and rebuild for all + \l{Supported Platforms}{supported Windows versions and other platforms}. + + \section1 Getting Started on Mac + + \list + \o \l{Supported Platforms}{Supported Mac OS X platforms} - Qt supports + a wide range of Mac platform variants. + \o \l{Qt for Mac OS X Requirements}{Qt for Mac OS X Requirements} + - Software required to run Qt on Mac OS X. + \o \l{Installing Qt for X11 Platforms}{Installing Qt for X11 Platforms} + - Build Qt for Mac OS X development. + \o \l{Platform and Compiler Notes - Mac OS X}{Platform and Compiler Notes - Mac OS X} + - Platform specific notes. + \o \l{Getting Started Guides}{Getting started} + \endlist + + \section1 Key Features for Mac OS X Development + + \section2 Integrated Development Tools + + Qt includes a set of integrated development tools to speed development + on the Mac platform. + + \list + \o \l{Qt Designer Manual}{Qt Designer} provides a drag and drop + visual GUI builder. + \o \l{Qt Linguist Manual}{Qt Linguist} provides internationalization + and translation features. + \o \l{Qt Assistant Manual}{Qt Assistant} is a customizable HTML help + file reader providing the complete Qt documentation offline. + \endlist + + \section2 Cross-Platform Development using Qt Creator + + \l{http://doc.qt.nokia.com/qtcreator-snapshot/index.html}{Qt Creator} is + a complete Cross-platform IDE included in the Qt SDK. The IDE allows + programmers to create, build, debug and run Qt applications accross all + supported platforms. + + \section2 Rich Class Library + + The Qt class library includes all the functionality needed to build + advanced GUI applications. + + \list + \o Complete set of customizable \l{UI Design with Qt}{UI + controls/widgets} + \o 3D graphics support with \l{QtOpenGL Module}{OpenGL + integration} + \o Powerful \l{Thread Support in Qt}{multi-threading} features + \o \l{Graphics View Framework}{2D graphics canvas} capable of + handling millions of items + \o Integrated \l{Phonon multimedia framework}{Phonon multimedia + framework} + \o \l{WebKit in Qt}{WebKit} integration + \o \l{Network programming with Qt}{Networking}, \l{QtXml Module} + {XML} and \l{SQL in Qt}{database} functionality + \o \l{ECMAScript Reference}{ECMA standard} scripting engine + \endlist + + \section3 Supports Intel Hardware and Universal Binaries + + Qt is written without making assumptions about the number representation, + endianness or architecture of the underlying processor. To support Intel + hardware on the Apple platforms, Qt customers simply need to recompile + their apps. + + Additional \l{Cross-Platform and Platform-Specific Development} + information. + + \note Qt also provides support for 64-bit applications on top of Cocoa APIs. +*/ +/*! + \page windowsCE-Mobile-support.html + \title Support for Windows CE and Windows Mobile + \brief Platform support for Windows CE and Windows Mobile. + \ingroup platform-specific + \ingroup platform-details + + \section1 Qt on Windows CE and Windows Mobile + + Qt is a C++ application and UI framework. You can use Qt to write + rich and high performance applications using an intuitive API + available for a wide range of devices. Use the code from one single + code-base and rebuild for all \l{Supported Platforms}{supported + Windows CE/Mobile versions as well as other other platforms}. + + Supporting most existing Windows CE configurations and with minimal + hardware dependencies, Qt is easy to build even for custom hardware + configurations. Unused components and features can even be compiled out. + + \section1 Getting Started on Windows CE/Mobile + + \list + \o \l{Supported Platforms}{Supported Windows CE/Mobile platforms} + - Qt supports a wide range of Windows CE/Mobile platform variants. + \o \l{Qt for Windows CE Requirements}{Qt for Windows CE/Mobile + Requirements} - Software required to run Qt on Windows CE/Mobile. + \o \l{Installing Qt for Windows CE}{Installing Qt for + Windows CE/Mobile Platforms} - Build Qt for Windows CE/Mobile + development. + \o \l{Platform and Compiler Notes - Windows CE}{Platform and + Compiler Notes - Windows CE/Mobile} - Platform specific notes. + \o \l{Getting Started Guides}{Getting started} + \endlist + + \section1 Key Features for Windows CE/Mobile Development + + On top of all the tools and API and class libraries that Qt offers, + Qt for Windows CE provides you with added functionality for an + optimized embedded development environment. + + \section2 Native and Customizable Look and Feel + + Windows Mobile and Windows CE styles are available with Qt. At runtime, + Qt applications will detect which style to use. The look and feel of + your applications can also be easily customized in a fraction of + the time and lines of code required for traditional UI styling with + Qt Style Sheets. + + \section2 Advanced Text Layout Engine + + Qt for Windows CE supports TrueType and raster fonts. Qt also has + extended Unicode support and right-to-left languages. Qts rich text + engine adds capabilities for complex text layouts including tables, + path tracing and text which flows around shapes. + + \section2 Qt for Windows CE/Mobile also provide support for: + + \list + \o Graphics Acceleration using \l{Qt for Windows CE and OpenGL + ES}{OpenGL ES} + \o \l{Graphics View Framework}{2D graphics canvas} capable of + handling millions of items. + \o \l{Qt Designer Manual}{Qt Designer} for GUI layout and + forms builder. + \o \l{Qt Linguist Manual}{Qt Linguist} provides internationalization + and translation features. + \endlist + + Applications created with Qt for Windows CE/Mobile can be ported to + Symbian, Maemo and any other OS that Qt supports. + + Additional \l{Cross-Platform and Platform-Specific Development} + information. + +*/ + +/*! + \page embeddedLinux-support.html + \title Support for Embedded Linux + \brief Platform support for Embedded Linux. + \ingroup platform-specific + \ingroup platform-details + + \section1 Qt on Embedded Linux + + Qt is the leading application and UI framework for devices powered + by embedded Linux. You can use Qt to create highly memory efficient + devices and applications that have completely unique user experiences. + + Qt runs anywhere Linux runs. Qts intuitive API means fewer lines of + code and higher level functionality in less time. Use the code from + one single code-base and rebuild for all \l{Supported Platforms} + {supported platforms}. + + \section1 Getting Started on Embedded Linux + + \list + \o \l{Supported Platforms}{Supported Linux platforms} + - Qt supports a wide range of Linux platform variants. + \o \l{Qt for Embedded Linux Requirements}{Qt for Embedded Linux + Requirements} - Software required to run Qt on Embedded Linux. + \o \l{Installing Qt for Embedded Linux}{Installing Qt for Embedded + Linux} - Build Qt for development on Embedded Linux. + \o \l{Platform and Compiler Notes - Embedded Linux}{Platform and + Compiler Notes - Embedded Linux} - Platform specific notes. + \o \l{Getting Started Guides}{Getting started} + \endlist + + \section1 Key Features for Embedded Linux Development + + On top of all the tools and API and class libraries that Qt offers, + such as WebKit, Qt for Embedded Linux provides you with key components + for an optimized embedded development environment. + + \section2 Compact and Efficient Windowing System \l{Qt for Embedded Linux Classes}{QWS} + + Qt builds on the standard API for embedded Linux devices with its own + compact window system. Qt-based applications write directly to the + Linux framebuffer, eliminating the need for the X11 windowing system. + + \section2 Virtual Frame Buffer (QVFb) + + Qt for Embedded Linux provides a \l{The Virtual Framebuffer}{virtual + frame buffer} that will match the physical device display, pixel for + pixel. This gives the developer a realistic testing infrastructure + testing on the desktop where the frame buffer simulates the physical + device displays width, height and color depth. + + \section2 Inter-Process Communication (IPC) + + IPC allows for creation of rich multi-application user experiences. + Two main concepts define inter-process communication: channels and + messages. + + \section2 Extended Font Format + + Qt supports a wide range of font formats on embedded Linux including: + TrueType, Postscript Type1 and Qt pre-rendered fonts. Qt has + extended Unicode support including automatic data extraction at build + time and automatic update at runtime. + + Plug-ins for custom font formats are also available allowing new font + engines to be easily added at runtime. Font sharing capabilities + between applications allow for increased memory efficiency. + + Applications created with Qt for Embedded Linux can be ported to + Windows CE and any other OS that Qt supports. + + Additional \l{Cross-Platform and Platform-Specific Development} + information. + +*/ +/*! + \page symbian-support.html + \title Support for Symbian + \brief Platform support for Symbian. + \ingroup platform-specific + \ingroup platform-details + + \section1 Qt on Symbian + + Qt provides support for the Symbian platform with integration + to the S60 framework. If you are developing apps for the Symbian, + Maemo or MeeGo platforms in most cases, you can use Qt under the + free LGPL licensing option. Qt is cross-platform, and that means + that you can use the code from one single code-base and rebuild + for all \l{Supported Platforms}{supported platforms}. + + \section1 Getting Started on Symbian + + \list + \o \l{Supported Platforms}{Supported platform} + - Details on the Qt support for Symbian. + \o \l{Qt for the Symbian platform Requirements}{Qt for the + Symbian platform Requirements} - Software required to run Qt + on Symbian. + \o \l{Installing Qt for the Symbian platform}{Installing Qt + for the Symbian platform} - Build Qt for Symbian development. + \o \l{Platform and Compiler Notes - Symbian}{Platform Notes - Symbian} + - Platform specific notes. + \o \l{Getting Started Guides}{Getting started} + \endlist + + \section1 Key Features for Symbian Development + + On top of all the tools and the API and class libraries that Qt + offers, Qt provides you with added functionality for an optimized + Symbian development experience. + + \section2 Native Look and Feel + + Qt will detect which theme the phone is running and applies the + style at runtime to your Qt application. The look and feel of your + applications can also be easily customized in a fraction of the + time and lines of code required for traditional UI styling with + Qt Style Sheets. + + \section2 Graphics Features + + Qt for Symbian contains a powerful paint engine that provides + features such as anti, aliasing, gradients, curves and transparency. + It also has animation support with timelines and easing curves. It + is already targeting future device technology by supporting hardware + acceleration using OpenVG. + + \section2 Device Configurations + + Using Qt for Symbian all supported Symbian devices provides automatic + support for swiching between landscape and portrait mode, different + screen resolutions as well as touch screen and key pad input. + + \section2 Cross-Platform Development using Qt Creator + + \l{http://doc.qt.nokia.com/qtcreator-snapshot/index.html}{Qt Creator} is + a complete Cross-platform IDE included in the Qt SDK. The IDE allows + programmers to create, build, debug and run Qt applications accross all + supported platforms. + + \section3 Licensing + + Qt for Symbian is available under the Qt Commercial License, the LGPL + v. 2.1 "LGPL") and the GPL v. 3.0. Symbian currently licenses their + software products under either the Symbian Foundation License or the + Eclipse Public License ("EPL"). While the LGPL and the EPL are not + compatible and may not be combined on a file-by-file basis, they may + be used in a common environment provided that the interaction between + Qt and Symbian is limited to: dynamic linking, inter-process + communication and data exchange. Therefore, most Symbian developers + can use Qt for Symbian under the LGPL. + + Additional \l{Cross-Platform and Platform-Specific Development} + information. + +*/ +/*! + \page maemo-support.html + \title Support for Maemo + \brief Platform support for Maemo. + \ingroup platform-specific + \ingroup platform-details + + \section1 Qt on Maemo + + Qt is a comprehensive application and UI framework for developing + Maemo applications that can also be deployed across major + device and desktop operating systems without rewriting the source code. + If you are developing apps for the Symbian, Mameo platforms + in most cases, you can use Qt under the free LGPL licensing option. + Qt is cross-platform, and that means that you can use the code from + one single code-base and rebuild for all \l{Supported Platforms} + {supported platforms}. Maemo 6 is now MeeGo. + + \section1 Getting Started on Maemo + \list + \o \l{Supported Platforms}{Supported Maemo platforms} + - Qt support for Maemo versions. + \omit + \o \l{Qt for Maemo Requirements}{Qt for Maemo + Requirements} - Software required to run Qt on Maemo. + \o \l{Installing Qt for Maemo}{Installing Qt for + Maemo} - Build Qt for Maemo development. + \o \l{Platform and Compiler Notes - Maemo}{Platform and + Compiler Notes - Maemo} - Platform specific notes. + \endomit + \o \l{Getting Started Guides}{Getting started} + \endlist + + \section1 Key Features for Maemo Development + + \section2 Native Look and Feel + + Qt will detect which theme the device is running and applies the + style at runtime to your Qt application. Widgets are optimized + for touch screen usage. + + \section2 Graphics Features + + Qt for Maemo provides a powerful paint engine that cotain + features such as anti aliasing, gradients, curves and transparency. + It also has animation support with timelines and easing curves. Qt + for Maemo also supports hardware acceleration using ARM NEON + and OpenGL ES 2.0. + + \section2 Device Configurations + + Applications developed with Qt for Maemo will across all + supported Maemo devices provide automatic support for switching + between landscape and portrait mode. They will support input methods, + including predictive text input and on-screen keyboard. The + applications will also have support for one finger touch events and + gestures, and have configurable kinetic scrolling. + + \section2 Maemo - Linux/X11 + + Qt supports a wide range of X11 platform variants, such as: Solaris, + AIX, HP-UX, Maemo 5 and MeeGo. Qt for Maemo contains all Qt modules + and features the same functionality as the Qt on X11 version. + + \section2 Cross-Platform Development using Qt Creator + + \l{http://doc.qt.nokia.com/qtcreator-snapshot/index.html}{Qt Creator} is + a complete Cross-platform IDE included in the Qt SDK. The IDE allows + programmers to create, build, debug and run Qt applications accross all + supported platforms. + + Additional \l{Cross-Platform and Platform-Specific Development} + information. +*/ + +/*! + + \page meego-support.html + \title Support for MeeGo + \brief Platform support for MeeGo. + \ingroup platform-specific + \ingroup platform-details + + \section1 Qt on MeeGo + + Qt is a comprehensive application and UI framework for developing + MeeGo applications that can also be deployed across major + device and desktop operating systems without rewriting the source code. + If you are developing apps for the Symbian, MeeGo platforms + in most cases, you can use Qt under the free LGPL licensing option. + Qt is cross-platform, and that means that you can use the code from + one single code-base and rebuild for all \l{Supported Platforms} + {supported platforms}. + + \section1 Getting Started on MeeGo + + \list + \o \l{Supported Platforms}{Supported MeeGo platforms} + - Qt support for MeeGo versions. + \omit + \o \l{Qt for MeeGo Requirements}{Qt for MeeGo + Requirements} - Software required to run Qt on MeeGo. + \o \l{Installing Qt for MeeGo}{Installing Qt for + MeeGo} - Build Qt for MeeGo development. + \o \l{Platform and Compiler Notes - MeeGo}{Platform and + Compiler Notes - MeeGo} - Platform specific notes. + \endomit + \o \l{Getting Started Guides}{Getting started} + \endlist + + \section1 Key Features for MeeGo Development + + \section2 Native Look and Feel + + Qt will detect which theme the device is running and applies the + style at runtime to your Qt application. Widgets are optimized + for touch screen usage. + + \section2 Graphics Features + + Qt for MeeGo provides a powerful paint engine that cotain + features such as anti aliasing, gradients, curves and transparency. + It also has animation support with timelines and easing curves. Qt + for MeeGo also supports hardware acceleration using ARM NEON, x86, + and OpenGL ES 2.0. + + \section2 Device Configurations + + Qt is the foundation of MeeGo UI and application development and + therefore Qt will be present in all upcoming MeeGo devices. Qt + can provide automatic support for: + \list + \o Switching between landscape and portrait mode + \o Input Methods, including predictive text input and on-screen + keyboard + \o Configurable kinetic scrolling + \endlist + + \section2 Maemo - Linux/X11 + + Qt supports a wide range of X11 platform variants, such as: Solaris, + AIX, HP-UX, Maemo 5 and MeeGo. Qt for MeeGo contains all Qt modules + and features the same functionality as the Qt on X11 version. + + \section2 Cross-Platform Development using Qt Creator + + \l{http://doc.qt.nokia.com/qtcreator-snapshot/index.html}{Qt Creator} is + a complete Cross-platform IDE included in the Qt SDK. The IDE allows + programmers to create, build, debug and run Qt applications accross all + supported platforms. + + Additional \l{Cross-Platform and Platform-Specific Development} + information. +*/ + +/*! \page supported-platforms.html \title Supported Platforms \brief The platforms supported by Nokia for Qt. \ingroup platform-specific + \group platform-details + + Qt is a cross-platform application and UI framework. Using Qt, + you can write web-enabled applications once and deploy them + across desktop, mobile and embedded operating systems without + rewriting the source code. + + \section1 Qt is Available for the Following Platforms + + \table + \header + \o {2,1} Qt Cross Platform Support + \header + \o {1,1} Desktop + \o {1,1} Mobile/Embedded + \row + \o \l{Support for Windows}{Windows} + \o \l{Support for Windows CE and Windows Mobile}{Windows CE and Windows Mobile} + \row + \o \l{Support for Linux/X11}{Linux/X11} + \o \l{Support for Embedded Linux}{Embedded Linux} + \row + \o \l{Support for Mac OS X}{Mac OS X} + \o \l{Support for Symbian}{Symbian} + \row + \o\l{Support for MeeGo}{MeeGo} + \o\l{Support for Maemo}{Maemo} + \endtable + + \section1 Supported Platform Details The Qt team strives to provide support for the platforms most frequently used by Qt users. We have designed our internal testing procedure to @@ -70,7 +748,7 @@ \o MSVC 2008 \row \o Microsoft Windows 7 \o MSVC 2008 - \row \o Apple Mac OS X 10.6 "Snow Leopard" + \row \o Apple Mac OS X 10.6 "Snow Leopard" \o As provided by Apple \row \o Apple Mac OS X 10.5 "Leopard" x86_64 (Cocoa 32 and 64bit) \o As provided by Apple @@ -78,6 +756,10 @@ \o gcc (\l{http://www.codesourcery.com/}{Codesourcery version)} \row \o Windows CE 5.0 (ARMv4i, x86, MIPS) \o MSVC 2005 WinCE 5.0 Standard (x86, pocket, smart, mipsii) + \row \o Maemo 5(Linux, ARM, X11) + \o gcc (\l{http://www.scratchbox.org/}{Scratchbox)} + \row \o MeeGo (Linux, ARM, X11) + \o gcc (\l{http://www.scratchbox.org/}{Scratchbox)} \row \o Symbian (Symbian/S60 5.0) \o RVCT 2.2 [build 686 or later], WINSCW 3.2.5 [build 482 or later], GCCE (for applications) \endtable @@ -85,9 +767,9 @@ \section1 Tier 2 Platforms Tier 2 platforms are subject to ad hoc and internal testing. However, Qt users - should note that errors may be present in released product versions for Tier 2 - platforms and, subject to resource availability, known errors in Tier 2 platforms - may or may not be corrected prior to new version releases. + should note that errors may be present in released product versions for Tier 2 + platforms and, subject to resource availability, known errors in Tier 2 platforms + may or may not be corrected prior to new version releases. \table \header \o Platform @@ -116,15 +798,13 @@ \o MSVC 2005 WinCE 5.0 Standard (x86, pocket, smart, mipsii) \row \o Windows Embedded CE 6.0 (ARMv4i, x86, MIPS) \o MSVC 2008 WinCE Embedded 6.0 Professional - \row \o Maemo 5(Linux, ARM, X11) - \o gcc (\l{http://www.scratchbox.org/}{Scratchbox)} \row \o Symbian (Symbian/S60 3.1, 3.2) \o RVCT 2.2 [build 686 or later], WINSCW 3.2.5 [build 482 or later], GCCE (for applications) \endtable - \note The PPC architecture on Mac has been downgraded from tier 1 to tier 2 for 4.7. - - \section1 Tier 3 Platforms (Not supported by Nokia) + \note The PPC architecture on Mac has been downgraded from tier 1 to tier 2 for 4.7. + + \section1 Tier 3 Platforms (Not Supported by Nokia) All platforms not specifically listed above are not supported by Nokia. Nokia does not run its unit test suite or perform any other internal tests on platforms not @@ -147,7 +827,7 @@ warranties and conditions, either express or implied, including, but not limited to, implied warranties of merchantability, fitness for a particular purpose, title and non-infringement with regard to the Licensed Software. - + \section1 Planned Changes for Qt 4.8 The following changes to the list of supported platforms are at time of publishing diff --git a/doc/src/platforms/wince-customization.qdoc b/doc/src/platforms/wince-customization.qdoc index a59dd6f..49ba852 100644 --- a/doc/src/platforms/wince-customization.qdoc +++ b/doc/src/platforms/wince-customization.qdoc @@ -146,7 +146,7 @@ application that attempts to dynamically load the Qt for Windows CE libraries using \c LoadLibrary. The following code can be used for this: - \snippet doc/src/snippets/code/doc_src_wince-customization.qdoc 9 + \snippet doc/src/snippets/code/doc_src_wince-customization.cpp 9 Once you have compiled and deployed the application as well as the Qt libraries, start a remote debugger. The debugger will then print the diff --git a/doc/src/porting/porting-qsa.qdoc b/doc/src/porting/porting-qsa.qdoc index ea83e97..e831583 100644 --- a/doc/src/porting/porting-qsa.qdoc +++ b/doc/src/porting/porting-qsa.qdoc @@ -64,7 +64,7 @@ can have named properties. For instance to create an point object with the properties x and y one would write the following Qt Script code: - \snippet doc/src/snippets/code/doc_src_porting-qsa.qdoc 0 + \snippet doc/src/snippets/code/doc_src_porting-qsa.js 0 The object \c point in this case is constructed as a plain object and we assign two properties, \c x and \c y, to it with the values 12 and @@ -73,17 +73,17 @@ global namespace of the script engine. Similarly, global functions are named properties of the global object; for example: - \snippet doc/src/snippets/code/doc_src_porting-qsa.qdoc 1 + \snippet doc/src/snippets/code/doc_src_porting-qsa.js 1 An equivalent construction that illustrates that the function is a property of the global object is the following assignment: - \snippet doc/src/snippets/code/doc_src_porting-qsa.qdoc 2 + \snippet doc/src/snippets/code/doc_src_porting-qsa.js 2 Since functions are objects, they can be assigned to objects as properties, becoming member functions: - \snippet doc/src/snippets/code/doc_src_porting-qsa.qdoc 3 + \snippet doc/src/snippets/code/doc_src_porting-qsa.js 3 In the code above, we see the first subtle difference between QSA and Qt Script. In QSA one would write the point class like this: @@ -99,7 +99,7 @@ All the code above runs with QSA except the assignment of a function to \c{point.manhattanLength}, which we repeat here for clarity: - \snippet doc/src/snippets/code/doc_src_porting-qsa.qdoc 5 + \snippet doc/src/snippets/code/doc_src_porting-qsa.js 5 This is because, in QSA, the value of \c this is decided based on the location of the declaration of the function it is used in. In the @@ -129,7 +129,7 @@ function with the newly created object as the \c this pointer. So, in a sense, it is equivalent to: - \snippet doc/src/snippets/code/doc_src_porting-qsa.qdoc 8 + \snippet doc/src/snippets/code/doc_src_porting-qsa.js 8 This is similar to the manhattenLength() example above. Again, the main difference between QSA and Qt Script is that one has to @@ -149,7 +149,7 @@ one could write this in Qt Script as: - \snippet doc/src/snippets/code/doc_src_porting-qsa.qdoc 10 + \snippet doc/src/snippets/code/doc_src_porting-qsa.js 10 In QSA, the member functions were part of the class declaration, and were therefore shared between all instances of a given class. @@ -173,7 +173,7 @@ To make the \c toString() function part of the prototype, we write code like this: - \snippet doc/src/snippets/code/doc_src_porting-qsa.qdoc 11 + \snippet doc/src/snippets/code/doc_src_porting-qsa.js 11 Here, we made the \c toString() function part of the prototype so that, when we call \c{car.toString()} it will be resolved via the @@ -195,7 +195,7 @@ without any special members, but it is possible to replace this object with another prototype object. - \snippet doc/src/snippets/code/doc_src_porting-qsa.qdoc 13 + \snippet doc/src/snippets/code/doc_src_porting-qsa.js 13 In the code above, we have a constructor, \c{GasolineCar}, which calls the "base class" implementation of the constructor to @@ -223,7 +223,7 @@ as static members as properties of the constructor function. For example: - \snippet doc/src/snippets/code/doc_src_porting-qsa.qdoc 15 + \snippet doc/src/snippets/code/doc_src_porting-qsa.js 15 Note that in QSA, static member variables were also accessible in instances of the given class. In Qt Script, with the approach @@ -374,7 +374,7 @@ the interpreter using their object names as the names of the variables. - \snippet doc/src/snippets/code/doc_src_porting-qsa.qdoc 16 + \snippet doc/src/snippets/code/doc_src_porting-qsa.cpp 16 The code above adds the button to the global namespace under the name "button". One obvious limitation here is that there is potential for @@ -382,7 +382,7 @@ provides a more flexible way of adding QObjects to the scripting environment. - \snippet doc/src/snippets/code/doc_src_porting-qsa.qdoc 17 + \snippet doc/src/snippets/code/doc_src_porting-qsa.cpp 17 In the code above we create a QPushButton and wrap it in a script value using the function, QScriptEngine::newQObject(). This gives us @@ -404,14 +404,14 @@ Below is listed some code from the filter example in the QSA package. - \snippet doc/src/snippets/code/doc_src_porting-qsa.qdoc 18 + \snippet doc/src/snippets/code/doc_src_porting-qsa.cpp 18 The equivalent in Qt Script is written in much the same way as constructors are written in scripts. We register a callback C++ function under the name "ImageSource" in the global namespace and return the QObject from this function: - \snippet doc/src/snippets/code/doc_src_porting-qsa.qdoc 19 + \snippet doc/src/snippets/code/doc_src_porting-qsa.cpp 19 In the Qt Script case we use the same approach that we use to expose a QObject, namely via QScriptEngine::newQObject(). This function also diff --git a/doc/src/porting/porting4-canvas.qdoc b/doc/src/porting/porting4-canvas.qdoc index 445f66d..1e20384 100644 --- a/doc/src/porting/porting4-canvas.qdoc +++ b/doc/src/porting/porting4-canvas.qdoc @@ -152,7 +152,7 @@ \row \o Q3Canvas::onCanvas() \o The is no equivalent to this function in Graphics View. However, you can combine QGraphicsScene::sceneRect() and QRectF::intersects(): - \snippet doc/src/snippets/code/doc_src_porting4-canvas.qdoc 0 + \snippet doc/src/snippets/code/doc_src_porting4-canvas.cpp 0 \row \o Q3Canvas::rect() \o The equivalent, QGraphicsScene::sceneRect(), returns a QRectF (double @@ -251,7 +251,7 @@ out the public tile API can then be declared as new members of this class. Here is one example of how to implement tile support: - \snippet doc/src/snippets/code/doc_src_porting4-canvas.qdoc 1 + \snippet doc/src/snippets/code/doc_src_porting4-canvas.cpp 1 Depending on how your scene uses tiles, you may be able to simplify this approach. In this example, we will try to mimic the behavior @@ -264,30 +264,30 @@ two-dimensional vector of ints to keep track of what tiles should be used at what parts of the scene. - \snippet doc/src/snippets/code/doc_src_porting4-canvas.qdoc 2 + \snippet doc/src/snippets/code/doc_src_porting4-canvas.cpp 2 In setTiles(), we store the pixmap and tile properties as members of the class. Then we resize the tiles vector to match the width and height of our tile grid. - \snippet doc/src/snippets/code/doc_src_porting4-canvas.qdoc 3 + \snippet doc/src/snippets/code/doc_src_porting4-canvas.cpp 3 The setTile() function updates the tiles index, and then updates the corresponding rect in the scene by calling tileRect(). - \snippet doc/src/snippets/code/doc_src_porting4-canvas.qdoc 4 + \snippet doc/src/snippets/code/doc_src_porting4-canvas.cpp 4 The first tileRect() function returns a QRect for the tile at position (x, y). - \snippet doc/src/snippets/code/doc_src_porting4-canvas.qdoc 5 + \snippet doc/src/snippets/code/doc_src_porting4-canvas.cpp 5 The second tileRect() function returns a QRect for a tile number. With these functions in place, we can implement the drawBackground() function. - \snippet doc/src/snippets/code/doc_src_porting4-canvas.qdoc 6 + \snippet doc/src/snippets/code/doc_src_porting4-canvas.cpp 6 In drawBackground(), we redraw all tiles that have been exposed by intersecting each tile rect with the exposed background @@ -522,7 +522,7 @@ For compatibility, you may want to shift the ellipse up and to the left to keep the ellipse centered. Example: - \snippet doc/src/snippets/code/doc_src_porting4-canvas.qdoc 7 + \snippet doc/src/snippets/code/doc_src_porting4-canvas.cpp 7 Note: QGraphicsEllipseItem uses QAbstractGraphicsShapeItem::pen() for outlines, whereas Q3CanvasEllipse did not use @@ -588,7 +588,7 @@ QPainterPath::moveTo() and QPainterPath::cubicTo(). Here is how you can convert a bezier curve Q3PointArray to a QPainterPath: - \snippet doc/src/snippets/code/doc_src_porting4-canvas.qdoc 8 + \snippet doc/src/snippets/code/doc_src_porting4-canvas.cpp 8 Note: QGraphicsPathItem uses QAbstractGraphicsShapeItem::pen() for outlines, whereas Q3CanvasSpline did not use @@ -653,7 +653,7 @@ functionality using Graphics View, you can load the images by using QDir: - \snippet doc/src/snippets/code/doc_src_porting4-canvas.qdoc 9 + \snippet doc/src/snippets/code/doc_src_porting4-canvas.cpp 9 \section2 Q3CanvasText diff --git a/doc/src/porting/porting4-designer.qdoc b/doc/src/porting/porting4-designer.qdoc index d84af3f..ef3e746 100644 --- a/doc/src/porting/porting4-designer.qdoc +++ b/doc/src/porting/porting4-designer.qdoc @@ -104,7 +104,7 @@ For example, here's the \c uic output for a simple \c helloworld.ui form (some details were removed for simplicity): - \snippet doc/src/snippets/code/doc_src_porting4-designer.qdoc 0 + \snippet doc/src/snippets/code/doc_src_porting4-designer.cpp 0 In this case, the main container was specified to be a QWidget (or any subclass of QWidget). Had we started with a QMainWindow @@ -116,7 +116,7 @@ an instance of the main container (a plain QWidget), and call \c setupUi(): - \snippet doc/src/snippets/code/doc_src_porting4-designer.qdoc 1 + \snippet doc/src/snippets/code/doc_src_porting4-designer.cpp 1 The second approach is to inherit from both the \c Ui::HelloWorld class and the main container, and to call \c setupUi() in the @@ -124,7 +124,7 @@ its subclasses, e.g. QDialog) must appear first in the base class list so that \l{moc} picks it up correctly. For example: - \snippet doc/src/snippets/code/doc_src_porting4-designer.qdoc 2 + \snippet doc/src/snippets/code/doc_src_porting4-designer.cpp 2 This second method is useful when porting Qt 3 forms to Qt 4. \c HelloWorldWidget is a class whose instance is the actual form @@ -212,7 +212,7 @@ them to the widgets in the form after calling \c setupUi(). For example: - \snippet doc/src/snippets/code/doc_src_porting4-designer.qdoc 5 + \snippet doc/src/snippets/code/doc_src_porting4-designer.cpp 5 A quick and dirty way to port forms containing custom signals and slots is to generate the code using \c uic3, rather than \c uic. Since @@ -233,7 +233,7 @@ \tt{\e{signalName}}, then this signal will be connected to the main container's slot. For example: - \snippet doc/src/snippets/code/doc_src_porting4-designer.qdoc 6 + \snippet doc/src/snippets/code/doc_src_porting4-designer.cpp 6 Because of the naming convention, \c setupUi() automatically connects \c pushButton's \c clicked() signal to \c @@ -257,14 +257,14 @@ Next, we add the resource file to our \c .pro file: - \snippet doc/src/snippets/code/doc_src_porting4-designer.qdoc 8 + \snippet doc/src/snippets/code/doc_src_porting4-designer.pro 8 When \c qmake is run, it will create the appropriate Makefile rules to call \c rcc on the resource file, and compile and link the result into the application. The icons may be accessed as follows: - \snippet doc/src/snippets/code/doc_src_porting4-designer.qdoc 9 + \snippet doc/src/snippets/code/doc_src_porting4-designer.cpp 9 In each case, the leading colon tells Qt to look for the file in the virtual file tree defined by the set of resource files diff --git a/doc/src/porting/porting4-dnd.qdoc b/doc/src/porting/porting4-dnd.qdoc index 92b9fc1..993b8d2 100644 --- a/doc/src/porting/porting4-dnd.qdoc +++ b/doc/src/porting/porting4-dnd.qdoc @@ -54,7 +54,7 @@ \l{Q3DragObject::}{drag()} function is called, and it receives no information about how the operation ended. - \snippet doc/src/snippets/code/doc_src_dnd.qdoc 0 + \snippet doc/src/snippets/code/doc_src_dnd.cpp 0 Similarly, in Qt 4, drag operations are also initiated when a QDrag object is constructed and its \l{QDrag::}{exec()} function is called. In contrast, @@ -94,7 +94,7 @@ indicating success or failure of these checks via the event's \l{QDragEnterEvent::}{accept()} function, as shown in this simple example: - \snippet doc/src/snippets/code/doc_src_dnd.qdoc 1 + \snippet doc/src/snippets/code/doc_src_dnd.cpp 1 In Qt 4, you can examine the MIME type describing the data to determine whether the widget should accept the event or, for common data types, you @@ -113,7 +113,7 @@ accept dropped data in the form of text or images might provide an implementation of \l{QWidget::}{dropEvent()} that looks like the following: - \snippet doc/src/snippets/code/doc_src_dnd.qdoc 2 + \snippet doc/src/snippets/code/doc_src_dnd.cpp 2 In Qt 4, the event is handled in a similar way: diff --git a/doc/src/porting/porting4.qdoc b/doc/src/porting/porting4.qdoc index a3960c3..1c11a02 100644 --- a/doc/src/porting/porting4.qdoc +++ b/doc/src/porting/porting4.qdoc @@ -760,7 +760,7 @@ function. The solution is to reimplement QWidget::paintEvent() in your QAbstractButton subclass as follows: - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 0 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 0 \table \header \o Q3Button function \o QAbstractButton equivalent @@ -860,11 +860,11 @@ \o QMemArray::at() returned a non-const reference, whereas the new QByteArray::at() returns a const value. Code like - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 1 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 1 will no longer compile. Instead, use QByteArray::operator[]: - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 2 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 2 \o The QMemArray::contains(char) function has been renamed QByteArray::count(char). In addition, there now exists a @@ -935,11 +935,11 @@ function returns \c void and either adds it to the cache or deletes it right away. Old code like - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 3 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 3 becomes - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 4 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 4 \o The new QCache class \e always takes ownership of the items it stores (i.e. auto-delete is always on). If you use Q3Cache @@ -950,11 +950,11 @@ pointers, not the objects that the pointers refer to. For example, - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 5 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 5 becomes - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 6 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 6 An alternative is to stick to using Q3Cache. \endlist @@ -1051,7 +1051,7 @@ you can simply replace colorGroup() with palette(): - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 7 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 7 \section1 QColorDrag @@ -1089,7 +1089,7 @@ '\\0' issue is handled by having QByteArray allocate one extra byte that it always sets to '\\0'. For example: - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 8 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 8 The Qt3Support library contains a class called Q3CString that inherits from the new QByteArray class and that @@ -1416,26 +1416,26 @@ \header \o Q3Dict idiom \o QMultiHash idiom \row \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 9 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 9 \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 10 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 10 \row \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 11 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 11 \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 12 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 12 \row \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 13 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 13 (also called from Q3Dict's destructor) \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 14 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 14 In 99% of cases, the following idiom also works: - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 15 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 15 However, it may lead to crashes if \c hash is referenced from the value type's destructor, because \c hash contains @@ -1471,11 +1471,11 @@ Be aware that QHashIterator has a different way of iterating than Q3DictIterator. A typical loop with Q3DictIterator looks like this: - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 16 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 16 Here's the equivalent QHashIterator loop: - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 17 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 17 See \l{Java-style iterators} for details. @@ -2377,7 +2377,7 @@ Use QObject::findChildren() instead of QObject::queryList(). For example: - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 18 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 18 QObject::killTimers() has been removed because it was unsafe to use in subclass. (A subclass normally doesn't know whether the @@ -2712,48 +2712,48 @@ \header \o QPtrList idiom \o QList idiom \row \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 19 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 19 \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 20 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 20 \row \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 21 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 21 \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 22 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 22 \row \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 23 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 23 \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 24 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 24 \row \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 25 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 25 \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 26 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 26 \row \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 27 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 27 \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 28 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 28 \row \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 29 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 29 (removes the current item) \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 30 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 30 \row \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 31 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 31 (also called from QPtrList's destructor) \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 32 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 32 In 99% of cases, the following idiom also works: - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 33 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 33 However, it may lead to crashes if \c list is referenced from the value type's destructor, because \c list contains @@ -2790,11 +2790,11 @@ Be aware that QListIterator has a different way of iterating than QPtrList. A typical loop with QPtrList looks like this: - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 34 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 34 Here's the equivalent QListIterator loop: - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 35 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 35 Finally, QPtrListIterator<T> must also be ported. There are no fewer than four iterator classes that can be used as a @@ -2821,11 +2821,11 @@ iterating than QPtrList. A typical loop with QPtrList looks like this: - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 36 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 36 Here's the equivalent QListIterator loop: - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 37 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 37 Finally, QPtrListStdIterator<T> must also be ported. This is easy, because QList also provides STL-style iterators @@ -2864,26 +2864,26 @@ \header \o QPtrQueue idiom \o QQueue idiom \row \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 38 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 38 \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 39 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 39 \row \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 40 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 40 \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 41 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 41 \row \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 42 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 42 (also called from QPtrQueue's destructor) \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 43 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 43 In 99% of cases, the following idiom also works: - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 44 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 44 However, it may lead to crashes if \c queue is referenced from the value type's destructor, because \c queue contains @@ -2923,26 +2923,26 @@ \header \o QPtrStack idiom \o QStack idiom \row \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 45 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 45 \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 46 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 46 \row \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 47 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 47 \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 48 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 48 \row \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 49 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 49 (also called from QPtrStack's destructor) \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 50 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 50 In 99% of cases, the following idiom also works: - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 51 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 51 However, it may lead to crashes if \c stack is referenced from the value type's destructor, because \c stack contains @@ -3024,36 +3024,36 @@ \header \o QPtrVector idiom \o QVector idiom \row \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 52 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 52 \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 53 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 53 \row \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 54 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 54 \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 55 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 55 \row \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 56 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 56 \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 57 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 57 \row \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 58 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 58 \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 59 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 59 \row \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 60 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 60 (also called from QPtrVector's destructor) \o - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 61 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 61 In 99% of cases, the following idiom also works: - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 62 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 62 However, it may lead to crashes if \c vect is referenced from the value type's destructor, because \c vect contains @@ -3193,7 +3193,7 @@ An easy way of porting to Qt 4 is to include this class into your project and to use it instead of \c QShared: - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 63 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 63 If possible, we recommend that you use QSharedData and QSharedDataPointer instead. They provide thread-safe reference @@ -3217,11 +3217,11 @@ Previously, you would do the following with Q3SimpleRichText: - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 63a + \snippet doc/src/snippets/code/doc_src_porting4.cpp 63a However, with QTextDocument, you use the following code instead: - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 63b + \snippet doc/src/snippets/code/doc_src_porting4.cpp 63b See \l{Rich Text Processing} for an overview of the Qt 4 rich text classes. @@ -3233,7 +3233,7 @@ The slider's rect can now be retrieved using the code snippet below: - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 63c + \snippet doc/src/snippets/code/doc_src_porting4.cpp 63c In addition, the direction of a vertical QSlider has changed, i.e. the bottom is now the minimum, and the top the maximum. You @@ -3454,7 +3454,7 @@ byte array; you should avoid taking a pointer to the data contained in temporary objects. - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 64 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 64 In the above example, the \c goodData pointer is valid for the lifetime of the \c asciiData byte array. If you need to keep a copy of the data @@ -3464,11 +3464,11 @@ \o QString::at() returned a non-const reference, whereas the new QString::at() returns a const value. Code like - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 65 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 65 will no longer compile. Instead, use QString::operator[]: - \snippet doc/src/snippets/code/doc_src_porting4.qdoc 66 + \snippet doc/src/snippets/code/doc_src_porting4.cpp 66 \o The QString::contains(\e x) function (where \e x is a character or a string) has been renamed QString::count(\e x). diff --git a/doc/src/porting/qt3to4.qdoc b/doc/src/porting/qt3to4.qdoc index 336601f..3c95b4c 100644 --- a/doc/src/porting/qt3to4.qdoc +++ b/doc/src/porting/qt3to4.qdoc @@ -122,7 +122,7 @@ In some cases, you might get compiler errors because of identifiers in the global namespace (e.g., \c CTRL). Adding - \snippet doc/src/snippets/code/doc_src_qt3to4.qdoc 2 + \snippet doc/src/snippets/code/doc_src_qt3to4.cpp 2 at the beginning of the source file that contains the indentifier solves the problem. diff --git a/doc/src/porting/qt4-accessibility.qdoc b/doc/src/porting/qt4-accessibility.qdoc index 6e56942..2d9e8c3 100644 --- a/doc/src/porting/qt4-accessibility.qdoc +++ b/doc/src/porting/qt4-accessibility.qdoc @@ -68,7 +68,7 @@ variable set to 1. For example, this is set in the following way with the bash shell: - \snippet doc/src/snippets/code/doc_src_qt4-accessibility.qdoc environment + \snippet doc/src/snippets/code/doc_src_qt4-accessibility.cpp environment Accessibility features are built into Qt by default when the libraries are configured and built. @@ -132,17 +132,17 @@ information for a custom widget. We can use QAccessibleWidget as a base class and reimplement various functions: - \snippet doc/src/snippets/code/doc_src_qt4-accessibility.qdoc 0 + \snippet doc/src/snippets/code/doc_src_qt4-accessibility.cpp 0 Here's how we would implement the \l{QAccessibleInterface::doAction()}{doAction()} function to call a function named click() on the wrapped MyWidget object when the user invokes the object's default action or "presses" it. - \snippet doc/src/snippets/code/doc_src_qt4-accessibility.qdoc 1 + \snippet doc/src/snippets/code/doc_src_qt4-accessibility.cpp 1 To export the widget interface as a plugin, we must subclass QAccessibleFactory: - \snippet doc/src/snippets/code/doc_src_qt4-accessibility.qdoc 2 + \snippet doc/src/snippets/code/doc_src_qt4-accessibility.cpp 2 */ diff --git a/doc/src/porting/qt4-arthur.qdoc b/doc/src/porting/qt4-arthur.qdoc index 434aa29..460a048 100644 --- a/doc/src/porting/qt4-arthur.qdoc +++ b/doc/src/porting/qt4-arthur.qdoc @@ -119,7 +119,7 @@ Setting a linear gradient brush is done by creating a QLinearGradient object and setting it as a brush. - \snippet doc/src/snippets/code/doc_src_qt4-arthur.qdoc 0 + \snippet doc/src/snippets/code/doc_src_qt4-arthur.cpp 0 The code shown above produces a pattern as show in the following pixmap: @@ -130,7 +130,7 @@ focal point. Setting a radial brush is done by creating a QRadialGradient object and setting it as a brush. - \snippet doc/src/snippets/code/doc_src_qt4-arthur.qdoc 1 + \snippet doc/src/snippets/code/doc_src_qt4-arthur.cpp 1 The code shown above produces a pattern as shown in the following pixmap: @@ -141,7 +141,7 @@ angle. Setting a conical brush is done by creating a QConicalGradient object and setting it as a brush. - \snippet doc/src/snippets/code/doc_src_qt4-arthur.qdoc 2 + \snippet doc/src/snippets/code/doc_src_qt4-arthur.cpp 2 The code shown above produces a pattern as shown in the following pixmap: @@ -156,7 +156,7 @@ transparent color, while 255 represents a fully opaque color. For example: - \snippet doc/src/snippets/code/doc_src_qt4-arthur.qdoc 3 + \snippet doc/src/snippets/code/doc_src_qt4-arthur.cpp 3 The code shown above produces the following output: @@ -180,7 +180,7 @@ provide the option of turning on anti-aliased edges when drawing graphics primitives. - \snippet doc/src/snippets/code/doc_src_qt4-arthur.qdoc 4 + \snippet doc/src/snippets/code/doc_src_qt4-arthur.cpp 4 This produces the following output: @@ -221,7 +221,7 @@ first add a rectangle, which becomes a closed subpath. We then add two bezier curves, and finally draw the entire path. - \snippet doc/src/snippets/code/doc_src_qt4-arthur.qdoc 5 + \snippet doc/src/snippets/code/doc_src_qt4-arthur.cpp 5 The code above produces the following output: @@ -236,18 +236,18 @@ painting to an off-screen pixmap then copying the pixmap to the screen. For example: - \snippet doc/src/snippets/code/doc_src_qt4-arthur.qdoc 6 + \snippet doc/src/snippets/code/doc_src_qt4-arthur.cpp 6 Since the double-buffering is handled by QWidget internally this now becomes: - \snippet doc/src/snippets/code/doc_src_qt4-arthur.qdoc 7 + \snippet doc/src/snippets/code/doc_src_qt4-arthur.cpp 7 Double-buffering is turned on by default, but can be turned off for individual widgets by setting the widget attribute Qt::WA_PaintOnScreen. - \snippet doc/src/snippets/code/doc_src_qt4-arthur.qdoc 8 + \snippet doc/src/snippets/code/doc_src_qt4-arthur.cpp 8 \section2 Pen and Brush Transformation @@ -270,7 +270,7 @@ possible to specify both texture and gradient fills for both text and outlines. - \snippet doc/src/snippets/code/doc_src_qt4-arthur.qdoc 9 + \snippet doc/src/snippets/code/doc_src_qt4-arthur.cpp 9 The code above produces the following output: @@ -290,7 +290,7 @@ Painting on an image is as simple as drawing on any other paint device. - \snippet doc/src/snippets/code/doc_src_qt4-arthur.qdoc 10 + \snippet doc/src/snippets/code/doc_src_qt4-arthur.cpp 10 \section2 SVG Rendering Support diff --git a/doc/src/porting/qt4-mainwindow.qdoc b/doc/src/porting/qt4-mainwindow.qdoc index 1eff2c2..ebfbc8d 100644 --- a/doc/src/porting/qt4-mainwindow.qdoc +++ b/doc/src/porting/qt4-mainwindow.qdoc @@ -86,7 +86,7 @@ the first time it is called. You can also call QMainWindow::setMenuBar() to use a custom menu bar in the main window. - \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.qdoc 0 + \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.cpp 0 \dots \snippet examples/mainwindows/menus/mainwindow.cpp 5 \dots @@ -110,7 +110,7 @@ \snippet examples/mainwindows/sdi/mainwindow.cpp 0 \dots - \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.qdoc 1 + \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.cpp 1 In this example, the toolbar is restricted to the top and bottom toolbar areas of the main window, and is initially placed in the @@ -132,7 +132,7 @@ required, the default can be changed with the QMainWindow::setCorner() function: - \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.qdoc 2 + \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.cpp 2 The following diagram shows the configuration produced by the above code. Note that the left and right dock widgets will occupy the top and bottom @@ -143,7 +143,7 @@ Once all of the main window components have been set up, the central widget is created and installed by using code similar to the following: - \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.qdoc 3 + \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.cpp 3 The central widget can be any subclass of QWidget. @@ -217,17 +217,17 @@ constructed using the general QMenu class. Qt 3: - \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.qdoc 4 + \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.cpp 4 Qt 4: - \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.qdoc 5 + \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.cpp 5 Toolbars follow the same pattern as menus, with the new, more consistent behavior: Qt 3: - \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.qdoc 6 + \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.cpp 6 Qt 4: - \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.qdoc 7 + \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.cpp 7 The behavior of dock widgets is now configured through the member functions of QDockWidget. For example, compare the old and new ways @@ -235,7 +235,7 @@ main window. In Qt 3: - \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.qdoc 8 + \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.cpp 8 In Qt 4: - \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.qdoc 9 + \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.cpp 9 */ diff --git a/doc/src/porting/qt4-sql.qdoc b/doc/src/porting/qt4-sql.qdoc index bafaacb..2a5a206 100644 --- a/doc/src/porting/qt4-sql.qdoc +++ b/doc/src/porting/qt4-sql.qdoc @@ -104,12 +104,12 @@ The simplest way to present data from a database is to simply combine a QSqlQueryModel with a QTableView: - \snippet doc/src/snippets/code/doc_src_qt4-sql.qdoc 0 + \snippet doc/src/snippets/code/doc_src_qt4-sql.cpp 0 To present the contents of a single table, we can use QSqlTableModel instead: - \snippet doc/src/snippets/code/doc_src_qt4-sql.qdoc 1 + \snippet doc/src/snippets/code/doc_src_qt4-sql.cpp 1 In practice, it's common that we need to customize the rendering of a field in the database. In that case, we can create our own diff --git a/doc/src/porting/qt4-styles.qdoc b/doc/src/porting/qt4-styles.qdoc index 76b0b1c..7422f06 100644 --- a/doc/src/porting/qt4-styles.qdoc +++ b/doc/src/porting/qt4-styles.qdoc @@ -90,7 +90,7 @@ pointer type is correct. If the object isn't of the right type, qstyleoption_cast() returns 0. For example: - \snippet doc/src/snippets/code/doc_src_qt4-styles.qdoc 0 + \snippet doc/src/snippets/code/doc_src_qt4-styles.cpp 0 For performance reasons, there are few member functions and the access to the variables is direct. This "low-level" feel makes @@ -108,7 +108,7 @@ The following code snippet illustrates how to use QStyle to draw the focus rectangle from a custom widget's paintEvent(): - \snippet doc/src/snippets/code/doc_src_qt4-styles.qdoc 1 + \snippet doc/src/snippets/code/doc_src_qt4-styles.cpp 1 The next example shows how to derive from an existing style to customize the look of a graphical element: @@ -130,11 +130,11 @@ For example, here's the signature of the QStyle::drawControl() function in Qt 3: - \snippet doc/src/snippets/code/doc_src_qt4-styles.qdoc 2 + \snippet doc/src/snippets/code/doc_src_qt4-styles.cpp 2 Here's the signature of the same function in Qt 4: - \snippet doc/src/snippets/code/doc_src_qt4-styles.qdoc 3 + \snippet doc/src/snippets/code/doc_src_qt4-styles.cpp 3 In Qt 3, some of the information required to draw a graphical element was stored in a QStyleOption parameter, while the rest diff --git a/doc/src/porting/qt4-tulip.qdoc b/doc/src/porting/qt4-tulip.qdoc index 161c373..c78ff96 100644 --- a/doc/src/porting/qt4-tulip.qdoc +++ b/doc/src/porting/qt4-tulip.qdoc @@ -80,16 +80,16 @@ addition to the C++ language that is implemented using the standard C++ preprocessor. The syntax is: - \snippet doc/src/snippets/code/doc_src_qt4-tulip.qdoc 0 + \snippet doc/src/snippets/code/doc_src_qt4-tulip.cpp 0 Example: - \snippet doc/src/snippets/code/doc_src_qt4-tulip.qdoc 1 + \snippet doc/src/snippets/code/doc_src_qt4-tulip.cpp 1 The iterator variable can also be defined outside the loop. For example: - \snippet doc/src/snippets/code/doc_src_qt4-tulip.qdoc 2 + \snippet doc/src/snippets/code/doc_src_qt4-tulip.cpp 2 Just like standard \c for loops, foreach supports braces, \c break, \c continue, and nested loops. Qt makes a copy of the @@ -124,25 +124,25 @@ Traversing a container using a Java-style iterator: - \snippet doc/src/snippets/code/doc_src_qt4-tulip.qdoc 3 + \snippet doc/src/snippets/code/doc_src_qt4-tulip.cpp 3 Modifying items using a Java-style iterator: - \snippet doc/src/snippets/code/doc_src_qt4-tulip.qdoc 4 + \snippet doc/src/snippets/code/doc_src_qt4-tulip.cpp 4 Removing items using a Java-style iterator: - \snippet doc/src/snippets/code/doc_src_qt4-tulip.qdoc 5 + \snippet doc/src/snippets/code/doc_src_qt4-tulip.cpp 5 Iterating over items with a particular value using STL-style vs. Java-style iterators: - \snippet doc/src/snippets/code/doc_src_qt4-tulip.qdoc 6 + \snippet doc/src/snippets/code/doc_src_qt4-tulip.cpp 6 Modifying and removing items using STL-style vs. Java-style iterators: - \snippet doc/src/snippets/code/doc_src_qt4-tulip.qdoc 7 + \snippet doc/src/snippets/code/doc_src_qt4-tulip.cpp 7 The next group of examples show the API of the container classes themselves. The API is similar to the QTL classes of Qt 3, but is nicer @@ -151,16 +151,16 @@ Iterating over a QList using an index (which is fast even for large lists, because QList is implemented as an array-list): - \snippet doc/src/snippets/code/doc_src_qt4-tulip.qdoc 8 + \snippet doc/src/snippets/code/doc_src_qt4-tulip.cpp 8 Retrieving a value from a map, using a default value if the key doesn't exist: - \snippet doc/src/snippets/code/doc_src_qt4-tulip.qdoc 9 + \snippet doc/src/snippets/code/doc_src_qt4-tulip.cpp 9 Getting all the values for a particular key in a QMultiMap or QMultiHash: - \snippet doc/src/snippets/code/doc_src_qt4-tulip.qdoc 10 + \snippet doc/src/snippets/code/doc_src_qt4-tulip.cpp 10 \section1 Comparison with Qt 3 diff --git a/doc/src/qt-webpages.qdoc b/doc/src/qt-webpages.qdoc index 5a3bfc9..e915267 100644 --- a/doc/src/qt-webpages.qdoc +++ b/doc/src/qt-webpages.qdoc @@ -246,6 +246,21 @@ */ /*! + \externalpage http://doc.qt.nokia.com/qtcreator-snapshot/index.html + \title Qt Creator Manual +*/ + +/*! + \externalpage http://doc.qt.nokia.com/qtcreator-snapshot/creator-qml-application.html + \title Developing Qt Quick Applications with Creator +*/ + +/*! \externalpage http://qt.gitorious.org/qt/pages/QtCodingStyle \title Qt Coding Style */ + +/*! + \externalpage http://qt.nokia.com/developer/learning/online/training/training-day-at-developer-days-2009/ + \title Training Day at Qt Developer Days 2009 +*/ diff --git a/doc/src/qt4-intro.qdoc b/doc/src/qt4-intro.qdoc index 3cabb1c..41848e9 100644 --- a/doc/src/qt4-intro.qdoc +++ b/doc/src/qt4-intro.qdoc @@ -241,7 +241,9 @@ \section1 Build System Unlike previous Qt releases, Qt 4 is a collection of smaller - libraries: + libraries. A complete list of libraries in the current release + of Qt can be found on the \l{All Modules} page. The following + table describes the initial set of libraries released with Qt 4. \table \header \o Library \o Description @@ -276,11 +278,11 @@ link your application against QtCore and QtGui. To remove the dependency upon QtGui, add the line - \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 0 + \snippet doc/src/snippets/code/doc_src_qt4-intro.pro 0 to your .pro file. To enable the other libraries, add the line - \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 1 + \snippet doc/src/snippets/code/doc_src_qt4-intro.pro 1 Another change to the build system is that moc now understands preprocessor directives. qmake automatically passes the defines set @@ -290,21 +292,21 @@ To compile code that uses UI files, you will also need this line in the .pro file: - \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 2 + \snippet doc/src/snippets/code/doc_src_qt4-intro.pro 2 \section1 Include Syntax The syntax for including Qt class definitions has become - \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 3 + \snippet doc/src/snippets/code/doc_src_qt4-intro.cpp 3 For example: - \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 4 + \snippet doc/src/snippets/code/doc_src_qt4-intro.cpp 4 This is guaranteed to work for any public Qt class. The old syntax, - \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 5 + \snippet doc/src/snippets/code/doc_src_qt4-intro.cpp 5 still works, but we encourage you to switch to the new syntax. @@ -318,7 +320,7 @@ To include the definitions for all the classes in a library, simply specify the name of that library. For example: - \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 6 + \snippet doc/src/snippets/code/doc_src_qt4-intro.cpp 6 \section1 Namespaces @@ -330,7 +332,7 @@ to access a constant that is part of the Qt namespace, prefix it with \c{Qt::} (e.g., \c{Qt::yellow}), or add the directive - \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 7 + \snippet doc/src/snippets/code/doc_src_qt4-intro.cpp 7 at the top of your source files, after your \c #include directives. If you use the \c{using namespace} syntax you don't @@ -360,7 +362,7 @@ \list \o Code that used it looked confusing, for example: - \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 8 + \snippet doc/src/snippets/code/doc_src_qt4-intro.cpp 8 \c label1 is a QLabel that displays the text "Hello"; \c label2 is a QLabel with no text, with the object name @@ -370,7 +372,7 @@ they blindly followed Qt's convention and provided a "const char *name" in their subclasses's constructors. For example: - \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 9 + \snippet doc/src/snippets/code/doc_src_qt4-intro.cpp 9 \o The name parameter was in Qt since version 1, and it always was documented as: "It is not very useful in the current @@ -405,12 +407,12 @@ Here's the Qt 3 idiom to cast a type to a subtype: - \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 10 + \snippet doc/src/snippets/code/doc_src_qt4-intro.cpp 10 The Qt 4 idiom is both cleaner and safer, because typos will always result in compiler errors: - \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 11 + \snippet doc/src/snippets/code/doc_src_qt4-intro.cpp 11 \section1 QPointer<T> @@ -421,7 +423,7 @@ Example: - \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 12 + \snippet doc/src/snippets/code/doc_src_qt4-intro.cpp 12 QPointer<T> is more or less the same as the old QGuardedPtr<T> class, except that it is now implemented in a much more lightweight manner @@ -461,7 +463,7 @@ To enable the Qt 3 support classes and functions, add the line - \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 13 + \snippet doc/src/snippets/code/doc_src_qt4-intro.pro 13 to your \c .pro file. @@ -469,18 +471,18 @@ in a compiler warning (e.g., "'find' is deprecated"). If you want to turn off that warning, add the line - \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 14 + \snippet doc/src/snippets/code/doc_src_qt4-intro.pro 14 to your \c .pro file. If you want to use compatibility functions but don't want to link against the Qt3Support library, add the line - \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 15 + \snippet doc/src/snippets/code/doc_src_qt4-intro.pro 15 or - \snippet doc/src/snippets/code/doc_src_qt4-intro.qdoc 16 + \snippet doc/src/snippets/code/doc_src_qt4-intro.pro 16 to your \c .pro file, depending on whether you want compatibility function calls to generate compiler warnings or not. diff --git a/doc/src/scripting/qtscriptextensions.qdoc b/doc/src/scripting/qtscriptextensions.qdoc index 888cf73..431adb0 100644 --- a/doc/src/scripting/qtscriptextensions.qdoc +++ b/doc/src/scripting/qtscriptextensions.qdoc @@ -68,7 +68,7 @@ An example of a simple \c{__init__.js}: - \snippet doc/src/snippets/code/doc_src_qtscriptextensions.qdoc 0 + \snippet doc/src/snippets/code/doc_src_qtscriptextensions.js 0 QScriptEngine will look for a QScriptExtensionPlugin that provides the relevant extension by querying each plugin for its keys() diff --git a/doc/src/scripting/scripting.qdoc b/doc/src/scripting/scripting.qdoc index 79fed97..f882da0 100644 --- a/doc/src/scripting/scripting.qdoc +++ b/doc/src/scripting/scripting.qdoc @@ -144,7 +144,7 @@ script function. In the following example a script signal handler is defined that will handle the QLineEdit::textChanged() signal: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 47 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 47 The first two arguments to qScriptConnect() are the same as you would pass to QObject::connect() to establish a normal C++ @@ -155,7 +155,7 @@ ("slot") itself. The following example shows how the \c this argument can be put to use: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 48 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 48 We create two QLineEdit objects and define a single signal handler function. The connections use the same handler function, but the @@ -179,13 +179,13 @@ In this form of connection, the argument to \c{connect()} is the function to connect to the signal. - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 2 + \snippet doc/src/snippets/code/doc_src_qtscript.js 2 The argument can be a Qt Script function, as in the above example, or it can be a QObject slot, as in the following example: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 3 + \snippet doc/src/snippets/code/doc_src_qtscript.js 3 When the argument is a QObject slot, the argument types of the signal and slot do not necessarily have to be compatible; @@ -196,7 +196,7 @@ \c{disconnect()} function, passing the function to disconnect as argument: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 4 + \snippet doc/src/snippets/code/doc_src_qtscript.js 4 When a script function is invoked in response to a signal, the \c this object will be the Global Object. @@ -214,11 +214,11 @@ \c{clicked} signal; passing the form as the \c this object makes sense in such a case. - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 5 + \snippet doc/src/snippets/code/doc_src_qtscript.js 5 To disconnect from the signal, pass the same arguments to \c{disconnect()}: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 6 + \snippet doc/src/snippets/code/doc_src_qtscript.js 6 \section3 Signal to Named Member Function Connections @@ -234,11 +234,11 @@ Note that the function is resolved when the connection is made, not when the signal is emitted. - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 7 + \snippet doc/src/snippets/code/doc_src_qtscript.js 7 To disconnect from the signal, pass the same arguments to \c{disconnect()}: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 8 + \snippet doc/src/snippets/code/doc_src_qtscript.js 8 \section3 Error Handling @@ -247,14 +247,14 @@ You can obtain an error message from the resulting \c{Error} object. Example: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 9 + \snippet doc/src/snippets/code/doc_src_qtscript.js 9 \section3 Emitting Signals from Scripts To emit a signal from script code, you simply invoke the signal function, passing the relevant arguments: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 10 + \snippet doc/src/snippets/code/doc_src_qtscript.js 10 It is currently not possible to define a new signal in a script; i.e., all signals must be defined by C++ classes. @@ -267,13 +267,13 @@ \c{myOverloadedSlot(int)} and \c{myOverloadedSlot(QString)}, the following script code will behave reasonably: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 11 + \snippet doc/src/snippets/code/doc_src_qtscript.js 11 You can specify a particular overload by using array-style property access with the \l{QMetaObject::normalizedSignature()}{normalized signature} of the C++ function as the property name: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 12 + \snippet doc/src/snippets/code/doc_src_qtscript.js 12 If the overloads have different number of arguments, QtScript will pick the overload with the argument count that best matches the @@ -291,11 +291,11 @@ property will automatically be invoked. For example, if your C++ class has a property declared as follows: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 13 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 13 then script code can do things like the following: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 14 + \snippet doc/src/snippets/code/doc_src_qtscript.js 14 \section2 Accessing Child QObjects @@ -306,12 +306,12 @@ \c{"okButton"}, you can access this object in script code through the expression - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 15 + \snippet doc/src/snippets/code/doc_src_qtscript.js 15 Since \c{objectName} is itself a Q_PROPERTY, you can manipulate the name in script code to, for example, rename an object: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 16 + \snippet doc/src/snippets/code/doc_src_qtscript.js 16 You can also use the functions \c{findChild()} and \c{findChildren()} to find children. These two functions behave identically to @@ -320,7 +320,7 @@ For example, we can use these functions to find objects using strings and regular expressions: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 17 + \snippet doc/src/snippets/code/doc_src_qtscript.js 17 You typically want to use \c{findChild()} when manipulating a form that uses nested layouts; that way the script is isolated from the @@ -367,7 +367,7 @@ For example, a constructor function that constructs QObjects only to be used in the script environment is a good candidate: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 18 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 18 \section3 Auto-Ownership @@ -638,7 +638,7 @@ For example, the following class definition enables scripting only for certain functions: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 19 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 19 In the example above, aNonScriptableFunction() is not declared as a slot, so it will not be available in QtScript. The other three @@ -649,7 +649,7 @@ It is possible to make any function script-invokable by specifying the \c{Q_INVOKABLE} modifier when declaring the function: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 20 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 20 Once declared with \c{Q_INVOKABLE}, the method can be invoked from QtScript code just as if it were a slot. Although such a method is @@ -657,19 +657,25 @@ call to \c{connect()} in script code; \c{connect()} accepts both native and non-native functions as targets. + As discussed in \l{Default Conversion from Qt Script to C++}, Qt + Script handles conversion for many C++ types. If your function takes + arguments for which Qt Script does not handle conversion, you need + to supply conversion functions. This is done using the + qScriptRegisterMetaType() function. + \section2 Making C++ Class Properties Available in QtScript In the previous example, if we wanted to get or set a property using QtScript we would have to write code like the following: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 21 + \snippet doc/src/snippets/code/doc_src_qtscript.js 21 Scripting languages often provide a property syntax to modify and retrieve properties (in our case the enabled state) of an object. Many script programmers would want to write the above code like this: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 22 + \snippet doc/src/snippets/code/doc_src_qtscript.js 22 To make this possible, you must define properties in the C++ QObject subclass. For example, the following \c MyObject class declaration @@ -677,7 +683,7 @@ \c{setEnabled(bool)} as its setter function and \c{isEnabled()} as its getter function: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 23 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 23 The only difference from the original code is the use of the macro \c{Q_PROPERTY}, which takes the type and name of the property, and @@ -688,7 +694,7 @@ declaring the property; by default, the \c{SCRIPTABLE} attribute is \c true. For example: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 24 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 24 \section2 Reacting to C++ Objects Signals in Scripts @@ -703,14 +709,14 @@ regardless of whether the signal will be connected to a slot in C++ or in QtScript. - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 25 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 25 The only change we have made to the code in the previous section is to declare a signals section with the relevant signal. Now, the script writer can define a function and connect to the object like this: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 26 + \snippet doc/src/snippets/code/doc_src_qtscript.js 26 \section2 Design of Application Objects @@ -752,7 +758,7 @@ still allowing pointers to your custom objects to flow seamlessly between C++ and scripts. Example: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 43 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 43 \section1 Function Objects and Native Functions @@ -778,23 +784,23 @@ result. The following script defines a Qt Script object that has a toKelvin() function: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 90 + \snippet doc/src/snippets/code/doc_src_qtscript.js 90 The toKelvin() function takes a temperature in Kelvin as argument, and returns the temperature converted to Celsius. The following snippet shows how the toKelvin() function might be obtained and called from C++: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 91 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 91 If a script defines a global function, you can access the function as a property of QScriptEngine::globalObject(). For example, the following script defines a global function add(): - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 56 + \snippet doc/src/snippets/code/doc_src_qtscript.js 56 C++ code might call the add() function as follows: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 92 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 92 As already mentioned, functions are just values in Qt Script; a function by itself is not "tied to" a particular object. This is why you have to specify @@ -816,7 +822,7 @@ is invoked determines the \c this object when the function body is executed, as the following script example illustrates: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 49 + \snippet doc/src/snippets/code/doc_src_qtscript.js 49 An important thing to note is that in Qt Script, unlike C++ and Java, the \c this object is not part of the execution scope. This means that @@ -824,14 +830,14 @@ use the \c this keyword to access the object's properties. For example, the following script probably doesn't do what you want: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 50 + \snippet doc/src/snippets/code/doc_src_qtscript.js 50 You will get a reference error saying that 'a is not defined' or, worse, two totally unrelated global variables \c a and \c b will be used to perform the computation, if they exist. Instead, the script should look like this: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 51 + \snippet doc/src/snippets/code/doc_src_qtscript.js 51 Accidentally omitting the \c this keyword is a typical source of error for programmers who are used to the scoping rules of C++ and Java. @@ -844,7 +850,7 @@ your function as if it were a "normal" script function. Here is how the previous \c{getProperty()} function can be written in C++: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 52 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 52 Call QScriptEngine::newFunction() to wrap the function. This will produce a special type of function object that carries a pointer to @@ -905,7 +911,7 @@ script would normally define an \c{add()} function that takes two arguments, adds them together and returns the result: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 56 + \snippet doc/src/snippets/code/doc_src_qtscript.js 56 When a script function is defined with formal parameters, their names can be viewed as mere aliases of properties of the \c @@ -914,12 +920,12 @@ variable. This means that the \c{add()} function can equivalently be written like this: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 57 + \snippet doc/src/snippets/code/doc_src_qtscript.js 57 This latter form closely matches what a native implementation typically looks like: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 58 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 58 \section3 Checking the Number of Arguments @@ -930,13 +936,13 @@ really needs two arguments in order to do something useful. This can be expressed by the script definition as follows: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 59 + \snippet doc/src/snippets/code/doc_src_qtscript.js 59 This would result in an error being thrown if a script invokes \c{add()} with anything other than two arguments. The native function can be modified to perform the same check: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 62 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 62 \section3 Checking the Types of Arguments @@ -954,7 +960,7 @@ stricter semantics (namely, that it should only add numeric operands), the argument types can be tested: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 60 + \snippet doc/src/snippets/code/doc_src_qtscript.js 60 Then an invocation like \c{add("foo", new Array())} will cause an error to be thrown. @@ -962,12 +968,12 @@ The C++ version can call QScriptValue::isNumber() to perform similar tests: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 63 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 63 A less strict script implementation might settle for performing an explicit to-number conversion before applying the \c{+} operator: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 61 + \snippet doc/src/snippets/code/doc_src_qtscript.js 61 In a native implementation, this is equivalent to calling QScriptValue::toNumber() without performing any type test first, @@ -1000,21 +1006,21 @@ \c{concat("Qt", " ", "Script ", 101)} would return "Qt Script 101". A script definition of \c{concat()} might look like this: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 64 + \snippet doc/src/snippets/code/doc_src_qtscript.js 64 Here is an equivalent native implementation: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 65 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 65 A second use case for a variable number of arguments is to implement optional arguments. Here's how a script definition typically does it: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 66 + \snippet doc/src/snippets/code/doc_src_qtscript.js 66 And here's the native equivalent: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 67 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 67 A third use case for a variable number of arguments is to simulate C++ overloads. This involves checking the number of arguments and/or @@ -1043,7 +1049,7 @@ call to another function. In script code, this is what it typically looks like: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 68 + \snippet doc/src/snippets/code/doc_src_qtscript.js 68 For example, \c{foo(10, 20, 30)} would result in the \c{foo()} function executing the equivalent of \c{bar(10, 20, 30)}. This is useful if @@ -1054,7 +1060,7 @@ function that has the exact same "signature". In C++, the forwarding function might look like this: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 69 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 69 \o The arguments object can serve as input to a QScriptValueIterator, providing a generic way to iterate over the arguments. A debugger @@ -1072,7 +1078,7 @@ Some script functions are constructors; they are expected to initialize new objects. The following snippet is a small example: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 75 + \snippet doc/src/snippets/code/doc_src_qtscript.js 75 There is nothing special about constructor functions. In fact, any script function can act as a constructor function (i.e., any function @@ -1118,7 +1124,7 @@ The following example implements a constructor function that always creates and initializes a new object: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 76 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 76 Given this constructor, scripts would be able to use either the expression \c{new Person("Bob")} or \c{Person("Bob")} to create a @@ -1154,7 +1160,7 @@ returns the function object being invoked. The following example shows how this might be used: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 55 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 55 \section2 Native Functions as Arguments to Functions @@ -1163,13 +1169,13 @@ naturally. As an example, here's a native comparison function that compares its two arguments numerically: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 53 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 53 The above function can be passed as argument to the standard \c{Array.prototype.sort} function to sort an array numerically, as the following C++ code illustrates: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 54 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 54 Note that, in this case, we are truly treating the native function object as a value \mdash i.e., we don't store it as a property of the @@ -1204,7 +1210,7 @@ itself. This technique is typically used in conjunction with QScriptEngine::pushContext(), as in the following example: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 77 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 77 We create a temporary execution context, create a local variable for it, evaluate the script, and finally restore the old context. @@ -1227,7 +1233,7 @@ define a native combined getter/setter that transforms the value slightly: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 78 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 78 The example uses the internal data of the object to store and retrieve the transformed value. Alternatively, the property @@ -1240,12 +1246,12 @@ The following C++ code shows how an object property can be defined in terms of the native getter/setter: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 79 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 79 When the property is accessed, like in the following script, the getter/setter does its job behind the scenes: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 80 + \snippet doc/src/snippets/code/doc_src_qtscript.js 80 \note It is important that the setter function, not just the getter, returns the value of the property; i.e., the setter should \e{not} @@ -1266,7 +1272,7 @@ Property getters and setters can be defined and installed by script code as well, as in the following example: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 81 + \snippet doc/src/snippets/code/doc_src_qtscript.js 81 Getters and setters can only be used to implement "a priori properties"; i.e., the technique can't be used to react to an access @@ -1342,7 +1348,7 @@ including the \c{hasOwnProperty()} function and \c{toString()} function: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 27 + \snippet doc/src/snippets/code/doc_src_qtscript.js 27 The \c{toString()} function itself is not defined in \c{o} (since we did not assign anything to \c{o.toString}), so instead the @@ -1382,7 +1388,7 @@ The following code defines a simple constructor function for a class called \c{Person}: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 28 + \snippet doc/src/snippets/code/doc_src_qtscript.js 28 Next, you want to set up \c{Person.prototype} as your prototype object; i.e., define the interface that should be common to all @@ -1397,19 +1403,19 @@ \c{Object.prototype}, to give your \c{Person} objects a more appropriate string representation: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 29 + \snippet doc/src/snippets/code/doc_src_qtscript.js 29 This resembles the process of reimplementing a virtual function in C++. Henceforth, when the property named \c{toString} is looked up in a \c{Person} object, it will be resolved in \c{Person.prototype}, not in \c{Object.prototype} as before: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 30 + \snippet doc/src/snippets/code/doc_src_qtscript.js 30 There are also some other interesting things we can learn about a \c{Person} object: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 31 + \snippet doc/src/snippets/code/doc_src_qtscript.js 31 The \c{hasOwnProperty()} function is not inherited from \c{Person.prototype}, but rather from \c{Object.prototype}, which is @@ -1426,13 +1432,13 @@ following example shows how one can create a subclass of \c{Person} called \c{Employee}: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 32 + \snippet doc/src/snippets/code/doc_src_qtscript.js 32 Again, you can use the \c{instanceof} to verify that the class relationship between \c{Employee} and \c{Person} has been correctly established: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 33 + \snippet doc/src/snippets/code/doc_src_qtscript.js 33 This shows that the prototype chain of \c{Employee} objects is the same as that of \c{Person} objects, but with \c{Employee.prototype} @@ -1477,25 +1483,25 @@ preceding section can be implemented in terms of the Qt Script API. We begin with the native constructor function: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 34 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 34 Here's the native equivalent of the \c{Person.prototype.toString} function we saw before: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 35 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 35 The \c{Person} class can then be initialized as follows: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 36 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 36 The implementation of the \c{Employee} subclass is similar. We use QScriptValue::call() to call the super-class (Person) constructor: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 37 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 37 The \c{Employee} class can then be initialized as follows: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 38 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 38 When implementing the prototype object of a class, you may want to use the QScriptable class, as it enables you to define the API of your @@ -1521,7 +1527,7 @@ modify the underlying C++ value, lets you modify the actual value contained in the script value (and not a copy of it). - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 39 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 39 \section2 Implementing Constructors for Value-based Types @@ -1529,7 +1535,7 @@ by wrapping a native factory function. For example, the following function implements a simple constructor for QPoint: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 44 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 44 In the above code we simplified things a bit, e.g. we didn't check the argument count to decide which QPoint C++ constructor to use. @@ -1564,16 +1570,16 @@ The following snippet shows a constructor function that constructs QXmlStreamReader objects that are stored using QSharedPointer: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 93 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 93 Prototype functions can use qscriptvalue_cast() to cast the \c this object to the proper type: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 94 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 94 The prototype and constructor objects are set up in the usual way: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 95 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 95 Scripts can now construct QXmlStreamReader objects by calling the \c XmlStreamReader constructor, and when the Qt Script object is @@ -1643,12 +1649,12 @@ somewhere else. The following code shows a custom print() that adds text to a QPlainTextEdit. - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 45 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 45 The following code shows how the custom print() function may be initialized and used. - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 46 + \snippet doc/src/snippets/code/doc_src_qtscript.cpp 46 A pointer to the QPlainTextEdit is stored as an internal property of the script function itself, so that it can be retrieved when @@ -1680,7 +1686,7 @@ function. Essentially all that is necessary to achieve this is to use the qsTr() script function. Example: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 82 + \snippet doc/src/snippets/code/doc_src_qtscript.js 82 This accounts for 99% of the user-visible strings you're likely to write. @@ -1689,7 +1695,7 @@ unique in your project, you should use the qsTranslate() function and pass a suitable context as the first argument. Example: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 83 + \snippet doc/src/snippets/code/doc_src_qtscript.js 83 If you need to have translatable text completely outside a function, there are two functions to help: QT_TR_NOOP() and QT_TRANSLATE_NOOP(). They merely @@ -1698,18 +1704,18 @@ Example of QT_TR_NOOP(): - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 84 + \snippet doc/src/snippets/code/doc_src_qtscript.js 84 Example of QT_TRANSLATE_NOOP(): - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 85 + \snippet doc/src/snippets/code/doc_src_qtscript.js 85 \section2 Use String.prototype.arg() for Dynamic Text The String.prototype.arg() function (which is modeled after QString::arg()) offers a simple means for substituting arguments: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 86 + \snippet doc/src/snippets/code/doc_src_qtscript.js 86 \section2 Produce Translations @@ -1804,7 +1810,7 @@ This property has the QScriptValue::Undeletable flag set. For example: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 40 + \snippet doc/src/snippets/code/doc_src_qtscript.js 40 \i \c{Object.prototype.__defineGetter__} \br This function installs a @@ -1814,7 +1820,7 @@ \c this object will be the object whose property is accessed. For example: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 41 + \snippet doc/src/snippets/code/doc_src_qtscript.js 41 \i \c{Object.prototype.__defineSetter__} \br This function installs a @@ -1824,7 +1830,7 @@ \c this object will be the object whose property is accessed. For example: - \snippet doc/src/snippets/code/doc_src_qtscript.qdoc 42 + \snippet doc/src/snippets/code/doc_src_qtscript.js 42 \i \c{Function.prototype.connect} \br This function connects diff --git a/doc/src/snippets/code/doc_src_activeqt-dumpcpp.qdoc b/doc/src/snippets/code/doc_src_activeqt-dumpcpp.cpp index 0c29b1c..0c29b1c 100644 --- a/doc/src/snippets/code/doc_src_activeqt-dumpcpp.qdoc +++ b/doc/src/snippets/code/doc_src_activeqt-dumpcpp.cpp diff --git a/doc/src/snippets/code/doc_src_appicon.pro b/doc/src/snippets/code/doc_src_appicon.pro new file mode 100644 index 0000000..176b458 --- /dev/null +++ b/doc/src/snippets/code/doc_src_appicon.pro @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +#! [1] +RC_FILE = myapp.rc +#! [1] + + +#! [2] +ICON = myapp.icns +#! [2] + + +#! [5] +ICON = myapp.svg +#! [5] diff --git a/doc/src/snippets/code/doc_src_appicon.qdoc b/doc/src/snippets/code/doc_src_appicon.qdoc index 06bf861..8dd30a4 100644 --- a/doc/src/snippets/code/doc_src_appicon.qdoc +++ b/doc/src/snippets/code/doc_src_appicon.qdoc @@ -43,16 +43,6 @@ IDI_ICON1 ICON DISCARDABLE "myappico.ico" //! [0] -//! [1] -RC_FILE = myapp.rc -//! [1] - - -//! [2] -ICON = myapp.icns -//! [2] - - //! [3] kde-config --path icon //! [3] @@ -61,7 +51,3 @@ kde-config --path icon //! [4] gnome-config --datadir //! [4] - -//! [5] -ICON = myapp.svg -//! [5] diff --git a/doc/src/snippets/code/doc_src_containers.qdoc b/doc/src/snippets/code/doc_src_containers.cpp index fa300f9..fa300f9 100644 --- a/doc/src/snippets/code/doc_src_containers.qdoc +++ b/doc/src/snippets/code/doc_src_containers.cpp diff --git a/doc/src/snippets/code/doc_src_coordsys.qdoc b/doc/src/snippets/code/doc_src_coordsys.cpp index 1ebb215..1ebb215 100644 --- a/doc/src/snippets/code/doc_src_coordsys.qdoc +++ b/doc/src/snippets/code/doc_src_coordsys.cpp diff --git a/doc/src/snippets/code/doc_src_debug.qdoc b/doc/src/snippets/code/doc_src_debug.cpp index 40a5ac2..40a5ac2 100644 --- a/doc/src/snippets/code/doc_src_debug.qdoc +++ b/doc/src/snippets/code/doc_src_debug.cpp diff --git a/doc/src/snippets/code/doc_src_deployment.cpp b/doc/src/snippets/code/doc_src_deployment.cpp new file mode 100644 index 0000000..e7f7511 --- /dev/null +++ b/doc/src/snippets/code/doc_src_deployment.cpp @@ -0,0 +1,56 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +//! [9] +qApp->addLibraryPath("/some/other/path"); +//! [9] + + +//! [19] +qApp->addLibraryPath("C:\some\other\path"); +//! [19] + + +//! [49] +QDir dir(QApplication::applicationDirPath()); +dir.cdUp(); +dir.cd("plugins"); +QApplication::setLibraryPaths(QStringList(dir.absolutePath())); +//! [49] diff --git a/doc/src/snippets/code/doc_src_deployment.pro b/doc/src/snippets/code/doc_src_deployment.pro new file mode 100644 index 0000000..b9fdd54 --- /dev/null +++ b/doc/src/snippets/code/doc_src_deployment.pro @@ -0,0 +1,87 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +#! [8] +DESTDIR = /path/to/Qt/plugandpaint/plugins +#! [8] + + +#! [21] +CONFIG += embed_manifest_exe +#! [21] + + +#! [23] +CONFIG-=embed_manifest_dll +#! [23] + + +#! [26] +CONFIG-=app_bundle +#! [26] + + +#! [51] +QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.3 +#! [51] + +#! [53] +QMAKE_MAC_SDK=/Developer/SDKs/MacOSX10.4u.sdk +CONFIG+=x86 ppc +#! [53] + +#! [56] +vendorinfo = \ + "%{\"Example Localized Vendor\"}" \ + ":\"Example Vendor\"" + +my_deployment.pkg_prerules = vendorinfo +DEPLOYMENT += my_deployment +#! [56] + +#! [57] +supported_platforms = \ + "; This demo only supports S60 5.0" \ + "[0x1028315F],0,0,0,{\"S60ProductID\"}" + +default_deployment.pkg_prerules -= pkg_platform_dependencies +my_deployment.pkg_prerules += supported_platforms +DEPLOYMENT += my_deployment +#! [57] diff --git a/doc/src/snippets/code/doc_src_deployment.qdoc b/doc/src/snippets/code/doc_src_deployment.qdoc index c5f4644..760bd8f 100644 --- a/doc/src/snippets/code/doc_src_deployment.qdoc +++ b/doc/src/snippets/code/doc_src_deployment.qdoc @@ -96,20 +96,10 @@ dirname=$PWD/$dirname fi LD_LIBRARY_PATH=$dirname export LD_LIBRARY_PATH -$dirname/$appname $* +$dirname/$appname "$@" //! [7] -//! [8] -DESTDIR = /path/to/Qt/plugandpaint/plugins -//! [8] - - -//! [9] -qApp->addLibraryPath("/some/other/path"); -//! [9] - - //! [10] ldd ./application //! [10] @@ -164,11 +154,6 @@ plugins\pnp_extrafilters.dll //! [18] -//! [19] -qApp->addLibraryPath("C:\some\other\path"); -//! [19] - - //! [20] embed_manifest_dll embed_manifest_exe @@ -411,14 +396,6 @@ install_name_tool -change /path/to/Qt/lib/QtCore.framework/Versions/4.0/QtCore //! [48] -//! [49] -QDir dir(QApplication::applicationDirPath()); -dir.cdUp(); -dir.cd("plugins"); -QApplication::setLibraryPaths(QStringList(dir.absolutePath())); -//! [49] - - //! [50] otool -L MyApp.app/Contents/MacOS/MyApp //! [50] @@ -483,4 +460,4 @@ make release-gcce //! [59] make installer_sis -//! [59]
\ No newline at end of file +//! [59] diff --git a/doc/src/snippets/code/doc_src_designer-manual.qdoc b/doc/src/snippets/code/doc_src_designer-manual.cpp index 90e34a4..a261818 100644 --- a/doc/src/snippets/code/doc_src_designer-manual.qdoc +++ b/doc/src/snippets/code/doc_src_designer-manual.cpp @@ -38,11 +38,6 @@ ** ****************************************************************************/ -//! [0] -CONFIG += uitools -//! [0] - - //! [1] #include <QtUiTools> //! [1] @@ -53,27 +48,6 @@ void on_<object name>_<signal name>(<signal parameters>); //! [2] -//! [3] -CONFIG += release -//! [3] - - -//! [4] -target.path = $$[QT_INSTALL_PLUGINS]/designer -INSTALLS += target -//! [4] - - -//! [5] -QT += script -//! [5] - - -//! [6] -widget.text = 'Hi - I was built ' + new Date().toString(); -//! [6] - - //! [7] class MyExtension: public QObject, public QdesignerContainerExtension diff --git a/doc/src/snippets/code/doc_src_designer-manual.js b/doc/src/snippets/code/doc_src_designer-manual.js new file mode 100644 index 0000000..074b47e --- /dev/null +++ b/doc/src/snippets/code/doc_src_designer-manual.js @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +//! [6] +widget.text = 'Hi - I was built ' + new Date().toString(); +//! [6] diff --git a/doc/src/snippets/code/doc_src_designer-manual.pro b/doc/src/snippets/code/doc_src_designer-manual.pro new file mode 100644 index 0000000..4b14a14 --- /dev/null +++ b/doc/src/snippets/code/doc_src_designer-manual.pro @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +#! [0] +CONFIG += uitools +#! [0] + + +#! [3] +CONFIG += release +#! [3] + + +#! [4] +target.path = $$[QT_INSTALL_PLUGINS]/designer +INSTALLS += target +#! [4] + + +#! [5] +QT += script +#! [5] diff --git a/doc/src/snippets/code/doc_src_dnd.qdoc b/doc/src/snippets/code/doc_src_dnd.cpp index d5dc721..d5dc721 100644 --- a/doc/src/snippets/code/doc_src_dnd.qdoc +++ b/doc/src/snippets/code/doc_src_dnd.cpp diff --git a/doc/src/snippets/code/doc_src_emb-performance.cpp b/doc/src/snippets/code/doc_src_emb-performance.cpp new file mode 100644 index 0000000..5a465a9 --- /dev/null +++ b/doc/src/snippets/code/doc_src_emb-performance.cpp @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +//! [1] +void *operator new[](size_t size) +{ + return malloc(size); +} + +void *operator new(size_t size) +{ + return malloc(size); +} + +void operator delete[](void *ptr) +{ + free(ptr); +} + +void operator delete[](void *ptr, size_t) +{ + free(ptr); +} + +void operator delete(void *ptr) +{ + free(ptr); +} + +void operator delete(void *ptr, size_t) +{ + free(ptr); +} +//! [1] diff --git a/doc/src/snippets/code/doc_src_emb-performance.qdoc b/doc/src/snippets/code/doc_src_emb-performance.qdoc index 8c129fd..9abf8d1 100644 --- a/doc/src/snippets/code/doc_src_emb-performance.qdoc +++ b/doc/src/snippets/code/doc_src_emb-performance.qdoc @@ -41,36 +41,3 @@ //! [0] ./configure -static //! [0] - - -//! [1] -void *operator new[](size_t size) -{ - return malloc(size); -} - -void *operator new(size_t size) -{ - return malloc(size); -} - -void operator delete[](void *ptr) -{ - free(ptr); -} - -void operator delete[](void *ptr, size_t) -{ - free(ptr); -} - -void operator delete(void *ptr) -{ - free(ptr); -} - -void operator delete(void *ptr, size_t) -{ - free(ptr); -} -//! [1] diff --git a/doc/src/snippets/code/doc_src_emb-pointer.pro b/doc/src/snippets/code/doc_src_emb-pointer.pro new file mode 100644 index 0000000..fed7d79 --- /dev/null +++ b/doc/src/snippets/code/doc_src_emb-pointer.pro @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +#! [7] +.... +QMAKE_CFLAGS += -I<path to tslib headers> +QMAKE_LFLAGS += -L<path to tslib library> -Wl,-rpath-link=<path to tslib library> +.... +#! [7] diff --git a/doc/src/snippets/code/doc_src_emb-pointer.qdoc b/doc/src/snippets/code/doc_src_emb-pointer.qdoc index 4ec1335..1fb6d8f 100644 --- a/doc/src/snippets/code/doc_src_emb-pointer.qdoc +++ b/doc/src/snippets/code/doc_src_emb-pointer.qdoc @@ -75,14 +75,6 @@ export QWS_MOUSE_PROTO="Vr41xx:press=500:/dev/misc/ts" //! [6] -//! [7] -.... -QMAKE_CFLAGS += -I<path to tslib headers> -QMAKE_LFLAGS += -L<path to tslib library> -Wl,-rpath-link=<path to tslib library> -.... -//! [7] - - //! [8] module_raw input module linear @@ -111,5 +103,3 @@ ls -l /dev/input/mouse0 //! [12] chmod a+rw /dev/input/mouse0 //! [12] - - diff --git a/doc/src/snippets/code/doc_src_examples_arrowpad.cpp b/doc/src/snippets/code/doc_src_examples_arrowpad.cpp new file mode 100644 index 0000000..c834b9f --- /dev/null +++ b/doc/src/snippets/code/doc_src_examples_arrowpad.cpp @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +//! [0] +qApp->translate("ArrowPad", x) +//! [0] diff --git a/doc/src/snippets/code/doc_src_examples_arrowpad.qdoc b/doc/src/snippets/code/doc_src_examples_arrowpad.qdoc index 933f419..ee3c367 100644 --- a/doc/src/snippets/code/doc_src_examples_arrowpad.qdoc +++ b/doc/src/snippets/code/doc_src_examples_arrowpad.qdoc @@ -38,11 +38,6 @@ ** ****************************************************************************/ -//! [0] -qApp->translate("ArrowPad", x) -//! [0] - - //! [1] lrelease arrowpad.pro //! [1] diff --git a/doc/src/snippets/code/doc_src_examples_taskmenuextension.qdoc b/doc/src/snippets/code/doc_src_examples_containerextension.pro index 7fe0394..cd86693 100644 --- a/doc/src/snippets/code/doc_src_examples_taskmenuextension.qdoc +++ b/doc/src/snippets/code/doc_src_examples_containerextension.pro @@ -38,7 +38,7 @@ ** ****************************************************************************/ -//! [0] +#! [0] target.path = $$[QT_INSTALL_PLUGINS]/designer INSTALLS += target -//! [0] +#! [0] diff --git a/doc/src/snippets/code/doc_src_examples_worldtimeclockplugin.qdoc b/doc/src/snippets/code/doc_src_examples_customwidgetplugin.pro index 7fe0394..cd86693 100644 --- a/doc/src/snippets/code/doc_src_examples_worldtimeclockplugin.qdoc +++ b/doc/src/snippets/code/doc_src_examples_customwidgetplugin.pro @@ -38,7 +38,7 @@ ** ****************************************************************************/ -//! [0] +#! [0] target.path = $$[QT_INSTALL_PLUGINS]/designer INSTALLS += target -//! [0] +#! [0] diff --git a/doc/src/snippets/code/doc_src_examples_editabletreemodel.qdoc b/doc/src/snippets/code/doc_src_examples_editabletreemodel.cpp index a69a7bf..a69a7bf 100644 --- a/doc/src/snippets/code/doc_src_examples_editabletreemodel.qdoc +++ b/doc/src/snippets/code/doc_src_examples_editabletreemodel.cpp diff --git a/doc/src/snippets/code/doc_src_examples_icons.cpp b/doc/src/snippets/code/doc_src_examples_icons.cpp new file mode 100644 index 0000000..411c49f --- /dev/null +++ b/doc/src/snippets/code/doc_src_examples_icons.cpp @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +//! [0] +if (!condition) + qFatal("ASSERT: "condition" in file ..."); +//! [0] diff --git a/doc/src/snippets/code/doc_src_examples_icons.qdoc b/doc/src/snippets/code/doc_src_examples_icons.qdoc index 7684224..8ca5751 100644 --- a/doc/src/snippets/code/doc_src_examples_icons.qdoc +++ b/doc/src/snippets/code/doc_src_examples_icons.qdoc @@ -38,12 +38,6 @@ ** ****************************************************************************/ -//! [0] -if (!condition) - qFatal("ASSERT: "condition" in file ..."); -//! [0] - - //! [1] qmake "CONFIG += debug" icons.pro //! [1] diff --git a/doc/src/snippets/code/doc_src_examples_imageviewer.cpp b/doc/src/snippets/code/doc_src_examples_imageviewer.cpp new file mode 100644 index 0000000..c86f8ac --- /dev/null +++ b/doc/src/snippets/code/doc_src_examples_imageviewer.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +//! [0] +imageLabel->resize(imageLabel->pixmap()->size()); +//! [0] + + +//! [1] +if (!imageLabel->pixmap()) + qFatal("ASSERT: "imageLabel->pixmap()" in file ..."); +//! [1] + + +//! [4] +scrollBar->setValue(int(factor * scrollBar->value())); +//! [4] diff --git a/doc/src/snippets/code/doc_src_examples_imageviewer.qdoc b/doc/src/snippets/code/doc_src_examples_imageviewer.qdoc index 84f822f..1870385 100644 --- a/doc/src/snippets/code/doc_src_examples_imageviewer.qdoc +++ b/doc/src/snippets/code/doc_src_examples_imageviewer.qdoc @@ -38,17 +38,6 @@ ** ****************************************************************************/ -//! [0] -imageLabel->resize(imageLabel->pixmap()->size()); -//! [0] - - -//! [1] -if (!imageLabel->pixmap()) - qFatal("ASSERT: "imageLabel->pixmap()" in file ..."); -//! [1] - - //! [2] qmake "CONFIG += debug" foo.pro //! [2] @@ -57,8 +46,3 @@ qmake "CONFIG += debug" foo.pro //! [3] qmake "CONFIG += release" foo.pro //! [3] - - -//! [4] -scrollBar->setValue(int(factor * scrollBar->value())); -//! [4] diff --git a/doc/src/snippets/code/doc_src_examples_qtscriptcustomclass.qdoc b/doc/src/snippets/code/doc_src_examples_qtscriptcustomclass.cpp index b62236c..b62236c 100644 --- a/doc/src/snippets/code/doc_src_examples_qtscriptcustomclass.qdoc +++ b/doc/src/snippets/code/doc_src_examples_qtscriptcustomclass.cpp diff --git a/doc/src/snippets/code/doc_src_examples_simpledommodel.qdoc b/doc/src/snippets/code/doc_src_examples_simpledommodel.cpp index 1abcdc2..1abcdc2 100644 --- a/doc/src/snippets/code/doc_src_examples_simpledommodel.qdoc +++ b/doc/src/snippets/code/doc_src_examples_simpledommodel.cpp diff --git a/doc/src/snippets/code/doc_src_examples_customwidgetplugin.qdoc b/doc/src/snippets/code/doc_src_examples_taskmenuextension.pro index 7fe0394..cd86693 100644 --- a/doc/src/snippets/code/doc_src_examples_customwidgetplugin.qdoc +++ b/doc/src/snippets/code/doc_src_examples_taskmenuextension.pro @@ -38,7 +38,7 @@ ** ****************************************************************************/ -//! [0] +#! [0] target.path = $$[QT_INSTALL_PLUGINS]/designer INSTALLS += target -//! [0] +#! [0] diff --git a/doc/src/snippets/code/doc_src_examples_textfinder.qdoc b/doc/src/snippets/code/doc_src_examples_textfinder.pro index d99f8ce..cdc2366 100644 --- a/doc/src/snippets/code/doc_src_examples_textfinder.qdoc +++ b/doc/src/snippets/code/doc_src_examples_textfinder.pro @@ -38,9 +38,9 @@ ** ****************************************************************************/ -//! [0] +#! [0] CONFIG += uitools HEADERS = textfinder.h RESOURCES = textfinder.qrc SOURCES = textfinder.cpp main.cpp -//! [0] +#! [0] diff --git a/doc/src/snippets/code/doc_src_examples_trollprint.qdoc b/doc/src/snippets/code/doc_src_examples_trollprint.cpp index 4b508e9..f7b8f48 100644 --- a/doc/src/snippets/code/doc_src_examples_trollprint.qdoc +++ b/doc/src/snippets/code/doc_src_examples_trollprint.cpp @@ -59,6 +59,7 @@ colorsDisabledRadio = new QRadioButton(tr("Disabled", "colors"), colors); belonging to MainWindow. ... +*/ //! [2] @@ -72,4 +73,5 @@ colorsDisabledRadio = new QRadioButton(tr("Disabled", "colors"), colors); checkbox and then click the Start Processing button. You should now see a pop up window with the text "Error: Name too long!". This window is a ZClientErrorDialog. +*/ //! [3] diff --git a/doc/src/snippets/code/doc_src_examples_containerextension.qdoc b/doc/src/snippets/code/doc_src_examples_worldtimeclockplugin.pro index 7fe0394..cd86693 100644 --- a/doc/src/snippets/code/doc_src_examples_containerextension.qdoc +++ b/doc/src/snippets/code/doc_src_examples_worldtimeclockplugin.pro @@ -38,7 +38,7 @@ ** ****************************************************************************/ -//! [0] +#! [0] target.path = $$[QT_INSTALL_PLUGINS]/designer INSTALLS += target -//! [0] +#! [0] diff --git a/doc/src/snippets/code/doc_src_graphicsview.qdoc b/doc/src/snippets/code/doc_src_graphicsview.cpp index 00ebab3..00ebab3 100644 --- a/doc/src/snippets/code/doc_src_graphicsview.qdoc +++ b/doc/src/snippets/code/doc_src_graphicsview.cpp diff --git a/doc/src/snippets/code/doc_src_groups.qdoc b/doc/src/snippets/code/doc_src_groups.cpp index 2d5fd97..2d5fd97 100644 --- a/doc/src/snippets/code/doc_src_groups.qdoc +++ b/doc/src/snippets/code/doc_src_groups.cpp diff --git a/doc/src/snippets/code/doc_src_i18n.cpp b/doc/src/snippets/code/doc_src_i18n.cpp new file mode 100644 index 0000000..cc85bd8 --- /dev/null +++ b/doc/src/snippets/code/doc_src_i18n.cpp @@ -0,0 +1,175 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +//! [0] +LoginWidget::LoginWidget() +{ + QLabel *label = new QLabel(tr("Password:")); + ... +} +//! [0] + + +//! [1] +void some_global_function(LoginWidget *logwid) +{ + QLabel *label = new QLabel( + LoginWidget::tr("Password:"), logwid); +} + +void same_global_function(LoginWidget *logwid) +{ + QLabel *label = new QLabel( + qApp->translate("LoginWidget", "Password:"), logwid); +} +//! [1] + + +//! [2] +QString FriendlyConversation::greeting(int type) +{ + static const char *greeting_strings[] = { + QT_TR_NOOP("Hello"), + QT_TR_NOOP("Goodbye") + }; + return tr(greeting_strings[type]); +} +//! [2] + + +//! [3] +static const char *greeting_strings[] = { + QT_TRANSLATE_NOOP("FriendlyConversation", "Hello"), + QT_TRANSLATE_NOOP("FriendlyConversation", "Goodbye") +}; + +QString FriendlyConversation::greeting(int type) +{ + return tr(greeting_strings[type]); +} + +QString global_greeting(int type) +{ + return qApp->translate("FriendlyConversation", + greeting_strings[type]); +} +//! [3] + + +//! [4] +void FileCopier::showProgress(int done, int total, + const QString ¤tFile) +{ + label.setText(tr("%1 of %2 files copied.\nCopying: %3") + .arg(done) + .arg(total) + .arg(currentFile)); +} +//! [4] + + +//! [5] +QString s1 = "%1 of %2 files copied. Copying: %3"; +QString s2 = "Kopierer nu %3. Av totalt %2 filer er %1 kopiert."; + +qDebug() << s1.arg(5).arg(10).arg("somefile.txt"); +qDebug() << s2.arg(5).arg(10).arg("somefile.txt"); +//! [5] + + +//! [8] +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + QTranslator qtTranslator; + qtTranslator.load("qt_" + QLocale::system().name(), + QLibraryInfo::location(QLibraryInfo::TranslationsPath)); + app.installTranslator(&qtTranslator); + + QTranslator myappTranslator; + myappTranslator.load("myapp_" + QLocale::system().name()); + app.installTranslator(&myappTranslator); + + ... + return app.exec(); +} +//! [8] + + +//! [9] +QString string = ...; // some Unicode text + +QTextCodec *codec = QTextCodec::codecForName("ISO 8859-5"); +QByteArray encodedString = codec->fromUnicode(string); +//! [9] + + +//! [10] +QByteArray encodedString = ...; // some ISO 8859-5 encoded text + +QTextCodec *codec = QTextCodec::codecForName("ISO 8859-5"); +QString string = codec->toUnicode(encodedString); +//! [10] + + +//! [11] +void Clock::setTime(const QTime &time) +{ + if (tr("AMPM") == "AMPM") { + // 12-hour clock + } else { + // 24-hour clock + } +} +//! [11] + + +//! [12] +void MyWidget::changeEvent(QEvent *event) +{ + if (e->type() == QEvent::LanguageChange) { + titleLabel->setText(tr("Document Title")); + ... + okPushButton->setText(tr("&OK")); + } else + QWidget::changeEvent(event); +} +//! [12] diff --git a/doc/src/snippets/code/doc_src_i18n.qdoc b/doc/src/snippets/code/doc_src_i18n.qdoc index f54ce37..f8f8f02 100644 --- a/doc/src/snippets/code/doc_src_i18n.qdoc +++ b/doc/src/snippets/code/doc_src_i18n.qdoc @@ -38,82 +38,6 @@ ** ****************************************************************************/ -//! [0] -LoginWidget::LoginWidget() -{ - QLabel *label = new QLabel(tr("Password:")); - ... -} -//! [0] - - -//! [1] -void some_global_function(LoginWidget *logwid) -{ - QLabel *label = new QLabel( - LoginWidget::tr("Password:"), logwid); -} - -void same_global_function(LoginWidget *logwid) -{ - QLabel *label = new QLabel( - qApp->translate("LoginWidget", "Password:"), logwid); -} -//! [1] - - -//! [2] -QString FriendlyConversation::greeting(int type) -{ - static const char *greeting_strings[] = { - QT_TR_NOOP("Hello"), - QT_TR_NOOP("Goodbye") - }; - return tr(greeting_strings[type]); -} -//! [2] - - -//! [3] -static const char *greeting_strings[] = { - QT_TRANSLATE_NOOP("FriendlyConversation", "Hello"), - QT_TRANSLATE_NOOP("FriendlyConversation", "Goodbye") -}; - -QString FriendlyConversation::greeting(int type) -{ - return tr(greeting_strings[type]); -} - -QString global_greeting(int type) -{ - return qApp->translate("FriendlyConversation", - greeting_strings[type]); -} -//! [3] - - -//! [4] -void FileCopier::showProgress(int done, int total, - const QString ¤tFile) -{ - label.setText(tr("%1 of %2 files copied.\nCopying: %3") - .arg(done) - .arg(total) - .arg(currentFile)); -} -//! [4] - - -//! [5] -QString s1 = "%1 of %2 files copied. Copying: %3"; -QString s2 = "Kopierer nu %3. Av totalt %2 filer er %1 kopiert."; - -qDebug() << s1.arg(5).arg(10).arg("somefile.txt"); -qDebug() << s2.arg(5).arg(10).arg("somefile.txt"); -//! [5] - - //! [6] 5 of 10 files copied. Copying: somefile.txt Kopierer nu somefile.txt. Av totalt 10 filer er 5 kopiert. @@ -132,64 +56,3 @@ TRANSLATIONS = superapp_dk.ts \ superapp_no.ts \ superapp_se.ts //! [7] - - -//! [8] -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - QTranslator qtTranslator; - qtTranslator.load("qt_" + QLocale::system().name(), - QLibraryInfo::location(QLibraryInfo::TranslationsPath)); - app.installTranslator(&qtTranslator); - - QTranslator myappTranslator; - myappTranslator.load("myapp_" + QLocale::system().name()); - app.installTranslator(&myappTranslator); - - ... - return app.exec(); -} -//! [8] - - -//! [9] -QString string = ...; // some Unicode text - -QTextCodec *codec = QTextCodec::codecForName("ISO 8859-5"); -QByteArray encodedString = codec->fromUnicode(string); -//! [9] - - -//! [10] -QByteArray encodedString = ...; // some ISO 8859-5 encoded text - -QTextCodec *codec = QTextCodec::codecForName("ISO 8859-5"); -QString string = codec->toUnicode(encodedString); -//! [10] - - -//! [11] -void Clock::setTime(const QTime &time) -{ - if (tr("AMPM") == "AMPM") { - // 12-hour clock - } else { - // 24-hour clock - } -} -//! [11] - - -//! [12] -void MyWidget::changeEvent(QEvent *event) -{ - if (e->type() == QEvent::LanguageChange) { - titleLabel->setText(tr("Document Title")); - ... - okPushButton->setText(tr("&OK")); - } else - QWidget::changeEvent(event); -} -//! [12] diff --git a/doc/src/snippets/code/doc_src_layout.qdoc b/doc/src/snippets/code/doc_src_layout.cpp index 47db36b..47db36b 100644 --- a/doc/src/snippets/code/doc_src_layout.qdoc +++ b/doc/src/snippets/code/doc_src_layout.cpp diff --git a/doc/src/snippets/code/doc_src_linguist-manual.cpp b/doc/src/snippets/code/doc_src_linguist-manual.cpp new file mode 100644 index 0000000..7cb5b1e --- /dev/null +++ b/doc/src/snippets/code/doc_src_linguist-manual.cpp @@ -0,0 +1,157 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +//! [3] +label->setText(tr("F\374r \310lise")); +//! [3] + + +void wrapInFunction() +{ +//! [6] +button = new QPushButton("&Quit", this); +//! [6] + + +//! [7] +button = new QPushButton(tr("&Quit"), this); +//! [7] + + +//! [8] +QPushButton::tr("&Quit") +//! [8] + + +//! [9] +QObject::tr("&Quit") +//! [9] + + +//! [10] +rbc = new QRadioButton(tr("Enabled", "Color frame"), this); +//! [10] + + +//! [11] +rbh = new QRadioButton(tr("Enabled", "Hue frame"), this); +//! [11] +} + + +//! [12] +/* + TRANSLATOR FindDialog + + Choose Edit|Find from the menu bar or press Ctrl+F to pop up the + Find dialog. + + ... +*/ +//! [12] + +//! [13] +/* + TRANSLATOR MyNamespace::MyClass + + Necessary for lupdate. + + ... +*/ +//! [13] + +//! [14] +void some_global_function(LoginWidget *logwid) +{ + QLabel *label = new QLabel( + LoginWidget::tr("Password:"), logwid); +} + +void same_global_function(LoginWidget *logwid) +{ + QLabel *label = new QLabel( + qApp->translate("LoginWidget", "Password:"), + logwid); +} +//! [14] + + +//! [15] +QString FriendlyConversation::greeting(int greet_type) +{ + static const char* greeting_strings[] = { + QT_TR_NOOP("Hello"), + QT_TR_NOOP("Goodbye") + }; + return tr(greeting_strings[greet_type]); +} +//! [15] + + +//! [16] +static const char* greeting_strings[] = { + QT_TRANSLATE_NOOP("FriendlyConversation", "Hello"), + QT_TRANSLATE_NOOP("FriendlyConversation", "Goodbye") +}; + +QString FriendlyConversation::greeting(int greet_type) +{ + return tr(greeting_strings[greet_type]); +} + +QString global_greeting(int greet_type) +{ + return qApp->translate("FriendlyConversation", + greeting_strings[greet_type]); +} +//! [16] + +void wrapInFunction() +{ + +//! [17] +QString tr(const char *text, const char *comment, int n); +//! [17] + +//! [18] +tr("%n item(s) replaced", "", count); +//! [18] + +} diff --git a/doc/src/snippets/code/doc_src_linguist-manual.pro b/doc/src/snippets/code/doc_src_linguist-manual.pro new file mode 100644 index 0000000..3b19ba7 --- /dev/null +++ b/doc/src/snippets/code/doc_src_linguist-manual.pro @@ -0,0 +1,62 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +#! [0] +HEADERS = main-dlg.h \ + options-dlg.h +SOURCES = main-dlg.cpp \ + options-dlg.cpp \ + main.cpp +FORMS = search-dlg.ui +TRANSLATIONS = superapp_dk.ts \ + superapp_fi.ts \ + superapp_no.ts \ + superapp_se.ts +#! [0] + + +#! [1] +CODECFORTR = ISO-8859-5 +#! [1] + + +#! [2] +CODECFORSRC = UTF-8 +#! [2] diff --git a/doc/src/snippets/code/doc_src_linguist-manual.qdoc b/doc/src/snippets/code/doc_src_linguist-manual.qdoc index 5975c9a..34b5dcc 100644 --- a/doc/src/snippets/code/doc_src_linguist-manual.qdoc +++ b/doc/src/snippets/code/doc_src_linguist-manual.qdoc @@ -38,35 +38,6 @@ ** ****************************************************************************/ -//! [0] -HEADERS = main-dlg.h \ - options-dlg.h -SOURCES = main-dlg.cpp \ - options-dlg.cpp \ - main.cpp -FORMS = search-dlg.ui -TRANSLATIONS = superapp_dk.ts \ - superapp_fi.ts \ - superapp_no.ts \ - superapp_se.ts -//! [0] - - -//! [1] -CODECFORTR = ISO-8859-5 -//! [1] - - -//! [2] -CODECFORSRC = UTF-8 -//! [2] - - -//! [3] -label->setText(tr("F\374r \310lise")); -//! [3] - - //! [4] Usage: lupdate [options] [project-file] @@ -116,118 +87,3 @@ Options: -version Display the version of lrelease and exit //! [5] - - -void wrapInFunction() -{ -//! [6] -button = new QPushButton("&Quit", this); -//! [6] - - -//! [7] -button = new QPushButton(tr("&Quit"), this); -//! [7] - - -//! [8] -QPushButton::tr("&Quit") -//! [8] - - -//! [9] -QObject::tr("&Quit") -//! [9] - - -//! [10] -rbc = new QRadioButton(tr("Enabled", "Color frame"), this); -//! [10] - - -//! [11] -rbh = new QRadioButton(tr("Enabled", "Hue frame"), this); -//! [11] -} - - -//! [12] -/* - TRANSLATOR FindDialog - - Choose Edit|Find from the menu bar or press Ctrl+F to pop up the - Find dialog. - - ... -*/ -//! [12] - -//! [13] -/* - TRANSLATOR MyNamespace::MyClass - - Necessary for lupdate. - - ... -*/ -//! [13] - -//! [14] -void some_global_function(LoginWidget *logwid) -{ - QLabel *label = new QLabel( - LoginWidget::tr("Password:"), logwid); -} - -void same_global_function(LoginWidget *logwid) -{ - QLabel *label = new QLabel( - qApp->translate("LoginWidget", "Password:"), - logwid); -} -//! [14] - - -//! [15] -QString FriendlyConversation::greeting(int greet_type) -{ - static const char* greeting_strings[] = { - QT_TR_NOOP("Hello"), - QT_TR_NOOP("Goodbye") - }; - return tr(greeting_strings[greet_type]); -} -//! [15] - - -//! [16] -static const char* greeting_strings[] = { - QT_TRANSLATE_NOOP("FriendlyConversation", "Hello"), - QT_TRANSLATE_NOOP("FriendlyConversation", "Goodbye") -}; - -QString FriendlyConversation::greeting(int greet_type) -{ - return tr(greeting_strings[greet_type]); -} - -QString global_greeting(int greet_type) -{ - return qApp->translate("FriendlyConversation", - greeting_strings[greet_type]); -} -//! [16] - -void wrapInFunction() -{ - -//! [17] -QString tr(const char *text, const char *comment, int n); -//! [17] - -//! [18] -tr("%n item(s) replaced", "", count); -//! [18] - -} - diff --git a/doc/src/snippets/code/doc_src_mac-differences.cpp b/doc/src/snippets/code/doc_src_mac-differences.cpp new file mode 100644 index 0000000..f261083 --- /dev/null +++ b/doc/src/snippets/code/doc_src_mac-differences.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +//! [1] +#ifdef Q_WS_MAC + CFURLRef appUrlRef = CFBundleCopyBundleURL(CFBundleGetMainBundle()); + CFStringRef macPath = CFURLCopyFileSystemPath(appUrlRef, + kCFURLPOSIXPathStyle); + const char *pathPtr = CFStringGetCStringPtr(macPath, + CFStringGetSystemEncoding()); + qDebug("Path = %s", pathPtr); + CFRelease(appUrlRef); + CFRelease(macPath); +#endif +//! [1] diff --git a/doc/src/snippets/code/doc_src_mac-differences.pro b/doc/src/snippets/code/doc_src_mac-differences.pro new file mode 100644 index 0000000..3490bfe --- /dev/null +++ b/doc/src/snippets/code/doc_src_mac-differences.pro @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +#! [0] +QMAKE_LFLAGS_SONAME = -Wl,-install_name,@executable_path/../Frameworks/ +#! [0] diff --git a/doc/src/snippets/code/doc_src_moc.cpp b/doc/src/snippets/code/doc_src_moc.cpp new file mode 100644 index 0000000..ec756e1 --- /dev/null +++ b/doc/src/snippets/code/doc_src_moc.cpp @@ -0,0 +1,144 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +//! [3] +#include "foo.moc" +//! [3] + + +//! [4] +#ifndef Q_MOC_RUN + ... +#endif +//! [4] + + +//! [5] +class SomeTemplate<int> : public QFrame +{ + Q_OBJECT + ... + +signals: + void mySignal(int); +}; +//! [5] + + +//! [6] +// correct +class SomeClass : public QObject, public OtherClass +{ + ... +}; +//! [6] + + +//! [7] +class SomeClass : public QObject +{ + Q_OBJECT + +public slots: + void apply(void (*apply)(List *, void *), char *); // WRONG +}; +//! [7] + + +//! [8] +typedef void (*ApplyFunction)(List *, void *); + +class SomeClass : public QObject +{ + Q_OBJECT + +public slots: + void apply(ApplyFunction, char *); +}; +//! [8] + + +//! [9] +class MyClass : public QObject +{ + Q_OBJECT + + enum Error { + ConnectionRefused, + RemoteHostClosed, + UnknownError + }; + +signals: + void stateChanged(MyClass::Error error); +}; +//! [9] + + +//! [10] +#ifdef ultrix +#define SIGNEDNESS(a) unsigned a +#else +#define SIGNEDNESS(a) a +#endif + +class Whatever : public QObject +{ + Q_OBJECT + +signals: + void someSignal(SIGNEDNESS(int)); +}; +//! [10] + + +//! [11] +class A +{ +public: + class B + { + Q_OBJECT + + public slots: // WRONG + void b(); + }; +}; +//! [11] diff --git a/doc/src/snippets/code/doc_src_moc.qdoc b/doc/src/snippets/code/doc_src_moc.qdoc index ef85b1b..74ab365 100644 --- a/doc/src/snippets/code/doc_src_moc.qdoc +++ b/doc/src/snippets/code/doc_src_moc.qdoc @@ -56,109 +56,3 @@ foo.o: foo.moc foo.moc: foo.cpp moc $(DEFINES) $(INCPATH) -i $< -o $@ //! [2] - - -//! [3] -#include "foo.moc" -//! [3] - - -//! [4] -#ifndef Q_MOC_RUN - ... -#endif -//! [4] - - -//! [5] -class SomeTemplate<int> : public QFrame -{ - Q_OBJECT - ... - -signals: - void mySignal(int); -}; -//! [5] - - -//! [6] -// correct -class SomeClass : public QObject, public OtherClass -{ - ... -}; -//! [6] - - -//! [7] -class SomeClass : public QObject -{ - Q_OBJECT - -public slots: - void apply(void (*apply)(List *, void *), char *); // WRONG -}; -//! [7] - - -//! [8] -typedef void (*ApplyFunction)(List *, void *); - -class SomeClass : public QObject -{ - Q_OBJECT - -public slots: - void apply(ApplyFunction, char *); -}; -//! [8] - - -//! [9] -class MyClass : public QObject -{ - Q_OBJECT - - enum Error { - ConnectionRefused, - RemoteHostClosed, - UnknownError - }; - -signals: - void stateChanged(MyClass::Error error); -}; -//! [9] - - -//! [10] -#ifdef ultrix -#define SIGNEDNESS(a) unsigned a -#else -#define SIGNEDNESS(a) a -#endif - -class Whatever : public QObject -{ - Q_OBJECT - -signals: - void someSignal(SIGNEDNESS(int)); -}; -//! [10] - - -//! [11] -class A -{ -public: - class B - { - Q_OBJECT - - public slots: // WRONG - void b(); - }; -}; -//! [11] diff --git a/doc/src/snippets/code/doc_src_model-view-programming.qdoc b/doc/src/snippets/code/doc_src_model-view-programming.cpp index 05c2e1d..05c2e1d 100644 --- a/doc/src/snippets/code/doc_src_model-view-programming.qdoc +++ b/doc/src/snippets/code/doc_src_model-view-programming.cpp diff --git a/doc/src/snippets/code/doc_src_modules.qdoc b/doc/src/snippets/code/doc_src_modules.pro index 643a94d..5871540 100644 --- a/doc/src/snippets/code/doc_src_modules.qdoc +++ b/doc/src/snippets/code/doc_src_modules.pro @@ -38,6 +38,6 @@ ** ****************************************************************************/ -//! [0] +#! [0] QT -= gui -//! [0] +#! [0] diff --git a/doc/src/snippets/code/doc_src_objecttrees.qdoc b/doc/src/snippets/code/doc_src_objecttrees.cpp index cd92a49..cd92a49 100644 --- a/doc/src/snippets/code/doc_src_objecttrees.qdoc +++ b/doc/src/snippets/code/doc_src_objecttrees.cpp diff --git a/doc/src/snippets/code/doc_src_phonon-api.qdoc b/doc/src/snippets/code/doc_src_phonon-api.cpp index d7a989b..d7a989b 100644 --- a/doc/src/snippets/code/doc_src_phonon-api.qdoc +++ b/doc/src/snippets/code/doc_src_phonon-api.cpp diff --git a/doc/src/snippets/code/doc_src_phonon.pro b/doc/src/snippets/code/doc_src_phonon.pro new file mode 100644 index 0000000..24cc7bd --- /dev/null +++ b/doc/src/snippets/code/doc_src_phonon.pro @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +#! [0] +QT += phonon +#! [0] diff --git a/doc/src/snippets/code/doc_src_plugins-howto.cpp b/doc/src/snippets/code/doc_src_plugins-howto.cpp new file mode 100644 index 0000000..06bf903 --- /dev/null +++ b/doc/src/snippets/code/doc_src_plugins-howto.cpp @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +//! [0] +class MyStylePlugin : public QStylePlugin +{ +public: + QStringList keys() const; + QStyle *create(const QString &key); +}; +//! [0] + + +//! [1] +#include "mystyleplugin.h" + +QStringList MyStylePlugin::keys() const +{ + return QStringList() << "MyStyle"; +} + +QStyle *MyStylePlugin::create(const QString &key) +{ + if (key.toLower() == "mystyle") + return new MyStyle; + return 0; +} + +Q_EXPORT_PLUGIN2(pnp_mystyleplugin, MyStylePlugin) +//! [1] + + +//! [2] +QApplication::setStyle(QStyleFactory::create("MyStyle")); +//! [2] + + +//! [4] +#include <QApplication> +#include <QtPlugin> + +Q_IMPORT_PLUGIN(qjpeg) +Q_IMPORT_PLUGIN(qgif) +Q_IMPORT_PLUGIN(qkrcodecs) + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + ... + return app.exec(); +} +//! [4] diff --git a/doc/src/snippets/code/doc_src_plugins-howto.pro b/doc/src/snippets/code/doc_src_plugins-howto.pro new file mode 100644 index 0000000..eb0ec28 --- /dev/null +++ b/doc/src/snippets/code/doc_src_plugins-howto.pro @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +#! [3] +CONFIG += release +#! [3] + + +#! [5] +QTPLUGIN += qjpeg \ + qgif \ + qkrcodecs +#! [5] diff --git a/doc/src/snippets/code/doc_src_plugins-howto.qdoc b/doc/src/snippets/code/doc_src_plugins-howto.qdoc index e80faee..b03dfed 100644 --- a/doc/src/snippets/code/doc_src_plugins-howto.qdoc +++ b/doc/src/snippets/code/doc_src_plugins-howto.qdoc @@ -38,69 +38,6 @@ ** ****************************************************************************/ -//! [0] -class MyStylePlugin : public QStylePlugin -{ -public: - QStringList keys() const; - QStyle *create(const QString &key); -}; -//! [0] - - -//! [1] -#include "mystyleplugin.h" - -QStringList MyStylePlugin::keys() const -{ - return QStringList() << "MyStyle"; -} - -QStyle *MyStylePlugin::create(const QString &key) -{ - if (key.toLower() == "mystyle") - return new MyStyle; - return 0; -} - -Q_EXPORT_PLUGIN2(pnp_mystyleplugin, MyStylePlugin) -//! [1] - - -//! [2] -QApplication::setStyle(QStyleFactory::create("MyStyle")); -//! [2] - - -//! [3] -CONFIG += release -//! [3] - - -//! [4] -#include <QApplication> -#include <QtPlugin> - -Q_IMPORT_PLUGIN(qjpeg) -Q_IMPORT_PLUGIN(qgif) -Q_IMPORT_PLUGIN(qkrcodecs) - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - ... - return app.exec(); -} -//! [4] - - -//! [5] -QTPLUGIN += qjpeg \ - qgif \ - qkrcodecs -//! [5] - - //! [6] HKEY_CURRENT_USER\Software\Trolltech\OrganizationDefaults\Qt Plugin Cache 4.2.debug HKEY_CURRENT_USER\Software\Trolltech\OrganizationDefaults\Qt Plugin Cache 4.2.false diff --git a/doc/src/snippets/code/doc_src_porting-qsa.cpp b/doc/src/snippets/code/doc_src_porting-qsa.cpp new file mode 100644 index 0000000..f9b9c6b --- /dev/null +++ b/doc/src/snippets/code/doc_src_porting-qsa.cpp @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +//! [16] +QPushButton *button = new QPushButton(); +button->setObjectName("button"); +interpreter->addTransientObject(button); +//! [16] + + +//! [17] +QPushButton *button = new QPushButton(); +QScriptValue scriptButton = engine.newQObject(button); +engine.globalObject().setProperty("button", scriptButton); +//! [17] + + +//! [18] +ModuleFactory::ModuleFactory() +{ + registerClass( "ImageSource", &ImgSource::staticMetaObject); + ... +} + +QObject *ModuleFactory::create( const QString &type, + const QVariantList &, + QObject * ) +{ + if ( type == "ImageSource" ) + return new ImgSource(); + ... +} + +... + +interpreter.addObjectFactory(new ModuleFactory()); +//! [18] + + +//! [19] +QScriptValue construct_QPushButton(QScriptContext *, QScriptEngine *engine) { + return engine->newQObject(new QPushButton()); +} + +... + +QScriptValue constructor = engine.newFunction(construct_QPushButton); +QScriptValue value = + engine.newQMetaObject(&QPushButton::staticMetaObject, + constructor); +engine.globalObject().setProperty("QPushButton", value); +//! [19] diff --git a/doc/src/snippets/code/doc_src_porting-qsa.js b/doc/src/snippets/code/doc_src_porting-qsa.js new file mode 100644 index 0000000..e58f5b7 --- /dev/null +++ b/doc/src/snippets/code/doc_src_porting-qsa.js @@ -0,0 +1,117 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +//! [0] +point = new Object(); +point.x = 12; +point.y = 35; +//! [0] + + +//! [1] +function manhattanLength(point) { + return point.x + point.y; +} +//! [1] + + +//! [2] +manhattanLength = function(point) { + return point.x + point.y; +} +//! [2] + + +//! [3] +point.manhattanLength = function() { + return this.x + this.y; +} +print(point.manhattanLength()); // prints 47 +//! [3] + + +//! [5] +point.manhattanLength = function() { + return this.x + this.y; +} +print(point.manhattanLength()); // prints 47 +//! [5] + + +//! [8] +var car = new Object(); +car.constructor = function(regnr) { + // ... +} +car.constructor(); +//! [8] + + +//! [10] +function Car(regnr) { + this.regNumber = regnr; + this.toString = function() { return this.regNumber; } +} +//! [10] + + +//! [11] +function Car(regnr) { + this.regNumber = regnr; +} +Car.prototype.toString = function() { return this.regNumber; } +//! [11] + + +//! [13] +function GasolineCar(regnr) { + Car(regnr); +} +GasolineCar.prototype = new Car(); +GasolineCar.prototype.toString = function() { + return "GasolineCar(" + this.regNumber + ")"; +} +//! [13] + + +//! [15] +Car.globalCount = 0; +print(Car.globalCount); +//! [15] diff --git a/doc/src/snippets/code/doc_src_porting-qsa.qdoc b/doc/src/snippets/code/doc_src_porting-qsa.qdoc index bb0b7fd..1846640 100644 --- a/doc/src/snippets/code/doc_src_porting-qsa.qdoc +++ b/doc/src/snippets/code/doc_src_porting-qsa.qdoc @@ -38,35 +38,6 @@ ** ****************************************************************************/ -//! [0] -point = new Object(); -point.x = 12; -point.y = 35; -//! [0] - - -//! [1] -function manhattanLength(point) { - return point.x + point.y; -} -//! [1] - - -//! [2] -manhattanLength = function(point) { - return point.x + point.y; -} -//! [2] - - -//! [3] -point.manhattanLength = function() { - return this.x + this.y; -} -print(point.manhattanLength()); // prints 47 -//! [3] - - //! [4] class Point() { var x; @@ -76,14 +47,6 @@ class Point() { //! [4] -//! [5] -point.manhattanLength = function() { - return this.x + this.y; -} -print(point.manhattanLength()); // prints 47 -//! [5] - - //! [6] class Car { var regNumber; @@ -103,13 +66,6 @@ var car = new Car("ABC 123"); //! [7] -//! [8] -var car = new Object(); -car.constructor = function(regnr) { ... } -car.constructor(); -//! [8] - - //! [9] class Car { var regNumber; @@ -123,22 +79,6 @@ class Car { //! [9] -//! [10] -function Car(regnr) { - this.regNumber = regnr; - this.toString = function() { return this.regNumber; } -} -//! [10] - - -//! [11] -function Car(regnr) { - this.regNumber = regnr; -} -Car.prototype.toString = function() { return this.regNumber; } -//! [11] - - //! [12] class GasolineCar extends Car { function GasolineCar(regnr) { @@ -151,77 +91,9 @@ class GasolineCar extends Car { //! [12] -//! [13] -function GasolineCar(regnr) { - Car(regnr); -} -GasolineCar.prototype = new Car(); -GasolineCar.prototype.toString = function() { - return "GasolineCar(" + this.regNumber + ")"; -} -//! [13] - - //! [14] class Car { static var globalCount = 0; } print(Car.globalCount); //! [14] - - -//! [15] -Car.globalCount = 0; -print(Car.globalCount); -//! [15] - - -//! [16] -QPushButton *button = new QPushButton(); -button->setObjectName("button"); -interpreter->addTransientObject(button); -//! [16] - - -//! [17] -QPushButton *button = new QPushButton(); -QScriptValue scriptButton = engine.newQObject(button); -engine.globalObject().setProperty("button", scriptButton); -//! [17] - - -//! [18] -ModuleFactory::ModuleFactory() -{ - registerClass( "ImageSource", &ImgSource::staticMetaObject); - ... -} - -QObject *ModuleFactory::create( const QString &type, - const QVariantList &, - QObject * ) -{ - if ( type == "ImageSource" ) - return new ImgSource(); - ... -} - -... - -interpreter.addObjectFactory(new ModuleFactory()); -//! [18] - - -//! [19] -QScriptValue construct_QPushButton(QScriptContext *, QScriptEngine *engine) { - return engine->newQObject(new QPushButton()); -} - -... - -QScriptValue constructor = engine.newFunction(construct_QPushButton); -QScriptValue value = - engine.newQMetaObject(&QPushButton::staticMetaObject, - constructor); -engine.globalObject().setProperty("QPushButton", value); -//! [19] diff --git a/doc/src/snippets/code/doc_src_porting4-canvas.qdoc b/doc/src/snippets/code/doc_src_porting4-canvas.cpp index 8004163..8004163 100644 --- a/doc/src/snippets/code/doc_src_porting4-canvas.qdoc +++ b/doc/src/snippets/code/doc_src_porting4-canvas.cpp diff --git a/doc/src/snippets/code/doc_src_porting4-designer.cpp b/doc/src/snippets/code/doc_src_porting4-designer.cpp new file mode 100644 index 0000000..1d73aae --- /dev/null +++ b/doc/src/snippets/code/doc_src_porting4-designer.cpp @@ -0,0 +1,173 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +//! [0] +namespace Ui { + +class HelloWorld +{ +public: + QVBoxLayout *vboxLayout; + QPushButton *pushButton; + + void setupUi(QWidget *HelloWorld) + { + HelloWorld->setObjectName(QString::fromUtf8("HelloWorld")); + + vboxLayout = new QVBoxLayout(HelloWorld); + vboxLayout->setObjectName(QString::fromUtf8("vboxLayout")); + + pushButton = new QPushButton(HelloWorld); + pushButton->setObjectName(QString::fromUtf8("pushButton")); + + vboxLayout->addWidget(pushButton); + + retranslateUi(HelloWorld); + } +}; + +} +//! [0] + + +//! [1] +#include <QApplication> +#include <QWidget> + +#include "ui_helloworld.h" // defines Ui::HelloWorld + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + QWidget w; + Ui::HelloWorld ui; + ui.setupUi(&w); + + w.show(); + return app.exec(); +} +//! [1] + + +//! [2] +#include <QApplication> +#include <QWidget> + +#include "ui_helloworld.h" // defines Ui::HelloWorld + +class HelloWorldWidget : public QWidget, public Ui::HelloWorld +{ + Q_OBJECT + +public: + HelloWorldWidget(QWidget *parent = 0) + : QWidget(parent) + { setupUi(this); } +}; + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + HelloWorldWidget w; + w.show(); + return app.exec(); +} +//! [2] + + +//! [5] +class HelloWorldWidget : public QWidget, public Ui::HelloWorld +{ + Q_OBJECT + +public: + HelloWorldWidget(QWidget *parent = 0); + +public slots: + void mySlot(); +}; + +HelloWorldWidget::HelloWorldWidget(QWidget *parent) + : QWidget(parent) +{ + setupUi(this); + + QObject::connect(pushButton, SIGNAL(clicked()), + this, SLOT(mySlot())); +} + +void HelloWorldWidget::mySlot() +{ + ... +} +//! [5] + + +//! [6] +class HelloWorldWidget : public QWidget, public Ui::HelloWorld +{ + Q_OBJECT + +public: + HelloWorldWidget(QWidget *parent = 0); + +public slots: + void on_pushButton_clicked(); +}; + +HelloWorldWidget::HelloWorldWidget(QWidget *parent) + : QWidget(parent) +{ + setupUi(this); +} + +void HelloWorldWidget::on_pushButton_clicked() +{ + ... +} +//! [6] + + +//! [9] +QFile file(":/icons/yes.png"); +QIcon icon(":/icons/no.png"); +QPixmap pixmap(":/icons/no.png"); +//! [9] diff --git a/doc/src/snippets/code/doc_src_porting4-designer.pro b/doc/src/snippets/code/doc_src_porting4-designer.pro new file mode 100644 index 0000000..673e593 --- /dev/null +++ b/doc/src/snippets/code/doc_src_porting4-designer.pro @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +#! [8] +RESOURCES += icons.qrc +#! [8] diff --git a/doc/src/snippets/code/doc_src_porting4-designer.qdoc b/doc/src/snippets/code/doc_src_porting4-designer.qdoc index 2c043f5..b5c686b 100644 --- a/doc/src/snippets/code/doc_src_porting4-designer.qdoc +++ b/doc/src/snippets/code/doc_src_porting4-designer.qdoc @@ -38,81 +38,6 @@ ** ****************************************************************************/ -//! [0] -namespace Ui { - -class HelloWorld -{ -public: - QVBoxLayout *vboxLayout; - QPushButton *pushButton; - - void setupUi(QWidget *HelloWorld) - { - HelloWorld->setObjectName(QString::fromUtf8("HelloWorld")); - - vboxLayout = new QVBoxLayout(HelloWorld); - vboxLayout->setObjectName(QString::fromUtf8("vboxLayout")); - - pushButton = new QPushButton(HelloWorld); - pushButton->setObjectName(QString::fromUtf8("pushButton")); - - vboxLayout->addWidget(pushButton); - - retranslateUi(HelloWorld); - } -}; - -} -//! [0] - - -//! [1] -#include <QApplication> -#include <QWidget> - -#include "ui_helloworld.h" // defines Ui::HelloWorld - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - - QWidget w; - Ui::HelloWorld ui; - ui.setupUi(&w); - - w.show(); - return app.exec(); -} -//! [1] - - -//! [2] -#include <QApplication> -#include <QWidget> - -#include "ui_helloworld.h" // defines Ui::HelloWorld - -class HelloWorldWidget : public QWidget, public Ui::HelloWorld -{ - Q_OBJECT - -public: - HelloWorldWidget(QWidget *parent = 0) - : QWidget(parent) - { setupUi(this); } -}; - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - HelloWorldWidget w; - w.show(); - return app.exec(); -} -//! [2] - - //! [3] uic3 myform.ui > myform.h uic3 -impl myform.h myform.ui > myform.cpp @@ -124,59 +49,6 @@ uic3 -convert myform3.ui > myform4.ui //! [4] -//! [5] -class HelloWorldWidget : public QWidget, public Ui::HelloWorld -{ - Q_OBJECT - -public: - HelloWorldWidget(QWidget *parent = 0); - -public slots: - void mySlot(); -}; - -HelloWorldWidget::HelloWorldWidget(QWidget *parent) - : QWidget(parent) -{ - setupUi(this); - - QObject::connect(pushButton, SIGNAL(clicked()), - this, SLOT(mySlot())); -} - -void HelloWorldWidget::mySlot() -{ - ... -} -//! [5] - - -//! [6] -class HelloWorldWidget : public QWidget, public Ui::HelloWorld -{ - Q_OBJECT - -public: - HelloWorldWidget(QWidget *parent = 0); - -public slots: - void on_pushButton_clicked(); -}; - -HelloWorldWidget::HelloWorldWidget(QWidget *parent) - : QWidget(parent) -{ - setupUi(this); -} - -void HelloWorldWidget::on_pushButton_clicked() -{ - ... -} -//! [6] - - //! [7] <RCC version="1.0"> <qresource prefix="/icons"> @@ -185,15 +57,3 @@ void HelloWorldWidget::on_pushButton_clicked() </qresource> </RCC> //! [7] - - -//! [8] -RESOURCES += icons.qrc -//! [8] - - -//! [9] -QFile file(":/icons/yes.png"); -QIcon icon(":/icons/no.png"); -QPixmap pixmap(":/icons/no.png"); -//! [9] diff --git a/doc/src/snippets/code/doc_src_porting4.qdoc b/doc/src/snippets/code/doc_src_porting4.cpp index 14c708a..14c708a 100644 --- a/doc/src/snippets/code/doc_src_porting4.qdoc +++ b/doc/src/snippets/code/doc_src_porting4.cpp diff --git a/doc/src/snippets/code/doc_src_properties.qdoc b/doc/src/snippets/code/doc_src_properties.cpp index 1238bc5..b5a103d 100644 --- a/doc/src/snippets/code/doc_src_properties.qdoc +++ b/doc/src/snippets/code/doc_src_properties.cpp @@ -44,6 +44,7 @@ Q_PROPERTY(type name [WRITE setFunction] [RESET resetFunction] [NOTIFY notifySignal] + [REVISION int] [DESIGNABLE bool] [SCRIPTABLE bool] [STORED bool] diff --git a/doc/src/snippets/code/doc_src_q3asciidict.qdoc b/doc/src/snippets/code/doc_src_q3asciidict.cpp index 4b32817..4b32817 100644 --- a/doc/src/snippets/code/doc_src_q3asciidict.qdoc +++ b/doc/src/snippets/code/doc_src_q3asciidict.cpp diff --git a/doc/src/snippets/code/doc_src_q3dict.qdoc b/doc/src/snippets/code/doc_src_q3dict.cpp index 9c51cae..9c51cae 100644 --- a/doc/src/snippets/code/doc_src_q3dict.qdoc +++ b/doc/src/snippets/code/doc_src_q3dict.cpp diff --git a/doc/src/snippets/code/doc_src_q3intdict.qdoc b/doc/src/snippets/code/doc_src_q3intdict.cpp index 0f15b6f..0f15b6f 100644 --- a/doc/src/snippets/code/doc_src_q3intdict.qdoc +++ b/doc/src/snippets/code/doc_src_q3intdict.cpp diff --git a/doc/src/snippets/code/doc_src_q3memarray.cpp b/doc/src/snippets/code/doc_src_q3memarray.cpp new file mode 100644 index 0000000..2c91050 --- /dev/null +++ b/doc/src/snippets/code/doc_src_q3memarray.cpp @@ -0,0 +1,108 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +//! [0] +#include <q3memarray.h> +#include <stdio.h> + +Q3MemArray<int> fib( int num ) // returns fibonacci array +{ + Q_ASSERT( num > 2 ); + Q3MemArray<int> f( num ); // array of ints + + f[0] = f[1] = 1; + for ( int i = 2; i < num; i++ ) + f[i] = f[i-1] + f[i-2]; + + return f; +} + +int main() +{ + Q3MemArray<int> a = fib( 6 ); // get first 6 fibonaccis + for ( int i = 0; i < a.size(); i++ ) + qDebug( "%d: %d", i, a[i] ); + + qDebug( "1 is found %d times", a.contains(1) ); + qDebug( "5 is found at index %d", a.find(5) ); + + return 0; +} +//! [0] + + +//! [2] +// MyStruct may be padded to 4 or 8 bytes +struct MyStruct +{ + short i; // 2 bytes + char c; // 1 byte +}; + +Q3MemArray<MyStruct> a(1); +a[0].i = 5; +a[0].c = 't'; + +MyStruct x; +x.i = '5'; +x.c = 't'; +int i = a.find( x ); // may return -1 if the pad bytes differ +//! [2] + + +//! [3] +static char bindata[] = { 231, 1, 44, ... }; +QByteArray a; +a.setRawData( bindata, sizeof(bindata) ); // a points to bindata +QDataStream s( a, IO_ReadOnly ); // open on a's data +s >> <something>; // read raw bindata +a.resetRawData( bindata, sizeof(bindata) ); // finished +//! [3] + + +//! [4] +static char bindata[] = { 231, 1, 44, ... }; +QByteArray a, b; +a.setRawData( bindata, sizeof(bindata) ); // a points to bindata +a.resize( 8 ); // will crash +b = a; // will crash +a[2] = 123; // might crash +// forget to resetRawData: will crash +//! [4] diff --git a/doc/src/snippets/code/doc_src_q3memarray.qdoc b/doc/src/snippets/code/doc_src_q3memarray.qdoc index 8e5e008..a966e50 100644 --- a/doc/src/snippets/code/doc_src_q3memarray.qdoc +++ b/doc/src/snippets/code/doc_src_q3memarray.qdoc @@ -38,36 +38,6 @@ ** ****************************************************************************/ -//! [0] -#include <q3memarray.h> -#include <stdio.h> - -Q3MemArray<int> fib( int num ) // returns fibonacci array -{ - Q_ASSERT( num > 2 ); - Q3MemArray<int> f( num ); // array of ints - - f[0] = f[1] = 1; - for ( int i = 2; i < num; i++ ) - f[i] = f[i-1] + f[i-2]; - - return f; -} - -int main() -{ - Q3MemArray<int> a = fib( 6 ); // get first 6 fibonaccis - for ( int i = 0; i < a.size(); i++ ) - qDebug( "%d: %d", i, a[i] ); - - qDebug( "1 is found %d times", a.contains(1) ); - qDebug( "5 is found at index %d", a.find(5) ); - - return 0; -} -//! [0] - - //! [1] 0: 1 1: 1 @@ -78,43 +48,3 @@ int main() 1 is found 2 times 5 is found at index 4 //! [1] - - -//! [2] -// MyStruct may be padded to 4 or 8 bytes -struct MyStruct -{ - short i; // 2 bytes - char c; // 1 byte -}; - -Q3MemArray<MyStruct> a(1); -a[0].i = 5; -a[0].c = 't'; - -MyStruct x; -x.i = '5'; -x.c = 't'; -int i = a.find( x ); // may return -1 if the pad bytes differ -//! [2] - - -//! [3] -static char bindata[] = { 231, 1, 44, ... }; -QByteArray a; -a.setRawData( bindata, sizeof(bindata) ); // a points to bindata -QDataStream s( a, IO_ReadOnly ); // open on a's data -s >> <something>; // read raw bindata -a.resetRawData( bindata, sizeof(bindata) ); // finished -//! [3] - - -//! [4] -static char bindata[] = { 231, 1, 44, ... }; -QByteArray a, b; -a.setRawData( bindata, sizeof(bindata) ); // a points to bindata -a.resize( 8 ); // will crash -b = a; // will crash -a[2] = 123; // might crash -// forget to resetRawData: will crash -//! [4] diff --git a/doc/src/snippets/code/doc_src_q3ptrdict.qdoc b/doc/src/snippets/code/doc_src_q3ptrdict.cpp index e64d874..e64d874 100644 --- a/doc/src/snippets/code/doc_src_q3ptrdict.qdoc +++ b/doc/src/snippets/code/doc_src_q3ptrdict.cpp diff --git a/doc/src/snippets/code/doc_src_q3ptrlist.qdoc b/doc/src/snippets/code/doc_src_q3ptrlist.cpp index 4f97c65..4f97c65 100644 --- a/doc/src/snippets/code/doc_src_q3ptrlist.qdoc +++ b/doc/src/snippets/code/doc_src_q3ptrlist.cpp diff --git a/doc/src/snippets/code/doc_src_q3valuelist.qdoc b/doc/src/snippets/code/doc_src_q3valuelist.cpp index 38ee9f6..38ee9f6 100644 --- a/doc/src/snippets/code/doc_src_q3valuelist.qdoc +++ b/doc/src/snippets/code/doc_src_q3valuelist.cpp diff --git a/doc/src/snippets/code/doc_src_q3valuestack.qdoc b/doc/src/snippets/code/doc_src_q3valuestack.cpp index 50827e6..50827e6 100644 --- a/doc/src/snippets/code/doc_src_q3valuestack.qdoc +++ b/doc/src/snippets/code/doc_src_q3valuestack.cpp diff --git a/doc/src/snippets/code/doc_src_q3valuevector.qdoc b/doc/src/snippets/code/doc_src_q3valuevector.cpp index 8af1568..8af1568 100644 --- a/doc/src/snippets/code/doc_src_q3valuevector.qdoc +++ b/doc/src/snippets/code/doc_src_q3valuevector.cpp diff --git a/doc/src/snippets/code/doc_src_qalgorithms.qdoc b/doc/src/snippets/code/doc_src_qalgorithms.cpp index 0438105..0438105 100644 --- a/doc/src/snippets/code/doc_src_qalgorithms.qdoc +++ b/doc/src/snippets/code/doc_src_qalgorithms.cpp diff --git a/doc/src/snippets/code/doc_src_qaxcontainer.qdoc b/doc/src/snippets/code/doc_src_qaxcontainer.pro index 93aa60b..ff39e67 100644 --- a/doc/src/snippets/code/doc_src_qaxcontainer.qdoc +++ b/doc/src/snippets/code/doc_src_qaxcontainer.pro @@ -38,11 +38,11 @@ ** ****************************************************************************/ -//! [0] +#! [0] CONFIG += qaxcontainer -//! [0] +#! [0] -//! [1] +#! [1] TYPELIBS = file.tlb -//! [1] +#! [1] diff --git a/doc/src/snippets/code/doc_src_qaxserver.cpp b/doc/src/snippets/code/doc_src_qaxserver.cpp new file mode 100644 index 0000000..dc16776 --- /dev/null +++ b/doc/src/snippets/code/doc_src_qaxserver.cpp @@ -0,0 +1,218 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +//! [3] +#include <QWidget> + +class MyActiveX : public QWidget +{ + Q_OBJECT +//! [3] + + +//! [4] +Q_CLASSINFO("ClassID", "{1D9928BD-4453-4bdd-903D-E525ED17FDE5}") +Q_CLASSINFO("InterfaceID", "{99F6860E-2C5A-42ec-87F2-43396F4BE389}") +Q_CLASSINFO("EventsID", "{0A3E9F27-E4F1-45bb-9E47-63099BCCD0E3}") +//! [4] + + +//! [5] +Q_PROPERTY(int value READ value WRITE setValue) +//! [5] + + +//! [6] +public: + MyActiveX(QWidget *parent = 0) + ... + + int value() const; + +public slots: + void setValue(int v); + ... + +signals: + void valueChange(int v); + ... + +}; +//! [6] + + +//! [7] +#include <QAxBindable> +#include <QWidget> + +class MyActiveX : public QWidget, public QAxBindable +{ + Q_OBJECT +//! [7] + + +//! [8] +QAXFACTORY_BEGIN("{ad90301a-849e-4e8b-9a91-0a6dc5f6461f}", + "{a8f21901-7ff7-4f6a-b939-789620c03d83}") + QAXCLASS(MyWidget) + QAXCLASS(MyWidget2) + QAXTYPE(MySubType) +QAXFACTORY_END() +//! [8] + + +//! [9] +#include <QApplication> +#include <QAxFactory> + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + if (!QAxFactory::isServer()) { + // create and show main window + } + return app.exec(); +} +//! [9] + + +//! [10] +MyFactory(const QUuid &, const QUuid &); +//! [10] + + +//! [11] +HMODULE dll = LoadLibrary("myserver.dll"); +typedef HRESULT(__stdcall *DllRegisterServerProc)(); +DllRegisterServerProc DllRegisterServer = + (DllRegisterServerProc)GetProcAddress(dll, "DllRegisterServer"); + +HRESULT res = E_FAIL; +if (DllRegisterServer) + res = DllRegisterServer(); +if (res != S_OK) + // error handling +//! [11] + + +//! [15] +class MyActiveX : public QWidget +{ + Q_OBJECT + Q_CLASSINFO("Version", "2.0") + Q_CLASSINFO("ClassID", "{7a4cffd8-cbcd-4ae9-ae7e-343e1e5710df}") + Q_CLASSINFO("InterfaceID", "{6fb035bf-8019-48d8-be51-ef05427d8994}") + Q_CLASSINFO("EventsID", "{c42fffdf-6557-47c9-817a-2da2228bc29c}") + Q_CLASSINFO("Insertable", "yes") + Q_CLASSINFO("ToSuperClass", "MyActiveX") + Q_PROPERTY(...) + +public: + MyActiveX(QWidget *parent = 0); + + ... +}; +//! [15] + + +//! [16] +class MyLicensedControl : public QWidget +{ + Q_OBJECT + Q_CLASSINFO("LicenseKey", "<key string>") + ... +}; +//! [16] + + +//! [17] +class AxImpl : public QAxAggregated, public ISomeCOMInterface +{ +public: + AxImpl() {} + + long queryInterface(const QUuid &iid, void **iface); + + // IUnknown + QAXAGG_IUNKNOWN + + // ISomeCOMInterface + ... +} +//! [17] + + +//! [18] +long AxImpl::queryInterface(const QUuid &iid, void **iface) +{ + *iface = 0; + if (iid == IID_ISomeCOMInterface) + *iface = (ISomeCOMInterface *)this; + else + return E_NOINTERFACE; + + AddRef(); + return S_OK; +} +//! [18] + + +//! [19] +HRESULT AxImpl::QueryInterface(REFIID iid, void **iface) +{ + return controllingUnknown()->QueryInterface(iid, iface); +} +//! [19] + + +//! [20] +class MyActiveX : public QWidget, public QAxBindable +{ + Q_OBJECT + +public: + MyActiveX(QWidget *parent); + + QAxAggregated *createAggregate() + { + return new AxImpl(); + } +}; +//! [20] diff --git a/doc/src/snippets/code/doc_src_qaxserver.pro b/doc/src/snippets/code/doc_src_qaxserver.pro new file mode 100644 index 0000000..18d66f3 --- /dev/null +++ b/doc/src/snippets/code/doc_src_qaxserver.pro @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +#! [0] +TEMPLATE = app +CONFIG += qaxserver + +RC_FILE = qaxserver.rc +... +#! [0] + + +#! [1] +TEMPLATE = lib +CONFIG += qaxserver dll + +DEF_FILE = qaxserver.def +RC_FILE = qaxserver.rc +... +#! [1] + + +#! [2] +TEMPLATE = lib +VERSION = 2.5 +... +#! [2] diff --git a/doc/src/snippets/code/doc_src_qaxserver.qdoc b/doc/src/snippets/code/doc_src_qaxserver.qdoc index c5906e9..2fd79e3 100644 --- a/doc/src/snippets/code/doc_src_qaxserver.qdoc +++ b/doc/src/snippets/code/doc_src_qaxserver.qdoc @@ -38,126 +38,6 @@ ** ****************************************************************************/ -//! [0] -TEMPLATE = app -CONFIG += qaxserver - -RC_FILE = qaxserver.rc -... -//! [0] - - -//! [1] -TEMPLATE = lib -CONFIG += qaxserver dll - -DEF_FILE = qaxserver.def -RC_FILE = qaxserver.rc -... -//! [1] - - -//! [2] -TEMPLATE = lib -VERSION = 2.5 -... -//! [2] - - -//! [3] -#include <QWidget> - -class MyActiveX : public QWidget -{ - Q_OBJECT -//! [3] - - -//! [4] -Q_CLASSINFO("ClassID", "{1D9928BD-4453-4bdd-903D-E525ED17FDE5}") -Q_CLASSINFO("InterfaceID", "{99F6860E-2C5A-42ec-87F2-43396F4BE389}") -Q_CLASSINFO("EventsID", "{0A3E9F27-E4F1-45bb-9E47-63099BCCD0E3}") -//! [4] - - -//! [5] -Q_PROPERTY(int value READ value WRITE setValue) -//! [5] - - -//! [6] -public: - MyActiveX(QWidget *parent = 0) - ... - - int value() const; - -public slots: - void setValue(int v); - ... - -signals: - void valueChange(int v); - ... - -}; -//! [6] - - -//! [7] -#include <QAxBindable> -#include <QWidget> - -class MyActiveX : public QWidget, public QAxBindable -{ - Q_OBJECT -//! [7] - - -//! [8] -QAXFACTORY_BEGIN("{ad90301a-849e-4e8b-9a91-0a6dc5f6461f}", - "{a8f21901-7ff7-4f6a-b939-789620c03d83}") - QAXCLASS(MyWidget) - QAXCLASS(MyWidget2) - QAXTYPE(MySubType) -QAXFACTORY_END() -//! [8] - - -//! [9] -#include <QApplication> -#include <QAxFactory> - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - if (!QAxFactory::isServer()) { - // create and show main window - } - return app.exec(); -} -//! [9] - - -//! [10] -MyFactory(const QUuid &, const QUuid &); -//! [10] - - -//! [11] -HMODULE dll = LoadLibrary("myserver.dll"); -typedef HRESULT(__stdcall *DllRegisterServerProc)(); -DllRegisterServerProc DllRegisterServer = - (DllRegisterServerProc)GetProcAddress(dll, "DllRegisterServer"); - -HRESULT res = E_FAIL; -if (DllRegisterServer) - res = DllRegisterServer(); -if (res != S_OK) - // error handling -//! [11] - - //! [12] cabarc N simpleax.cab simpleax.exe simple.inf //! [12] @@ -175,89 +55,3 @@ cabarc N simpleax.cab simpleax.exe simple.inf <param name="name" value="value"> <\object> //! [14] - - -//! [15] -class MyActiveX : public QWidget -{ - Q_OBJECT - Q_CLASSINFO("Version", "2.0") - Q_CLASSINFO("ClassID", "{7a4cffd8-cbcd-4ae9-ae7e-343e1e5710df}") - Q_CLASSINFO("InterfaceID", "{6fb035bf-8019-48d8-be51-ef05427d8994}") - Q_CLASSINFO("EventsID", "{c42fffdf-6557-47c9-817a-2da2228bc29c}") - Q_CLASSINFO("Insertable", "yes") - Q_CLASSINFO("ToSuperClass", "MyActiveX") - Q_PROPERTY(...) - -public: - MyActiveX(QWidget *parent = 0); - - ... -}; -//! [15] - - -//! [16] -class MyLicensedControl : public QWidget -{ - Q_OBJECT - Q_CLASSINFO("LicenseKey", "<key string>") - ... -}; -//! [16] - - -//! [17] -class AxImpl : public QAxAggregated, public ISomeCOMInterface -{ -public: - AxImpl() {} - - long queryInterface(const QUuid &iid, void **iface); - - // IUnknown - QAXAGG_IUNKNOWN - - // ISomeCOMInterface - ... -} -//! [17] - - -//! [18] -long AxImpl::queryInterface(const QUuid &iid, void **iface) -{ - *iface = 0; - if (iid == IID_ISomeCOMInterface) - *iface = (ISomeCOMInterface *)this; - else - return E_NOINTERFACE; - - AddRef(); - return S_OK; -} -//! [18] - - -//! [19] -HRESULT AxImpl::QueryInterface(REFIID iid, void **iface) -{ - return controllingUnknown()->QueryInterface(iid, iface); -} -//! [19] - - -//! [20] -class MyActiveX : public QWidget, public QAxBindable -{ - Q_OBJECT - -public: - MyActiveX(QWidget *parent); - - QAxAggregated *createAggregate() - { - return new AxImpl(); - } -}; -//! [20] diff --git a/doc/src/snippets/code/doc_src_qcache.qdoc b/doc/src/snippets/code/doc_src_qcache.cpp index 81fa3cf..81fa3cf 100644 --- a/doc/src/snippets/code/doc_src_qcache.qdoc +++ b/doc/src/snippets/code/doc_src_qcache.cpp diff --git a/doc/src/snippets/code/doc_src_qdbusadaptors.qdoc b/doc/src/snippets/code/doc_src_qdbusadaptors.cpp index abb31a1..749e64b 100644 --- a/doc/src/snippets/code/doc_src_qdbusadaptors.qdoc +++ b/doc/src/snippets/code/doc_src_qdbusadaptors.cpp @@ -39,82 +39,82 @@ ****************************************************************************/ //! [0] - class MainApplicationAdaptor: public QDBusAbstractAdaptor - { - Q_OBJECT - Q_CLASSINFO("D-Bus Interface", "org.kde.DBus.MainApplication") - Q_PROPERTY(QString caption READ caption WRITE setCaption) - Q_PROPERTY(QString organizationName READ organizationName) - Q_PROPERTY(QString organizationDomain READ organizationDomain) - - private: - QApplication *app; - - public: - MainApplicationAdaptor(QApplication *application) - : QDBusAbstractAdaptor(application), app(application) - { - connect(application, SIGNAL(aboutToQuit()), SIGNAL(aboutToQuit())); - connect(application, SIGNAL(focusChanged(QWidget*, QWidget*)), - SLOT(focusChangedSlot(QWidget*, QWidget*))); - } - - QString caption() - { - if (app->hasMainWindow()) - return app->mainWindow()->caption(); - return QString(""); // must not return a null QString - } - - void setCaption(const QString &newCaption) - { - if (app->hasMainWindow()) - app->mainWindow()->setCaption(newCaption); - } - - QString organizationName() - { - return app->organizationName(); - } - - QString organizationDomain() - { - return app->organizationDomain(); - } - - public slots: - Q_NOREPLY void quit() - { app->quit(); } - - void reparseConfiguration() - { app->reparseConfiguration(); } - - QString mainWindowObject() - { - if (app->hasMainWindow()) - return QString("/%1/mainwindow").arg(app->applicationName()); - return QString(); - } - - void setSessionManagement(bool enable) - { - if (enable) - app->enableSessionManagement(); - else - app->disableSessionManagement(); - } - - private slots: - void focusChangedSlot(QWidget *, QWidget *now) - { - if (now == app->mainWindow()) - emit mainWindowHasFocus(); - } - - signals: - void aboutToQuit(); - void mainWindowHasFocus(); - }; +class MainApplicationAdaptor: public QDBusAbstractAdaptor +{ + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "org.kde.DBus.MainApplication") + Q_PROPERTY(QString caption READ caption WRITE setCaption) + Q_PROPERTY(QString organizationName READ organizationName) + Q_PROPERTY(QString organizationDomain READ organizationDomain) + +private: + QApplication *app; + +public: + MainApplicationAdaptor(QApplication *application) + : QDBusAbstractAdaptor(application), app(application) + { + connect(application, SIGNAL(aboutToQuit()), SIGNAL(aboutToQuit())); + connect(application, SIGNAL(focusChanged(QWidget*, QWidget*)), + SLOT(focusChangedSlot(QWidget*, QWidget*))); + } + + QString caption() + { + if (app->hasMainWindow()) + return app->mainWindow()->caption(); + return QString(""); // must not return a null QString + } + + void setCaption(const QString &newCaption) + { + if (app->hasMainWindow()) + app->mainWindow()->setCaption(newCaption); + } + + QString organizationName() + { + return app->organizationName(); + } + + QString organizationDomain() + { + return app->organizationDomain(); + } + +public slots: + Q_NOREPLY void quit() + { app->quit(); } + + void reparseConfiguration() + { app->reparseConfiguration(); } + + QString mainWindowObject() + { + if (app->hasMainWindow()) + return QString("/%1/mainwindow").arg(app->applicationName()); + return QString(); + } + + void setSessionManagement(bool enable) + { + if (enable) + app->enableSessionManagement(); + else + app->disableSessionManagement(); + } + +private slots: + void focusChangedSlot(QWidget *, QWidget *now) + { + if (now == app->mainWindow()) + emit mainWindowHasFocus(); + } + +signals: + void aboutToQuit(); + void mainWindowHasFocus(); +}; //! [0] diff --git a/doc/src/snippets/code/doc_src_qiterator.qdoc b/doc/src/snippets/code/doc_src_qiterator.cpp index 82b1bd3..82b1bd3 100644 --- a/doc/src/snippets/code/doc_src_qiterator.qdoc +++ b/doc/src/snippets/code/doc_src_qiterator.cpp diff --git a/doc/src/snippets/code/doc_src_qmake-manual.cpp b/doc/src/snippets/code/doc_src_qmake-manual.cpp new file mode 100644 index 0000000..4f60e1d --- /dev/null +++ b/doc/src/snippets/code/doc_src_qmake-manual.cpp @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +//! [104] +// Add C includes here + +#if defined __cplusplus +// Add C++ includes here +#include <stdlib> +#include <iostream> +#include <vector> +#include <QApplication> // Qt includes +#include <QPushButton> +#include <QLabel> +#include "thirdparty/include/libmain.h" +#include "my_stable_class.h" +... +#endif +//! [104] + + diff --git a/doc/src/snippets/code/doc_src_qmake-manual.qdoc b/doc/src/snippets/code/doc_src_qmake-manual.pro index a35a3d9..ee35b77 100644 --- a/doc/src/snippets/code/doc_src_qmake-manual.qdoc +++ b/doc/src/snippets/code/doc_src_qmake-manual.pro @@ -38,569 +38,569 @@ ** ****************************************************************************/ -//! [0] +#! [0] make all -//! [0] +#! [0] -//! [1] +#! [1] CONFIG += qt thread debug -//! [1] +#! [1] -//! [2] +#! [2] CONFIG += qt QT += network xml -//! [2] +#! [2] -//! [3] +#! [3] QT = network xml # This will omit the core and gui modules. -//! [3] +#! [3] -//! [4] +#! [4] QT -= gui # Only the core module is used. -//! [4] +#! [4] -//! [5] +#! [5] CONFIG += link_pkgconfig PKGCONFIG += ogg dbus-1 -//! [5] +#! [5] -//! [6] +#! [6] LIBS += -L/usr/local/lib -lmath -//! [6] +#! [6] -//! [7] +#! [7] INCLUDEPATH = c:/msdev/include d:/stl/include -//! [7] +#! [7] -//! [8] +#! [8] qmake [mode] [options] files -//! [8] +#! [8] -//! [9] +#! [9] qmake -makefile [options] files -//! [9] +#! [9] -//! [10] +#! [10] qmake -makefile -unix -o Makefile "CONFIG+=test" test.pro -//! [10] +#! [10] -//! [11] +#! [11] qmake "CONFIG+=test" test.pro -//! [11] +#! [11] -//! [12] +#! [12] qmake -project [options] files -//! [12] +#! [12] -//! [13] +#! [13] qmake -spec macx-g++ -//! [13] +#! [13] -//! [14] +#! [14] QMAKE_LFLAGS += -F/path/to/framework/directory/ -//! [14] +#! [14] -//! [15] +#! [15] LIBS += -framework TheFramework -//! [15] +#! [15] -//! [16] +#! [16] TEMPLATE = lib CONFIG += lib_bundle -//! [16] +#! [16] -//! [17] +#! [17] FRAMEWORK_HEADERS.version = Versions FRAMEWORK_HEADERS.files = path/to/header_one.h path/to/header_two.h FRAMEWORK_HEADERS.path = Headers QMAKE_BUNDLE_DATA += FRAMEWORK_HEADERS -//! [17] +#! [17] -//! [18] +#! [18] CONFIG += x86 ppc -//! [18] +#! [18] -//! [19] +#! [19] qmake -spec macx-xcode project.pro -//! [19] +#! [19] -//! [20] +#! [20] qmake -tp vc -//! [20] +#! [20] -//! [21] +#! [21] qmake -tp vc -r -//! [21] +#! [21] -//! [22] +#! [22] CONFIG -= embed_manifest_exe -//! [22] +#! [22] -//! [23] +#! [23] CONFIG -= embed_manifest_dll -//! [23] +#! [23] -//! [24] +#! [24] make all -//! [24] +#! [24] -//! [25] +#! [25] build_pass:CONFIG(debug, debug|release) { unix: TARGET = $$join(TARGET,,,_debug) else: TARGET = $$join(TARGET,,,d) } -//! [25] +#! [25] -//! [26] +#! [26] CONFIG += qt console newstuff ... newstuff { SOURCES += new.cpp HEADERS += new.h } -//! [26] +#! [26] -//! [27] +#! [27] DEFINES += USE_MY_STUFF QT_DLL -//! [27] +#! [27] -//! [28] +#! [28] myFiles.files = path\*.png DEPLOYMENT += myFiles -//! [28] +#! [28] -//! [29] +#! [29] myFiles.files = path\file1.ext1 path2\file2.ext1 path3\* myFiles.path = \some\path\on\device someother.files = C:\additional\files\* someother.path = \myFiles\path2 DEPLOYMENT += myFiles someother -//! [29] +#! [29] -//! [30] +#! [30] DESTDIR = ../../lib -//! [30] +#! [30] -//! [31] +#! [31] DISTFILES += ../program.txt -//! [31] +#! [31] -//! [32] +#! [32] FORMS = mydialog.ui \ mywidget.ui \ myconfig.ui -//! [32] +#! [32] -//! [33] +#! [33] FORMS3 = my_uic3_dialog.ui \ my_uic3_widget.ui \ my_uic3_config.ui -//! [33] +#! [33] -//! [34] +#! [34] HEADERS = myclass.h \ login.h \ mainwindow.h -//! [34] +#! [34] -//! [35] +#! [35] INCLUDEPATH = c:/msdev/include d:/stl/include -//! [35] +#! [35] -//! [36] +#! [36] target.path += $$[QT_INSTALL_PLUGINS]/imageformats INSTALLS += target -//! [36] +#! [36] -//! [37] +#! [37] LEXSOURCES = lexer.l -//! [37] +#! [37] -//! [38] +#! [38] unix:LIBS += -L/usr/local/lib -lmath win32:LIBS += c:/mylibs/math.lib -//! [38] +#! [38] -//! [39] +#! [39] CONFIG += no_lflags_merge -//! [39] +#! [39] -//! [40] +#! [40] unix:MOC_DIR = ../myproject/tmp win32:MOC_DIR = c:/myproject/tmp -//! [40] +#! [40] -//! [41] +#! [41] unix:OBJECTS_DIR = ../myproject/tmp win32:OBJECTS_DIR = c:/myproject/tmp -//! [41] +#! [41] -//! [42] +#! [42] app { # Conditional code for 'app' template here } -//! [42] +#! [42] -//! [43] +#! [43] FRAMEWORK_HEADERS.version = Versions FRAMEWORK_HEADERS.files = path/to/header_one.h path/to/header_two.h FRAMEWORK_HEADERS.path = Headers QMAKE_BUNDLE_DATA += FRAMEWORK_HEADERS -//! [43] +#! [43] -//! [44] +#! [44] QMAKE_BUNDLE_EXTENSION = .myframework -//! [44] +#! [44] -//! [45] +#! [45] QMAKE_RESOURCE_FLAGS += -threshold 0 -compress 9 -//! [45] +#! [45] -//! [46] +#! [46] QMAKE_UIC = uic -L /path/to/plugin -//! [46] +#! [46] -//! [47] +#! [47] QT -= gui # Only the core module is used. -//! [47] +#! [47] -//! [48] +#! [48] unix:RCC_DIR = ../myproject/resources win32:RCC_DIR = c:/myproject/resources -//! [48] +#! [48] -//! [49] +#! [49] SOURCES = myclass.cpp \ login.cpp \ mainwindow.cpp -//! [49] +#! [49] -//! [50] +#! [50] SUBDIRS = kernel \ tools -//! [50] +#! [50] -//! [51] +#! [51] CONFIG += ordered -//! [51] +#! [51] -//! [52] +#! [52] TEMPLATE = app TARGET = myapp SOURCES = main.cpp -//! [52] +#! [52] -//! [53] +#! [53] TEMPLATE = lib SOURCES = main.cpp TARGET = mylib -//! [53] +#! [53] -//! [54] +#! [54] unix:UI_DIR = ../myproject/ui win32:UI_DIR = c:/myproject/ui -//! [54] +#! [54] -//! [55] +#! [55] unix:UI_HEADERS_DIR = ../myproject/ui/include win32:UI_HEADERS_DIR = c:/myproject/ui/include -//! [55] +#! [55] -//! [56] +#! [56] unix:UI_SOURCES_DIR = ../myproject/ui/src win32:UI_SOURCES_DIR = c:/myproject/ui/src -//! [56] +#! [56] -//! [57] +#! [57] VERSION = 1.2.3 -//! [57] +#! [57] -//! [58] +#! [58] YACCSOURCES = moc.y -//! [58] +#! [58] -//! [59] +#! [59] FILE = /etc/passwd FILENAME = $$basename(FILE) #passwd -//! [59] +#! [59] -//! [60] +#! [60] CONFIG = debug CONFIG += release CONFIG(release, debug|release):message(Release build!) #will print CONFIG(debug, debug|release):message(Debug build!) #no print -//! [60] +#! [60] -//! [61] +#! [61] contains( drivers, network ) { # drivers contains 'network' message( "Configuring for network build..." ) HEADERS += network.h SOURCES += network.cpp } -//! [61] +#! [61] -//! [62] +#! [62] error(An error has occurred in the configuration process.) -//! [62] +#! [62] -//! [63] +#! [63] exists( $(QTDIR)/lib/libqt-mt* ) { message( "Configuring for multi-threaded Qt..." ) CONFIG += thread } -//! [63] +#! [63] -//! [64] +#! [64] MY_VAR = one two three four MY_VAR2 = $$join(MY_VAR, " -L", -L) -Lfive MY_VAR3 = $$member(MY_VAR, 2) $$find(MY_VAR, t.*) -//! [64] +#! [64] -//! [65] +#! [65] LIST = 1 2 3 for(a, LIST):exists(file.$${a}):message(I see a file.$${a}!) -//! [65] +#! [65] -//! [66] +#! [66] include( shared.pri ) OPTIONS = standard custom !include( options.pri ) { message( "No custom build options specified" ) OPTIONS -= custom } -//! [66] +#! [66] -//! [67] +#! [67] isEmpty( CONFIG ) { CONFIG += qt warn_on debug } -//! [67] +#! [67] -//! [68] +#! [68] message( "This is a message" ) -//! [68] +#! [68] -//! [69] +#! [69] !build_pass:message( "This is a message" ) -//! [69] +#! [69] -//! [70] +#! [70] This is a test. -//! [70] +#! [70] -//! [71] +#! [71] system(ls /bin):HAS_BIN=FALSE -//! [71] +#! [71] -//! [72] +#! [72] UNAME = $$system(uname -s) contains( UNAME, [lL]inux ):message( This looks like Linux ($$UNAME) to me ) -//! [72] +#! [72] -//! [73] +#! [73] ARGS = 1 2 3 2 5 1 ARGS = $$unique(ARGS) #1 2 3 5 -//! [73] +#! [73] -//! [74] +#! [74] qmake -set VARIABLE VALUE -//! [74] +#! [74] -//! [75] +#! [75] qmake -query VARIABLE qmake -query #queries all current VARIABLE/VALUE pairs.. -//! [75] +#! [75] -//! [76] +#! [76] qmake -query "1.06a/VARIABLE" -//! [76] +#! [76] -//! [77] +#! [77] qmake -query "QT_INSTALL_PREFIX" -//! [77] +#! [77] -//! [78] +#! [78] QMAKE_VERS = $$[QMAKE_VERSION] -//! [78] +#! [78] -//! [79] +#! [79] documentation.path = /usr/local/program/doc documentation.files = docs/* -//! [79] +#! [79] -//! [80] +#! [80] INSTALLS += documentation -//! [80] +#! [80] -//! [81] +#! [81] unix:documentation.extra = create_docs; mv master.doc toc.doc -//! [81] +#! [81] -//! [82] +#! [82] target.path = /usr/local/myprogram INSTALLS += target -//! [82] +#! [82] -//! [83] +#! [83] CONFIG += create_prl -//! [83] +#! [83] -//! [84] +#! [84] CONFIG += link_prl -//! [84] +#! [84] -//! [85] +#! [85] QMAKE_EXT_MOC = .mymoc -//! [85] +#! [85] -//! [86] +#! [86] mytarget.target = .buildfile mytarget.commands = touch $$mytarget.target mytarget.depends = mytarget2 mytarget2.commands = @echo Building $$mytarget.target -//! [86] +#! [86] -//! [87] +#! [87] QMAKE_EXTRA_TARGETS += mytarget mytarget2 -//! [87] +#! [87] -//! [88] +#! [88] new_moc.output = moc_${QMAKE_FILE_BASE}.cpp new_moc.commands = moc ${QMAKE_FILE_NAME} -o ${QMAKE_FILE_OUT} new_moc.depend_command = g++ -E -M ${QMAKE_FILE_NAME} | sed "s,^.*: ,," new_moc.input = NEW_HEADERS QMAKE_EXTRA_COMPILERS += new_moc -//! [88] +#! [88] -//! [89] +#! [89] TARGET = myapp -//! [89] +#! [89] -//! [90] +#! [90] DEFINES += QT_DLL -//! [90] +#! [90] -//! [91] +#! [91] DEFINES -= QT_DLL -//! [91] +#! [91] -//! [92] +#! [92] DEFINES *= QT_DLL -//! [92] +#! [92] -//! [93] +#! [93] DEFINES ~= s/QT_[DT].+/QT -//! [93] +#! [93] -//! [94] +#! [94] EVERYTHING = $$SOURCES $$HEADERS message("The project contains the following files:") message($$EVERYTHING) -//! [94] +#! [94] -//! [95] +#! [95] win32:DEFINES += QT_DLL -//! [95] +#! [95] -//! [96] +#! [96] win32:xml { message(Building for Windows) SOURCES += xmlhandler_win.cpp @@ -609,146 +609,128 @@ win32:xml { } else { message("Unknown configuration") } -//! [96] +#! [96] -//! [97] +#! [97] MY_VARIABLE = value -//! [97] +#! [97] -//! [98] +#! [98] MY_DEFINES = $$DEFINES -//! [98] +#! [98] -//! [99] +#! [99] MY_DEFINES = $${DEFINES} -//! [99] +#! [99] -//! [100] +#! [100] TARGET = myproject_$${TEMPLATE} -//! [100] +#! [100] -//! [101] +#! [101] target.path = $$[QT_INSTALL_PLUGINS]/designer INSTALLS += target -//! [101] +#! [101] -//! [102] +#! [102] defineReplace(functionName){ #function code } -//! [102] +#! [102] -//! [103] +#! [103] CONFIG += myfeatures -//! [103] - - -//! [104] -// Add C includes here - -#if defined __cplusplus -// Add C++ includes here -#include <stdlib> -#include <iostream> -#include <vector> -#include <QApplication> // Qt includes -#include <QPushButton> -#include <QLabel> -#include "thirdparty/include/libmain.h" -#include "my_stable_class.h" -... -#endif -//! [104] +#! [103] -//! [105] +#! [105] PRECOMPILED_HEADER = stable.h -//! [105] +#! [105] -//! [106] +#! [106] precompile_header:!isEmpty(PRECOMPILED_HEADER) { DEFINES += USING_PCH } -//! [106] +#! [106] -//! [107] +#! [107] PRECOMPILED_HEADER = window.h SOURCES = window.cpp -//! [107] +#! [107] -//! [108] +#! [108] SOURCES += hello.cpp -//! [108] +#! [108] -//! [109] +#! [109] SOURCES += hello.cpp SOURCES += main.cpp -//! [109] +#! [109] -//! [110] +#! [110] SOURCES = hello.cpp \ main.cpp -//! [110] +#! [110] -//! [111] +#! [111] HEADERS += hello.h SOURCES += hello.cpp SOURCES += main.cpp -//! [111] +#! [111] -//! [112] +#! [112] TARGET = helloworld -//! [112] +#! [112] -//! [113] +#! [113] CONFIG += qt HEADERS += hello.h SOURCES += hello.cpp SOURCES += main.cpp -//! [113] +#! [113] -//! [114] +#! [114] qmake -o Makefile hello.pro -//! [114] +#! [114] -//! [115] +#! [115] qmake -tp vc hello.pro -//! [115] +#! [115] -//! [116] +#! [116] CONFIG += qt debug HEADERS += hello.h SOURCES += hello.cpp SOURCES += main.cpp -//! [116] +#! [116] -//! [117] +#! [117] win32 { SOURCES += hellowin.cpp } -//! [117] +#! [117] -//! [118] +#! [118] CONFIG += qt debug HEADERS += hello.h SOURCES += hello.cpp @@ -759,17 +741,17 @@ win32 { unix { SOURCES += hellounix.cpp } -//! [118] +#! [118] -//! [119] +#! [119] !exists( main.cpp ) { error( "No main.cpp file found" ) } -//! [119] +#! [119] -//! [120] +#! [120] CONFIG += qt debug HEADERS += hello.h SOURCES += hello.cpp @@ -783,19 +765,19 @@ unix { !exists( main.cpp ) { error( "No main.cpp file found" ) } -//! [120] +#! [120] -//! [121] +#! [121] win32 { debug { CONFIG += console } } -//! [121] +#! [121] -//! [122] +#! [122] CONFIG += qt debug HEADERS += hello.h SOURCES += hello.cpp @@ -812,10 +794,10 @@ unix { win32:debug { CONFIG += console } -//! [122] +#! [122] -//! [123] +#! [123] TEMPLATE = app DESTDIR = c:/helloapp HEADERS += hello.h @@ -823,32 +805,32 @@ SOURCES += hello.cpp SOURCES += main.cpp DEFINES += QT_DLL CONFIG += qt warn_on release -//! [123] +#! [123] -//! [124] +#! [124] make all -//! [124] +#! [124] -//! [125] +#! [125] make -//! [125] +#! [125] -//! [126] +#! [126] make install -//! [126] +#! [126] -//! [127] +#! [127] CONFIG(debug, debug|release) { mac: TARGET = $$join(TARGET,,,_debug) win32: TARGET = $$join(TARGET,,d) } -//! [127] +#! [127] -//! [128] +#! [128] customplugin.files = customimageplugin.dll customplugin.files += c:\myplugins\othercustomimageplugin.dll customplugin.path = imageformats @@ -857,50 +839,50 @@ dynamiclibrary.path = \sys\bin globalplugin.files = someglobalimageplugin.dll globalplugin.path = \resource\qt\plugins\imageformats DEPLOYMENT += customplugin dynamiclibrary globalplugin -//! [128] +#! [128] -//! [129] +#! [129] TARGET.EPOCALLOWDLLDATA = 1 -//! [129] +#! [129] -//! [130] +#! [130] TARGET.EPOCHEAPSIZE = 10000 10000000 TARGET.EPOCSTACKSIZE = 0x8000 -//! [130] +#! [130] -//! [131] +#! [131] QMAKE_CXXFLAGS.CW += -O2 QMAKE_CXXFLAGS.ARMCC += -O0 -//! [131] +#! [131] -//! [132] +#! [132] TARGET.UID2 = 0x00000001 TARGET.UID3 = 0x00000002 TARGET.SID = 0x00000003 TARGET.VID = 0x00000004 -//! [132] +#! [132] -//! [133] +#! [133] TARGET.CAPABILITY += AllFiles -//! [133] +#! [133] -//! [134] +#! [134] TARGET.CAPABILITY = ALL -TCB -DRM -AllFiles -//! [134] +#! [134] -//! [135] +#! [135] TARGET.EPOCHEAPSIZE = 10000 10000000 -//! [135] +#! [135] -//! [136] +#! [136] TARGET.EPOCSTACKSIZE = 0x8000 -//! [136] +#! [136] -//! [137] +#! [137] MMP_RULES += "DEFFILE hello.def" -//! [137] +#! [137] -//! [138] +#! [138] myBlock = \ "START RESOURCE foo.rss" \ "TARGET bar" \ @@ -911,37 +893,37 @@ myBlock = \ "END" MMP_RULES += myBlock -//! [138] +#! [138] -//! [139] +#! [139] myIfdefBlock = \ "$${LITERAL_HASH}ifdef WINSCW" \ "DEFFILE hello_winscw.def" \ "$${LITERAL_HASH}endif" MMP_RULES += myIfdefBlock -//! [139] +#! [139] -//! [140] +#! [140] somelib.files = somelib.dll somelib.path = \sys\bin somelib.pkg_prerules = "(0x12345678), 2, 2, 0, {\"Some Package\"}" \ "(0x87654321), 1, *, * ~ 2, 2, 0, {\"Some Other Package\"}" justdep.pkg_prerules = "(0xAAAABBBB), 0, 2, 0, {\"My Framework\"}" DEPLOYMENT += somelib justdep -//! [140] +#! [140] -//! [141] +#! [141] default_deployment.pkg_prerules -= pkg_platform_dependencies my_deployment.pkg_prerules = "[0x11223344],0,0,0,{\"SomeSpecificDeviceID\"}" DEPLOYMENT += my_deployment -//! [141] +#! [141] -//! [142] +#! [142] DEPLOYMENT_PLUGIN += qjpeg -//! [142] +#! [142] -//! [143] +#! [143] myextension = \ "start extension myextension" \ "$${LITERAL_HASH}if defined(WINSCW)" \ @@ -950,28 +932,28 @@ myextension = \ "option MYOPTION bar" \ "end" BLD_INF_RULES.prj_extensions += myextension -//! [143] +#! [143] -//! [144] +#! [144] RSS_RULES += "hidden = KAppIsHidden;" -//! [144] +#! [144] -//! [145] +#! [145] myrssrules = \ "hidden = KAppIsHidden;" \ "launch = KAppLaunchInBackground;" \ RSS_RULES += myrssrules -//! [145] +#! [145] -//! [146] +#! [146] DEPLOYMENT.installer_header = 0x12345678 -//! [146] +#! [146] -//! [147] +#! [147] DEPLOYMENT.installer_header = "$${LITERAL_HASH}{\"My Application Installer\"},(0x12345678),1,0,0" -//! [147] +#! [147] -//! [148] +#! [148] # Set conditional libraries LIB.MARM = "LIBRARY myarm.lib" LIB.WINSCW = "LIBRARY mywinscw.lib" @@ -982,62 +964,62 @@ MYCONDITIONS = MARM WINSCW MYVARIABLES = LIB addMMPRules(MYCONDITIONS, MYVARIABLES) -//! [148] +#! [148] -//! [149] +#! [149] SUBDIRS += my_executable my_library my_executable.subdir = app my_executable.depends = my_library my_library.subdir = lib -//! [149] +#! [149] -//! [150] +#! [150] symbian { SUBDIRS += emulator_dll emulator_dll.condition = WINSCW } -//! [150] +#! [150] -//! [151] +#! [151] RSS_RULES.service_list += "uid = 0x12345678; datatype_list = \{\}; opaque_data = r_my_icon;" RSS_RULES.footer +="RESOURCE CAPTION_AND_ICON_INFO r_my_icon \{ icon_file =\"$$PWD/my_icon.svg\"; \}" -//! [151] +#! [151] -//! [152] +#! [152] my_exports = \ "foo.h /epoc32/include/mylib/foo.h" \ "bar.h /epoc32/include/mylib/bar.h" BLD_INF_RULES.prj_exports += my_exports -//! [152] +#! [152] -//! [153] +#! [153] my_note.pkg_postrules.installer = "\"myinstallnote.txt\" - \"\", FILETEXT, TEXTCONTINUE" DEPLOYMENT += my_note -//! [153] +#! [153] -//! [154] +#! [154] DEPLOYMENT -= default_bin_deployment default_resource_deployment default_reg_deployment -//! [154] +#! [154] -//! [155] +#! [155] default_bin_deployment.flags += FILERUN RUNINSTALL dep_note.files = install_note.txt dep_note.flags = FILETEXT TEXTEXIT DEPLOYMENT += dep_note -//! [155] +#! [155] -//! [156] +#! [156] DEPLOYMENT.display_name = My Qt App -//! [156] +#! [156] -//! [157] +#! [157] packagesExist(sqlite3 QtNetwork QtDeclarative) { DEFINES += USE_FANCY_UI } -//! [157] +#! [157] -//! [158] +#! [158] #ifdef USE_FANCY_UI // Use the fancy UI, as we have extra packages available #endif -//! [158] +#! [158] diff --git a/doc/src/snippets/code/doc_src_qnamespace.cpp b/doc/src/snippets/code/doc_src_qnamespace.cpp new file mode 100644 index 0000000..c512862 --- /dev/null +++ b/doc/src/snippets/code/doc_src_qnamespace.cpp @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +//! [1] +enum CustomEventPriority +{ + // An important event + ImportantEventPriority = Qt::HighEventPriority, + + // A more important event + MoreImportantEventPriority = ImportantEventPriority + 1, + + // A critical event + CriticalEventPriority = 100 * MoreImportantEventPriority, + + // Not that important + StatusEventPriority = Qt::LowEventPriority, + + // These are less important than Status events + IdleProcessingDoneEventPriority = StatusEventPriority - 1 +}; +//! [1] diff --git a/doc/src/snippets/code/doc_src_qnamespace.qdoc b/doc/src/snippets/code/doc_src_qnamespace.qdoc index a1bd0b7..6b5ce6a 100644 --- a/doc/src/snippets/code/doc_src_qnamespace.qdoc +++ b/doc/src/snippets/code/doc_src_qnamespace.qdoc @@ -41,24 +41,3 @@ //! [0] QObject::connect: Cannot queue arguments of type 'MyType' //! [0] - - -//! [1] -enum CustomEventPriority -{ - // An important event - ImportantEventPriority = Qt::HighEventPriority, - - // A more important event - MoreImportantEventPriority = ImportantEventPriority + 1, - - // A critical event - CriticalEventPriority = 100 * MoreImportantEventPriority, - - // Not that important - StatusEventPriority = Qt::LowEventPriority, - - // These are less important than Status events - IdleProcessingDoneEventPriority = StatusEventPriority - 1 -}; -//! [1] diff --git a/doc/src/snippets/code/doc_src_qpair.qdoc b/doc/src/snippets/code/doc_src_qpair.cpp index a9a061e..a9a061e 100644 --- a/doc/src/snippets/code/doc_src_qpair.qdoc +++ b/doc/src/snippets/code/doc_src_qpair.cpp diff --git a/doc/src/snippets/code/doc_src_qplugin.qdoc b/doc/src/snippets/code/doc_src_qplugin.cpp index fdacc08..fdacc08 100644 --- a/doc/src/snippets/code/doc_src_qplugin.qdoc +++ b/doc/src/snippets/code/doc_src_qplugin.cpp diff --git a/doc/src/snippets/code/doc_src_qplugin.pro b/doc/src/snippets/code/doc_src_qplugin.pro new file mode 100644 index 0000000..f3444e2 --- /dev/null +++ b/doc/src/snippets/code/doc_src_qplugin.pro @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +#! [3] +TEMPLATE = app +QTPLUGIN += qjpeg qgif qmng # image formats +#! [3] diff --git a/doc/src/snippets/code/doc_src_qset.qdoc b/doc/src/snippets/code/doc_src_qset.cpp index 4a4953d..4a4953d 100644 --- a/doc/src/snippets/code/doc_src_qset.qdoc +++ b/doc/src/snippets/code/doc_src_qset.cpp diff --git a/doc/src/snippets/code/doc_src_qsignalspy.qdoc b/doc/src/snippets/code/doc_src_qsignalspy.cpp index 12462e2..12462e2 100644 --- a/doc/src/snippets/code/doc_src_qsignalspy.qdoc +++ b/doc/src/snippets/code/doc_src_qsignalspy.cpp diff --git a/doc/src/snippets/code/doc_src_qt3support.qdoc b/doc/src/snippets/code/doc_src_qt3support.cpp index 9e0f682..196efd4 100644 --- a/doc/src/snippets/code/doc_src_qt3support.qdoc +++ b/doc/src/snippets/code/doc_src_qt3support.cpp @@ -41,8 +41,3 @@ //! [0] #include <Qt3Support> //! [0] - - -//! [1] -QT += qt3support -//! [1] diff --git a/doc/src/snippets/code/doc_src_qt3support.pro b/doc/src/snippets/code/doc_src_qt3support.pro new file mode 100644 index 0000000..20fcc14 --- /dev/null +++ b/doc/src/snippets/code/doc_src_qt3support.pro @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +#! [1] +QT += qt3support +#! [1] diff --git a/doc/src/snippets/code/doc_src_qt3to4.cpp b/doc/src/snippets/code/doc_src_qt3to4.cpp new file mode 100644 index 0000000..d8eb5b4 --- /dev/null +++ b/doc/src/snippets/code/doc_src_qt3to4.cpp @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +//! [2] +using namespace Qt; +//! [2] diff --git a/doc/src/snippets/code/doc_src_qt4-accessibility.qdoc b/doc/src/snippets/code/doc_src_qt4-accessibility.cpp index efbbc5a..efbbc5a 100644 --- a/doc/src/snippets/code/doc_src_qt4-accessibility.qdoc +++ b/doc/src/snippets/code/doc_src_qt4-accessibility.cpp diff --git a/doc/src/snippets/code/doc_src_qt4-arthur.qdoc b/doc/src/snippets/code/doc_src_qt4-arthur.cpp index 6268309..6268309 100644 --- a/doc/src/snippets/code/doc_src_qt4-arthur.qdoc +++ b/doc/src/snippets/code/doc_src_qt4-arthur.cpp diff --git a/doc/src/snippets/code/doc_src_qt4-intro.qdoc b/doc/src/snippets/code/doc_src_qt4-intro.cpp index 45da7d0..76ed4a5 100644 --- a/doc/src/snippets/code/doc_src_qt4-intro.qdoc +++ b/doc/src/snippets/code/doc_src_qt4-intro.cpp @@ -38,21 +38,6 @@ ** ****************************************************************************/ -//! [0] -QT -= gui -//! [0] - - -//! [1] -QT += network opengl sql qt3support -//! [1] - - -//! [2] -CONFIG += uic3 -//! [2] - - //! [3] #include <QClassName> //! [3] @@ -119,23 +104,3 @@ safeLabel->setText("Hello world!"); delete label; // safeLabel is now 0, whereas label is a dangling pointer //! [12] - - -//! [13] -QT += qt3support -//! [13] - - -//! [14] -DEFINES += QT3_SUPPORT -//! [14] - - -//! [15] -DEFINES += QT3_SUPPORT_WARNINGS -//! [15] - - -//! [16] -DEFINES += QT3_SUPPORT -//! [16] diff --git a/doc/src/snippets/code/doc_src_qt4-intro.pro b/doc/src/snippets/code/doc_src_qt4-intro.pro new file mode 100644 index 0000000..40853b3 --- /dev/null +++ b/doc/src/snippets/code/doc_src_qt4-intro.pro @@ -0,0 +1,73 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +#! [0] +QT -= gui +#! [0] + + +#! [1] +QT += network opengl sql qt3support +#! [1] + + +#! [2] +CONFIG += uic3 +#! [2] + + +#! [13] +QT += qt3support +#! [13] + + +#! [14] +DEFINES += QT3_SUPPORT +#! [14] + + +#! [15] +DEFINES += QT3_SUPPORT_WARNINGS +#! [15] + + +#! [16] +DEFINES += QT3_SUPPORT +#! [16] diff --git a/doc/src/snippets/code/doc_src_qt4-mainwindow.qdoc b/doc/src/snippets/code/doc_src_qt4-mainwindow.cpp index d0c758e..d0c758e 100644 --- a/doc/src/snippets/code/doc_src_qt4-mainwindow.qdoc +++ b/doc/src/snippets/code/doc_src_qt4-mainwindow.cpp diff --git a/doc/src/snippets/code/doc_src_qt4-sql.qdoc b/doc/src/snippets/code/doc_src_qt4-sql.cpp index cbcfb2d..cbcfb2d 100644 --- a/doc/src/snippets/code/doc_src_qt4-sql.qdoc +++ b/doc/src/snippets/code/doc_src_qt4-sql.cpp diff --git a/doc/src/snippets/code/doc_src_qt4-styles.qdoc b/doc/src/snippets/code/doc_src_qt4-styles.cpp index effe3cd..effe3cd 100644 --- a/doc/src/snippets/code/doc_src_qt4-styles.qdoc +++ b/doc/src/snippets/code/doc_src_qt4-styles.cpp diff --git a/doc/src/snippets/code/doc_src_qt4-tulip.qdoc b/doc/src/snippets/code/doc_src_qt4-tulip.cpp index 83b1210..83b1210 100644 --- a/doc/src/snippets/code/doc_src_qt4-tulip.qdoc +++ b/doc/src/snippets/code/doc_src_qt4-tulip.cpp diff --git a/doc/src/snippets/code/doc_src_qtcore.qdoc b/doc/src/snippets/code/doc_src_qtcore.cpp index 35916ea..35916ea 100644 --- a/doc/src/snippets/code/doc_src_qtcore.qdoc +++ b/doc/src/snippets/code/doc_src_qtcore.cpp diff --git a/doc/src/snippets/code/doc_src_qtdbus.qdoc b/doc/src/snippets/code/doc_src_qtdbus.cpp index 20ff513..2143b5b 100644 --- a/doc/src/snippets/code/doc_src_qtdbus.qdoc +++ b/doc/src/snippets/code/doc_src_qtdbus.cpp @@ -41,8 +41,3 @@ //! [0] #include <QtDBus> //! [0] - - -//! [1] -QT += dbus -//! [1] diff --git a/doc/src/snippets/code/doc_src_qtdbus.pro b/doc/src/snippets/code/doc_src_qtdbus.pro new file mode 100644 index 0000000..6607d7d --- /dev/null +++ b/doc/src/snippets/code/doc_src_qtdbus.pro @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +#! [1] +QT += dbus +#! [1] diff --git a/doc/src/snippets/code/doc_src_qtdesigner.qdoc b/doc/src/snippets/code/doc_src_qtdesigner.cpp index a37b77f..562002e 100644 --- a/doc/src/snippets/code/doc_src_qtdesigner.qdoc +++ b/doc/src/snippets/code/doc_src_qtdesigner.cpp @@ -43,11 +43,6 @@ //! [0] -//! [1] -CONFIG += designer -//! [1] - - //! [2] QDesignerMemberSheetExtension *memberSheet = 0; QExtensionManager manager = formEditor->extensionManager(); diff --git a/doc/src/snippets/code/doc_src_qtdesigner.pro b/doc/src/snippets/code/doc_src_qtdesigner.pro new file mode 100644 index 0000000..dc962ef --- /dev/null +++ b/doc/src/snippets/code/doc_src_qtdesigner.pro @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +#! [1] +CONFIG += designer +#! [1] diff --git a/doc/src/snippets/code/doc_src_qtestevent.qdoc b/doc/src/snippets/code/doc_src_qtestevent.cpp index fd1c819..fd1c819 100644 --- a/doc/src/snippets/code/doc_src_qtestevent.qdoc +++ b/doc/src/snippets/code/doc_src_qtestevent.cpp diff --git a/doc/src/snippets/code/doc_src_qtestlib.cpp b/doc/src/snippets/code/doc_src_qtestlib.cpp new file mode 100644 index 0000000..bd98807 --- /dev/null +++ b/doc/src/snippets/code/doc_src_qtestlib.cpp @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +//! [0] +class MyFirstTest: public QObject +{ + Q_OBJECT +private slots: + void initTestCase() + { qDebug("called before everything else"); } + void myFirstTest() + { QVERIFY(1 == 1); } + void mySecondTest() + { QVERIFY(1 != 2); } + void cleanupTestCase() + { qDebug("called after myFirstTest and mySecondTest"); } +}; +//! [0] + + +//! [8] +void TestQString::toUpper() +{ + QString str = "Hello"; + QVERIFY(str.toUpper() == "HELLO"); +} +//! [8] + + +//! [11] +QCOMPARE(QString("hello").toUpper(), QString("HELLO")); +QCOMPARE(QString("Hello").toUpper(), QString("HELLO")); +QCOMPARE(QString("HellO").toUpper(), QString("HELLO")); +QCOMPARE(QString("HELLO").toUpper(), QString("HELLO")); +//! [11] + +//! [12] +class MyFirstBenchmark: public QObject +{ + Q_OBJECT +private slots: + void myFirstBenchmark() + { + QString string1; + QString string2; + QBENCHMARK { + string1.localeAwareCompare(string2); + } + } +}; +//! [12] diff --git a/doc/src/snippets/code/doc_src_qtestlib.pro b/doc/src/snippets/code/doc_src_qtestlib.pro new file mode 100644 index 0000000..a8fc56a --- /dev/null +++ b/doc/src/snippets/code/doc_src_qtestlib.pro @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +#! [1] +QT += testlib +#! [1] diff --git a/doc/src/snippets/code/doc_src_qtestlib.qdoc b/doc/src/snippets/code/doc_src_qtestlib.qdoc index 80b7d92..92d528e 100644 --- a/doc/src/snippets/code/doc_src_qtestlib.qdoc +++ b/doc/src/snippets/code/doc_src_qtestlib.qdoc @@ -38,28 +38,6 @@ ** ****************************************************************************/ -//! [0] -class MyFirstTest: public QObject -{ - Q_OBJECT -private slots: - void initTestCase() - { qDebug("called before everything else"); } - void myFirstTest() - { QVERIFY(1 == 1); } - void mySecondTest() - { QVERIFY(1 != 2); } - void cleanupTestCase() - { qDebug("called after myFirstTest and mySecondTest"); } -}; -//! [0] - - -//! [1] -QT += testlib -//! [1] - - //! [2] testname [options] [testfunctions[:testdata]]... //! [2] @@ -91,15 +69,6 @@ set LIB=C:\Program Files\Windows CE Tools\wce500\Windows Mobile 5.0 Pocket PC SD //! [7] -//! [8] -void TestQString::toUpper() -{ - QString str = "Hello"; - QVERIFY(str.toUpper() == "HELLO"); -} -//! [8] - - //! [9] /myTestDirectory$ qmake -project "CONFIG += qtestlib" /myTestDirectory$ qmake @@ -116,27 +85,3 @@ PASS : TestQString::cleanupTestCase() Totals: 3 passed, 0 failed, 0 skipped ********* Finished testing of TestQString ********* //! [10] - - -//! [11] -QCOMPARE(QString("hello").toUpper(), QString("HELLO")); -QCOMPARE(QString("Hello").toUpper(), QString("HELLO")); -QCOMPARE(QString("HellO").toUpper(), QString("HELLO")); -QCOMPARE(QString("HELLO").toUpper(), QString("HELLO")); -//! [11] - -//! [12] -class MyFirstBenchmark: public QObject -{ - Q_OBJECT -private slots: - void myFirstBenchmark() - { - QString string1; - QString string2; - QBENCHMARK { - string1.localeAwareCompare(string2); - } - } -}; -//! [12] diff --git a/doc/src/snippets/code/doc_src_qtgui.qdoc b/doc/src/snippets/code/doc_src_qtgui.pro index 370529a..dd3405c 100644 --- a/doc/src/snippets/code/doc_src_qtgui.qdoc +++ b/doc/src/snippets/code/doc_src_qtgui.pro @@ -38,6 +38,6 @@ ** ****************************************************************************/ -//! [0] +#! [0] #include <QtGui> -//! [0] +#! [0] diff --git a/doc/src/snippets/code/doc_src_qthelp.cpp b/doc/src/snippets/code/doc_src_qthelp.cpp new file mode 100644 index 0000000..2825738 --- /dev/null +++ b/doc/src/snippets/code/doc_src_qthelp.cpp @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +//! [0] +#include <QtHelp> +//! [0] + +//! [6] +QHelpEngineCore helpEngine("mycollection.qhc"); +... + +// get all file references for the identifier +QMap<QString, QUrl> links = + helpEngine.linksForIdentifier(QLatin1String("MyDialog::ChangeButton")); + +// If help is available for this keyword, get the help data +// of the first file reference. +if (links.count()) { + QByteArray helpData = helpEngine->fileData(links.constBegin().value()); + // show the documentation to the user + if (!helpData.isEmpty()) + displayHelp(helpData); +} +//! [6] + + diff --git a/doc/src/snippets/code/doc_src_qthelp.qdoc b/doc/src/snippets/code/doc_src_qthelp.qdoc index 4ad2100..ff25d19 100644 --- a/doc/src/snippets/code/doc_src_qthelp.qdoc +++ b/doc/src/snippets/code/doc_src_qthelp.qdoc @@ -38,11 +38,6 @@ ** ****************************************************************************/ -//! [0] -#include <QtHelp> -//! [0] - - //! [1] CONFIG += help //! [1] @@ -87,25 +82,6 @@ qcollectiongenerator mycollection.qhcp -o mycollection.qhc //! [5] -//! [6] -QHelpEngineCore helpEngine("mycollection.qhc"); -... - -// get all file references for the identifier -QMap<QString, QUrl> links = - helpEngine.linksForIdentifier(QLatin1String("MyDialog::ChangeButton")); - -// If help is available for this keyword, get the help data -// of the first file reference. -if (links.count()) { - QByteArray helpData = helpEngine->fileData(links.constBegin().value()); - // show the documentation to the user - if (!helpData.isEmpty()) - displayHelp(helpData); -} -//! [6] - - //! [7] <?xml version="1.0" encoding="UTF-8"?> <QtHelpProject version="1.0"> diff --git a/doc/src/snippets/code/doc_src_qtmultimedia.qdoc b/doc/src/snippets/code/doc_src_qtmultimedia.cpp index 76fb9cd..3f25c11 100644 --- a/doc/src/snippets/code/doc_src_qtmultimedia.qdoc +++ b/doc/src/snippets/code/doc_src_qtmultimedia.cpp @@ -38,11 +38,6 @@ ** ****************************************************************************/ -//! [0] -QT += multimedia -//! [0] - - //! [1] #include <QtMultimedia> //! [1] diff --git a/doc/src/snippets/code/doc_src_qtmultimedia.pro b/doc/src/snippets/code/doc_src_qtmultimedia.pro new file mode 100644 index 0000000..b23c994 --- /dev/null +++ b/doc/src/snippets/code/doc_src_qtmultimedia.pro @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +#! [0] +QT += multimedia +#! [0] diff --git a/doc/src/snippets/code/doc_src_qtnetwork.qdoc b/doc/src/snippets/code/doc_src_qtnetwork.cpp index 42d1808..7100f1a 100644 --- a/doc/src/snippets/code/doc_src_qtnetwork.qdoc +++ b/doc/src/snippets/code/doc_src_qtnetwork.cpp @@ -38,11 +38,6 @@ ** ****************************************************************************/ -//! [0] -QT += network -//! [0] - - //! [1] #include <QtNetwork> //! [1] diff --git a/doc/src/snippets/code/doc_src_qtnetwork.pro b/doc/src/snippets/code/doc_src_qtnetwork.pro new file mode 100644 index 0000000..f6c3a5a --- /dev/null +++ b/doc/src/snippets/code/doc_src_qtnetwork.pro @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +#! [0] +QT += network +#! [0] diff --git a/doc/src/snippets/code/doc_src_qtopengl.qdoc b/doc/src/snippets/code/doc_src_qtopengl.cpp index 555d571..088b31b 100644 --- a/doc/src/snippets/code/doc_src_qtopengl.qdoc +++ b/doc/src/snippets/code/doc_src_qtopengl.cpp @@ -41,8 +41,3 @@ //! [0] #include <QtOpenGL> //! [0] - - -//! [1] -QT += opengl -//! [1] diff --git a/doc/src/snippets/code/doc_src_qtopengl.pro b/doc/src/snippets/code/doc_src_qtopengl.pro new file mode 100644 index 0000000..97fbf28 --- /dev/null +++ b/doc/src/snippets/code/doc_src_qtopengl.pro @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +#! [1] +QT += opengl +#! [1] diff --git a/doc/src/snippets/code/doc_src_qtscript.cpp b/doc/src/snippets/code/doc_src_qtscript.cpp new file mode 100644 index 0000000..de82029 --- /dev/null +++ b/doc/src/snippets/code/doc_src_qtscript.cpp @@ -0,0 +1,568 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +//! [0] +#include <QtScript> +//! [0] + +//! [13] +Q_PROPERTY(bool enabled READ enabled WRITE setEnabled) +//! [13] + +//! [18] +QScriptValue myQObjectConstructor(QScriptContext *context, QScriptEngine *engine) +{ + // let the engine manage the new object's lifetime. + return engine->newQObject(new MyQObject(), QScriptEngine::ScriptOwnership); +} +//! [18] + + +//! [19] +class MyObject : public QObject +{ + Q_OBJECT + +public: + MyObject( ... ); + + void aNonScriptableFunction(); + +public slots: // these functions (slots) will be available in QtScript + void calculate( ... ); + void setEnabled( bool enabled ); + bool isEnabled() const; + +private: + .... + +}; +//! [19] + + +//! [20] +class MyObject : public QObject +{ + Q_OBJECT + + public: + Q_INVOKABLE void thisMethodIsInvokableInQtScript(); + void thisMethodIsNotInvokableInQtScript(); + + ... +}; +//! [20] + + +//! [23] +class MyObject : public QObject +{ + Q_OBJECT + // define the enabled property + Q_PROPERTY( bool enabled WRITE setEnabled READ isEnabled ) + +public: + MyObject( ... ); + + void aNonScriptableFunction(); + +public slots: // these functions (slots) will be available in QtScript + void calculate( ... ); + void setEnabled( bool enabled ); + bool isEnabled() const; + +private: + .... + +}; +//! [23] + + +//! [24] +Q_PROPERTY(int nonScriptableProperty READ foo WRITE bar SCRIPTABLE false) +//! [24] + + +//! [25] +class MyObject : public QObject +{ + Q_OBJECT + // define the enabled property + Q_PROPERTY( bool enabled WRITE setEnabled READ isEnabled ) + +public: + MyObject( ... ); + + void aNonScriptableFunction(); + +public slots: // these functions (slots) will be available in QtScript + void calculate( ... ); + void setEnabled( bool enabled ); + bool isEnabled() const; + +signals: // the signals + void enabledChanged( bool newState ); + +private: + .... + +}; +//! [25] + + +//! [34] +QScriptValue Person_ctor(QScriptContext *context, QScriptEngine *engine) +{ + QString name = context->argument(0).toString(); + context->thisObject().setProperty("name", name); + return engine->undefinedValue(); +} +//! [34] + + +//! [35] +QScriptValue Person_prototype_toString(QScriptContext *context, QScriptEngine *engine) +{ + QString name = context->thisObject().property("name").toString(); + QString result = QString::fromLatin1("Person(name: %0)").arg(name); + return result; +} +//! [35] + + +//! [36] +QScriptEngine engine; +QScriptValue ctor = engine.newFunction(Person_ctor); +ctor.property("prototype").setProperty("toString", engine.newFunction(Person_prototype_toString)); +QScriptValue global = engine.globalObject(); +global.setProperty("Person", ctor); +//! [36] + + +//! [37] +QScriptValue Employee_ctor(QScriptContext *context, QScriptEngine *engine) +{ + QScriptValue super = context->callee().property("prototype").property("constructor"); + super.call(context->thisObject(), QScriptValueList() << context->argument(0)); + context->thisObject().setProperty("salary", context->argument(1)); + return engine->undefinedValue(); +} +//! [37] + + +//! [38] +QScriptValue empCtor = engine.newFunction(Employee_ctor); +empCtor.setProperty("prototype", global.property("Person").construct()); +global.setProperty("Employee", empCtor); +//! [38] + + +//! [39] +Q_DECLARE_METATYPE(QPointF) +Q_DECLARE_METATYPE(QPointF*) + +QScriptValue QPointF_prototype_x(QScriptContext *context, QScriptEngine *engine) +{ + // Since the point is not to be modified, it's OK to cast to a value here + QPointF point = qscriptvalue_cast<QPointF>(context->thisObject()); + return point.x(); +} + +QScriptValue QPointF_prototype_setX(QScriptContext *context, QScriptEngine *engine) +{ + // Cast to a pointer to be able to modify the underlying C++ value + QPointF *point = qscriptvalue_cast<QPointF*>(context->thisObject()); + if (!point) + return context->throwError(QScriptContext::TypeError, "QPointF.prototype.setX: this object is not a QPointF"); + point->setX(context->argument(0).toNumber()); + return engine->undefinedValue(); +} +//! [39] + + +//! [43] +class MyObject : public QObject +{ + Q_OBJECT + ... +}; + +Q_DECLARE_METATYPE(MyObject*) + +QScriptValue myObjectToScriptValue(QScriptEngine *engine, MyObject* const &in) +{ return engine->newQObject(in); } + +void myObjectFromScriptValue(const QScriptValue &object, MyObject* &out) +{ out = qobject_cast<MyObject*>(object.toQObject()); } + +... + +qScriptRegisterMetaType(&engine, myObjectToScriptValue, myObjectFromScriptValue); +//! [43] + +//! [44] +QScriptValue QPoint_ctor(QScriptContext *context, QScriptEngine *engine) +{ + int x = context->argument(0).toInt32(); + int y = context->argument(1).toInt32(); + return engine->toScriptValue(QPoint(x, y)); +} + +... + +engine.globalObject().setProperty("QPoint", engine.newFunction(QPoint_ctor)); +//! [44] + +//! [45] +QScriptValue myPrintFunction(QScriptContext *context, QScriptEngine *engine) +{ + QString result; + for (int i = 0; i < context->argumentCount(); ++i) { + if (i > 0) + result.append(" "); + result.append(context->argument(i).toString()); + } + + QScriptValue calleeData = context->callee().data(); + QPlainTextEdit *edit = qobject_cast<QPlainTextEdit*>(calleeData.toQObject()); + edit->appendPlainText(result); + + return engine->undefinedValue(); +} +//! [45] + +//! [46] +int main(int argc, char **argv) +{ + QApplication app(argc, argv); + + QScriptEngine eng; + QPlainTextEdit edit; + + QScriptValue fun = eng.newFunction(myPrintFunction); + fun.setData(eng.newQObject(&edit)); + eng.globalObject().setProperty("print", fun); + + eng.evaluate("print('hello', 'world')"); + + edit.show(); + return app.exec(); +} +//! [46] + + +//! [47] +QScriptEngine eng; +QLineEdit *edit = new QLineEdit(...); +QScriptValue handler = eng.evaluate("(function(text) { print('text was changed to', text); })"); +qScriptConnect(edit, SIGNAL(textChanged(const QString &)), QScriptValue(), handler); +//! [47] + +//! [48] +QLineEdit *edit1 = new QLineEdit(...); +QLineEdit *edit2 = new QLineEdit(...); + +QScriptValue handler = eng.evaluate("(function() { print('I am', this.name); })"); +QScriptValue obj1 = eng.newObject(); +obj1.setProperty("name", "the walrus"); +QScriptValue obj2 = eng.newObject(); +obj2.setProperty("name", "Sam"); + +qScriptConnect(edit1, SIGNAL(returnPressed()), obj1, handler); +qScriptConnect(edit2, SIGNAL(returnPressed()), obj2, handler); +//! [48] + +//! [52] +QScriptValue getProperty(QScriptContext *ctx, QScriptEngine *eng) +{ + QString name = ctx->argument(0).toString(); + return ctx->thisObject().property(name); +} +//! [52] + +//! [53] +QScriptValue myCompare(QScriptContext *ctx, QScriptEngine *eng) +{ + double first = ctx->argument(0).toNumber(); + double second = ctx->argument(1).toNumber(); + int result; + if (first == second) + result = 0; + else if (first < second) + result = -1; + else + result = 1; + return result; +} +//! [53] + +//! [54] +QScriptEngine eng; +QScriptValue comparefn = eng.newFunction(myCompare); +QScriptValue array = eng.evaluate("new Array(10, 5, 20, 15, 30)"); +array.property("sort").call(array, QScriptValueList() << comparefn); + +// prints "5,10,15,20,30" +qDebug() << array.toString(); +//! [54] + +//! [55] +QScriptValue rectifier(QScriptContext *ctx, QScriptEngine *eng) +{ + QRectF magicRect = qscriptvalue_cast<QRectF>(ctx->callee().data()); + QRectF sourceRect = qscriptvalue_cast<QRectF>(ctx->argument(0)); + return eng->toScriptValue(sourceRect.intersected(magicRect)); +} + +... + +QScriptValue fun = eng.newFunction(rectifier); +QRectF magicRect = QRectF(10, 20, 30, 40); +fun.setData(eng.toScriptValue(magicRect)); +eng.globalObject().setProperty("rectifier", fun); +//! [55] + +//! [58] +QScriptValue add(QScriptContext *ctx, QScriptEngine *eng) +{ + double a = ctx->argument(0).toNumber(); + double b = ctx->argument(1).toNumber(); + return a + b; +} +//! [58] + +//! [62] +QScriptValue add(QScriptContext *ctx, QScriptEngine *eng) +{ + if (ctx->argumentCount() != 2) + return ctx->throwError("add() takes exactly two arguments"); + double a = ctx->argument(0).toNumber(); + double b = ctx->argument(1).toNumber(); + return a + b; +} +//! [62] + +//! [63] +QScriptValue add(QScriptContext *ctx, QScriptEngine *eng) +{ + if (ctx->argumentCount() != 2) + return ctx->throwError("add() takes exactly two arguments"); + if (!ctx->argument(0).isNumber()) + return ctx->throwError(QScriptContext::TypeError, "add(): first argument is not a number"); + if (!ctx->argument(1).isNumber()) + return ctx->throwError(QScriptContext::TypeError, "add(): second argument is not a number"); + double a = ctx->argument(0).toNumber(); + double b = ctx->argument(1).toNumber(); + return a + b; +} +//! [63] + +//! [65] +QScriptValue concat(QScriptContext *ctx, QScriptEngine *eng) +{ + QString result = ""; + for (int i = 0; i < ctx->argumentCount(); ++i) + result += ctx->argument(i).toString(); + return result; +} +//! [65] + +//! [67] +QScriptValue sort(QScriptContext *ctx, QScriptEngine *eng) +{ + QScriptValue comparefn = ctx->argument(0); + if (comparefn.isUndefined()) + comparefn = /* the built-in comparison function */; + else if (!comparefn.isFunction()) + return ctx->throwError(QScriptContext::TypeError, "sort(): argument is not a function"); + ... +} +//! [67] + +//! [69] +QScriptValue foo(QScriptContext *ctx, QScriptEngine *eng) +{ + QScriptValue bar = eng->globalObject().property("bar"); + QScriptValue arguments = ctx->argumentsObject(); + qDebug() << "calling bar() with" << arguments.property("length").toInt32() << "arguments"; + QScriptValue result = bar.apply(ctx->thisObject(), arguments); + qDebug() << "bar() returned" << result.toString(); + return result; +} +//! [69] + +//! [72] +QScriptValue counter(QScriptContext *ctx, QScriptEngine *eng) +{ + QScriptValue act = ctx->activationObject(); + act.setProperty("count", 0); + QScriptValue result = eng->newFunction(counter_inner); + result.setScope(act); + return result; +} +//! [72] + +//! [73] +QScriptValue counter_inner(QScriptContext *ctx, QScriptEngine *eng) +{ + QScriptValue outerAct = ctx->callee().scope(); + double count = outerAct.property("count").toNumber(); + outerAct.setProperty("count", count+1); + return count; +} +//! [73] + +//! [74] +QScriptValue counter_hybrid(QScriptContext *ctx, QScriptEngine *eng) +{ + QScriptValue act = ctx->activationObject(); + act.setProperty("count", 0); + return eng->evaluate("(function() { return count++; })"); +} +//! [74] + +//! [76] +QScriptValue Person_ctor(QScriptContext *ctx, QScriptEngine *eng) +{ + QScriptValue object; + if (ctx->isCalledAsConstructor()) { + object = ctx->thisObject(); + } else { + object = eng->newObject(); + object.setPrototype(ctx->callee().property("prototype")); + } + object.setProperty("name", ctx->argument(0)); + return object; +} +//! [76] + +//! [77] +QScriptContext *ctx = eng.pushContext(); +QScriptValue act = ctx->activationObject(); +act.setProperty("digit", 7); + +qDebug() << eng.evaluate("digit + 1").toNumber(); // 8 + +eng.popContext(); +//! [77] + +//! [78] +QScriptValue getSet(QScriptContext *ctx, QScriptEngine *eng) +{ + QScriptValue obj = ctx->thisObject(); + QScriptValue data = obj.data(); + if (!data.isValid()) { + data = eng->newObject(); + obj.setData(data); + } + QScriptValue result; + if (ctx->argumentCount() == 1) { + QString str = ctx->argument(0).toString(); + str.replace("Roberta", "Ken"); + result = str; + data.setProperty("x", result); + } else { + result = data.property("x"); + } + return result; +} +//! [78] + +//! [79] +QScriptEngine eng; +QScriptValue obj = eng.newObject(); +obj.setProperty("x", eng.newFunction(getSet), + QScriptValue::PropertyGetter|QScriptValue::PropertySetter); +//! [79] + +//! [91] +QScriptValue object = engine.evaluate("({ unitName: 'Celsius', toKelvin: function(x) { return x + 273; } })"); +QScriptValue toKelvin = object.property("toKelvin"); +QScriptValue result = toKelvin.call(object, QScriptValueList() << 100); +qDebug() << result.toNumber(); // 373 +//! [91] + +//! [92] +QScriptValue add = engine.globalObject().property("add"); +qDebug() << add.call(QScriptValue(), QScriptValueList() << 1 << 2).toNumber(); // 3 +//! [92] + +//! [93] +typedef QSharedPointer<QXmlStreamReader> XmlStreamReaderPointer; + +Q_DECLARE_METATYPE(XmlStreamReaderPointer) + +QScriptValue constructXmlStreamReader(QScriptContext *context, QScriptEngine *engine) +{ + if (!context->isCalledAsConstructor()) + return context->throwError(QScriptContext::SyntaxError, "please use the 'new' operator"); + + QIODevice *device = qobject_cast<QIODevice*>(context->argument(0).toQObject()); + if (!device) + return context->throwError(QScriptContext::TypeError, "please supply a QIODevice as first argument"); + + // Create the C++ object + QXmlStreamReader *reader = new QXmlStreamReader(device); + + XmlStreamReaderPointer pointer(reader); + + // store the shared pointer in the script object that we are constructing + return engine->newVariant(context->thisObject(), QVariant::fromValue(pointer)); +} +//! [93] + +//! [94] +QScriptValue xmlStreamReader_atEnd(QScriptContext *context, QScriptEngine *) +{ + XmlStreamReaderPointer reader = qscriptvalue_cast<XmlStreamReaderPointer>(context->thisObject()); + if (!reader) + return context->throwError(QScriptContext::TypeError, "this object is not an XmlStreamReader"); + return reader->atEnd(); +} +//! [94] + +//! [95] + QScriptEngine engine; + QScriptValue xmlStreamReaderProto = engine.newObject(); + xmlStreamReaderProto.setProperty("atEnd", engine.newFunction(xmlStreamReader_atEnd)); + + QScriptValue xmlStreamReaderCtor = engine.newFunction(constructXmlStreamReader, xmlStreamReaderProto); + engine.globalObject().setProperty("XmlStreamReader", xmlStreamReaderCtor); +//! [95] diff --git a/doc/src/snippets/code/doc_src_qtscript.js b/doc/src/snippets/code/doc_src_qtscript.js new file mode 100644 index 0000000..fe1f9b9 --- /dev/null +++ b/doc/src/snippets/code/doc_src_qtscript.js @@ -0,0 +1,444 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +//! [2] +function myInterestingScriptFunction() { + // ... +} +// ... +myQObject.somethingChanged.connect(myInterestingScriptFunction); +//! [2] + + +//! [3] +myQObject.somethingChanged.connect(myOtherQObject.doSomething); +//! [3] + + +//! [4] +myQObject.somethingChanged.disconnect(myInterestingFunction); +myQObject.somethingChanged.disconnect(myOtherQObject.doSomething); +//! [4] + + +//! [5] +var obj = { x: 123 }; +var fun = function() { print(this.x); }; +myQObject.somethingChanged.connect(obj, fun); +//! [5] + + +//! [6] +myQObject.somethingChanged.disconnect(obj, fun); +//! [6] + + +//! [7] +var obj = { x: 123, fun: function() { print(this.x); } }; +myQObject.somethingChanged.connect(obj, "fun"); +//! [7] + + +//! [8] +myQObject.somethingChanged.disconnect(obj, "fun"); +//! [8] + + +//! [9] +try { + myQObject.somethingChanged.connect(myQObject, "slotThatDoesntExist"); +} catch (e) { + print(e); +} +//! [9] + + +//! [10] +myQObject.somethingChanged("hello"); +//! [10] + + +//! [11] +myQObject.myOverloadedSlot(10); // will call the int overload +myQObject.myOverloadedSlot("10"); // will call the QString overload +//! [11] + + +//! [12] +myQObject['myOverloadedSlot(int)']("10"); // call int overload; the argument is converted to an int +myQObject['myOverloadedSlot(QString)'](10); // call QString overload; the argument is converted to a string +//! [12] + + +//! [14] +myQObject.enabled = true; + +// ... + +myQObject.enabled = !myQObject.enabled; +//! [14] + + +//! [15] +myDialog.okButton +//! [15] + + +//! [16] +myDialog.okButton.objectName = "cancelButton"; +// from now on, myDialog.cancelButton references the button +//! [16] + + +//! [17] +var okButton = myDialog.findChild("okButton"); +if (okButton != null) { + // do something with the OK button +} + +var buttons = myDialog.findChildren(RegExp("button[0-9]+")); +for (var i = 0; i < buttons.length; ++i) { + // do something with buttons[i] +} +//! [17] + + +//! [21] +var obj = new MyObject; +obj.setEnabled( true ); +print( "obj is enabled: " + obj.isEnabled() ); +//! [21] + + +//! [22] +var obj = new MyObject; +obj.enabled = true; +print( "obj is enabled: " + obj.enabled ); +//! [22] + + +//! [26] +function enabledChangedHandler( b ) +{ + print( "state changed to: " + b ); +} + +function init() +{ + var obj = new MyObject(); + // connect a script function to the signal + obj["enabledChanged(bool)"].connect(enabledChangedHandler); + obj.enabled = true; + print( "obj is enabled: " + obj.enabled ); +} +//! [26] + + +//! [27] +var o = new Object(); +o.foo = 123; +print(o.hasOwnProperty('foo')); // true +print(o.hasOwnProperty('bar')); // false +print(o); // calls o.toString(), which returns "[object Object]" +//! [27] + + +//! [28] +function Person(name) +{ + this.name = name; +} +//! [28] + + +//! [29] +Person.prototype.toString = function() { return "Person(name: " + this.name + ")"; } +//! [29] + + +//! [30] +var p1 = new Person("John Doe"); +var p2 = new Person("G.I. Jane"); +print(p1); // "Person(name: John Doe)" +print(p2); // "Person(name: G.I. Jane)" +//! [30] + + +//! [31] +print(p1.hasOwnProperty('name')); // 'name' is an instance variable, so this returns true +print(p1.hasOwnProperty('toString')); // returns false; inherited from prototype +print(p1 instanceof Person); // true +print(p1 instanceof Object); // true +//! [31] + + +//! [32] +function Employee(name, salary) +{ + Person.call(this, name); // call base constructor + + this.salary = salary; +} + +// set the prototype to be an instance of the base class +Employee.prototype = new Person(); + +// initialize prototype +Employee.prototype.toString = function() { + // ... +} +//! [32] + + +//! [33] +var e = new Employee("Johnny Bravo", 5000000); +print(e instanceof Employee); // true +print(e instanceof Person); // true +print(e instanceof Object); // true +print(e instanceof Array); // false +//! [33] + + +//! [40] +var o = new Object(); +(o.__proto__ === Object.prototype); // this evaluates to true +//! [40] + + +//! [41] +var o = new Object(); +o.__defineGetter__("x", function() { return 123; }); +var y = o.x; // 123 +//! [41] + + +//! [42] +var o = new Object(); +o.__defineSetter__("x", function(v) { print("and the value is:", v); }); +o.x = 123; // will print "and the value is: 123" +//! [42] + + +//! [49] +var getProperty = function(name) { return this[name]; }; + +name = "Global Object"; // creates a global variable +print(getProperty("name")); // "Global Object" + +var myObject = { name: 'My Object' }; +print(getProperty.call(myObject, "name")); // "My Object" + +myObject.getProperty = getProperty; +print(myObject.getProperty("name")); // "My Object" + +getProperty.name = "The getProperty() function"; +getProperty.getProperty = getProperty; +getProperty.getProperty("name"); // "The getProperty() function" +//! [49] + +//! [50] +var o = { a: 1, b: 2, sum: function() { return a + b; } }; +print(o.sum()); // reference error, or sum of global variables a and b!! +//! [50] + +//! [51] +var o = { a: 1, b: 2, sum: function() { return this.a + this.b; } }; +print(o.sum()); // 3 +//! [51] + +//! [56] +function add(a, b) { + return a + b; +} +//! [56] + +//! [57] +function add() { + return arguments[0] + arguments[1]; +} +//! [57] + +//! [59] +function add() { + if (arguments.length != 2) + throw Error("add() takes exactly two arguments"); + return arguments[0] + arguments[1]; +} +//! [59] + +//! [60] +function add() { + if (arguments.length != 2) + throw Error("add() takes exactly two arguments"); + if (typeof arguments[0] != "number") + throw TypeError("add(): first argument is not a number"); + if (typeof arguments[1] != "number") + throw TypeError("add(): second argument is not a number"); + return arguments[0] + arguments[1]; +} +//! [60] + +//! [61] +function add() { + if (arguments.length != 2) + throw Error("add() takes exactly two arguments"); + return Number(arguments[0]) + Number(arguments[1]); +} +//! [61] + +//! [64] +function concat() { + var result = ""; + for (var i = 0; i < arguments.length; ++i) + result += String(arguments[i]); + return result; +} +//! [64] + +//! [66] +function sort(comparefn) { + if (comparefn == undefined) + comparefn = fn; /* replace fn with the built-in comparison function */ + else if (typeof comparefn != "function") + throw TypeError("sort(): argument must be a function"); + // ... +} +//! [66] + +//! [68] +function foo() { + // Let bar() take care of this. + print("calling bar() with " + arguments.length + "arguments"); + var result = bar.apply(this, arguments); + print("bar() returned" + result); + return result; +} +//! [68] + +//! [70] +function counter() { + var count = 0; + return function() { + return count++; + } +} +//! [70] + +//! [71] +var c1 = counter(); // create a new counter function +var c2 = counter(); // create a new counter function +print(c1()); // 0 +print(c1()); // 1 +print(c2()); // 0 +print(c2()); // 1 +//! [71] + +//! [75] +function Book(isbn) { + this.isbn = isbn; +} + +var coolBook1 = new Book("978-0131872493"); +var coolBook2 = new Book("978-1593271473"); +//! [75] + +//! [80] +obj.x = "Roberta sent me"; +print(obj.x); // "Ken sent me" +obj.x = "I sent the bill to Roberta"; +print(obj.x); // "I sent the bill to Ken" +//! [80] + +//! [81] +obj = {}; +obj.__defineGetter__("x", function() { return this._x; }); +obj.__defineSetter__("x", function(v) { print("setting x to", v); this._x = v; }); +obj.x = 123; +//! [81] + +//! [82] +myButton.text = qsTr("Hello world!"); +//! [82] + +//! [83] +myButton.text = qsTranslate("MyAwesomeScript", "Hello world!"); +//! [83] + +//! [84] +FriendlyConversation.prototype.greeting = function(type) +{ + if (FriendlyConversation['greeting_strings'] == undefined) { + FriendlyConversation['greeting_strings'] = [ + QT_TR_NOOP("Hello"), + QT_TR_NOOP("Goodbye") + ]; + } + return qsTr(FriendlyConversation.greeting_strings[type]); +} +//! [84] + +//! [85] +FriendlyConversation.prototype.greeting = function(type) +{ + if (FriendlyConversation['greeting_strings'] == undefined) { + FriendlyConversation['greeting_strings'] = [ + QT_TRANSLATE_NOOP("FriendlyConversation", "Hello"), + QT_TRANSLATE_NOOP("FriendlyConversation", "Goodbye") + ]; + } + return qsTranslate("FriendlyConversation", FriendlyConversation.greeting_strings[type]); +} +//! [85] + +//! [86] +FileCopier.prototype.showProgress = function(done, total, currentFileName) +{ + this.label.text = qsTr("%1 of %2 files copied.\nCopying: %3") + .arg(done) + .arg(total) + .arg(currentFileName); +} +//! [86] + +//! [90] +({ unitName: "Celsius", + toKelvin: function(x) { return x + 273; } + }) +//! [90] diff --git a/doc/src/snippets/code/doc_src_qtscript.pro b/doc/src/snippets/code/doc_src_qtscript.pro new file mode 100644 index 0000000..ce687d7 --- /dev/null +++ b/doc/src/snippets/code/doc_src_qtscript.pro @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +#! [1] +QT += script +#! [1] diff --git a/doc/src/snippets/code/doc_src_qtscript.qdoc b/doc/src/snippets/code/doc_src_qtscript.qdoc index 1ba097a..b65311f 100644 --- a/doc/src/snippets/code/doc_src_qtscript.qdoc +++ b/doc/src/snippets/code/doc_src_qtscript.qdoc @@ -38,882 +38,6 @@ ** ****************************************************************************/ -//! [0] -#include <QtScript> -//! [0] - - -//! [1] -QT += script -//! [1] - - -//! [2] -function myInterestingScriptFunction() { ... } -... -myQObject.somethingChanged.connect(myInterestingScriptFunction); -//! [2] - - -//! [3] -myQObject.somethingChanged.connect(myOtherQObject.doSomething); -//! [3] - - -//! [4] -myQObject.somethingChanged.disconnect(myInterestingFunction); -myQObject.somethingChanged.disconnect(myOtherQObject.doSomething); -//! [4] - - -//! [5] -var obj = { x: 123 }; -var fun = function() { print(this.x); }; -myQObject.somethingChanged.connect(obj, fun); -//! [5] - - -//! [6] -myQObject.somethingChanged.disconnect(obj, fun); -//! [6] - - -//! [7] -var obj = { x: 123, fun: function() { print(this.x); } }; -myQObject.somethingChanged.connect(obj, "fun"); -//! [7] - - -//! [8] -myQObject.somethingChanged.disconnect(obj, "fun"); -//! [8] - - -//! [9] -try { - myQObject.somethingChanged.connect(myQObject, "slotThatDoesntExist"); -} catch (e) { - print(e); -} -//! [9] - - -//! [10] -myQObject.somethingChanged("hello"); -//! [10] - - -//! [11] -myQObject.myOverloadedSlot(10); // will call the int overload -myQObject.myOverloadedSlot("10"); // will call the QString overload -//! [11] - - -//! [12] -myQObject['myOverloadedSlot(int)']("10"); // call int overload; the argument is converted to an int -myQObject['myOverloadedSlot(QString)'](10); // call QString overload; the argument is converted to a string -//! [12] - - -//! [13] -Q_PROPERTY(bool enabled READ enabled WRITE setEnabled) -//! [13] - - -//! [14] -myQObject.enabled = true; - -... - -myQObject.enabled = !myQObject.enabled; -//! [14] - - -//! [15] -myDialog.okButton -//! [15] - - -//! [16] -myDialog.okButton.objectName = "cancelButton"; -// from now on, myDialog.cancelButton references the button -//! [16] - - -//! [17] -var okButton = myDialog.findChild("okButton"); -if (okButton != null) { - // do something with the OK button -} - -var buttons = myDialog.findChildren(RegExp("button[0-9]+")); -for (var i = 0; i < buttons.length; ++i) { - // do something with buttons[i] -} -//! [17] - - -//! [18] -QScriptValue myQObjectConstructor(QScriptContext *context, QScriptEngine *engine) -{ - // let the engine manage the new object's lifetime. - return engine->newQObject(new MyQObject(), QScriptEngine::ScriptOwnership); -} -//! [18] - - -//! [19] -class MyObject : public QObject -{ - Q_OBJECT - -public: - MyObject( ... ); - - void aNonScriptableFunction(); - -public slots: // these functions (slots) will be available in QtScript - void calculate( ... ); - void setEnabled( bool enabled ); - bool isEnabled() const; - -private: - .... - -}; -//! [19] - - -//! [20] -class MyObject : public QObject -{ - Q_OBJECT - - public: - Q_INVOKABLE void thisMethodIsInvokableInQtScript(); - void thisMethodIsNotInvokableInQtScript(); - - ... -}; -//! [20] - - -//! [21] -var obj = new MyObject; -obj.setEnabled( true ); -print( "obj is enabled: " + obj.isEnabled() ); -//! [21] - - -//! [22] -var obj = new MyObject; -obj.enabled = true; -print( "obj is enabled: " + obj.enabled ); -//! [22] - - -//! [23] -class MyObject : public QObject -{ - Q_OBJECT - // define the enabled property - Q_PROPERTY( bool enabled WRITE setEnabled READ isEnabled ) - -public: - MyObject( ... ); - - void aNonScriptableFunction(); - -public slots: // these functions (slots) will be available in QtScript - void calculate( ... ); - void setEnabled( bool enabled ); - bool isEnabled() const; - -private: - .... - -}; -//! [23] - - -//! [24] -Q_PROPERTY(int nonScriptableProperty READ foo WRITE bar SCRIPTABLE false) -//! [24] - - -//! [25] -class MyObject : public QObject -{ - Q_OBJECT - // define the enabled property - Q_PROPERTY( bool enabled WRITE setEnabled READ isEnabled ) - -public: - MyObject( ... ); - - void aNonScriptableFunction(); - -public slots: // these functions (slots) will be available in QtScript - void calculate( ... ); - void setEnabled( bool enabled ); - bool isEnabled() const; - -signals: // the signals - void enabledChanged( bool newState ); - -private: - .... - -}; -//! [25] - - -//! [26] -function enabledChangedHandler( b ) -{ - print( "state changed to: " + b ); -} - -function init() -{ - var obj = new MyObject(); - // connect a script function to the signal - obj["enabledChanged(bool)"].connect(enabledChangedHandler); - obj.enabled = true; - print( "obj is enabled: " + obj.enabled ); -} -//! [26] - - -//! [27] -var o = new Object(); -o.foo = 123; -print(o.hasOwnProperty('foo')); // true -print(o.hasOwnProperty('bar')); // false -print(o); // calls o.toString(), which returns "[object Object]" -//! [27] - - -//! [28] -function Person(name) -{ - this.name = name; -} -//! [28] - - -//! [29] -Person.prototype.toString = function() { return "Person(name: " + this.name + ")"; } -//! [29] - - -//! [30] -var p1 = new Person("John Doe"); -var p2 = new Person("G.I. Jane"); -print(p1); // "Person(name: John Doe)" -print(p2); // "Person(name: G.I. Jane)" -//! [30] - - -//! [31] -print(p1.hasOwnProperty('name')); // 'name' is an instance variable, so this returns true -print(p1.hasOwnProperty('toString')); // returns false; inherited from prototype -print(p1 instanceof Person); // true -print(p1 instanceof Object); // true -//! [31] - - -//! [32] -function Employee(name, salary) -{ - Person.call(this, name); // call base constructor - - this.salary = salary; -} - -// set the prototype to be an instance of the base class -Employee.prototype = new Person(); - -// initialize prototype -Employee.prototype.toString = function() { ... } -//! [32] - - -//! [33] -var e = new Employee("Johnny Bravo", 5000000); -print(e instanceof Employee); // true -print(e instanceof Person); // true -print(e instanceof Object); // true -print(e instanceof Array); // false -//! [33] - - -//! [34] -QScriptValue Person_ctor(QScriptContext *context, QScriptEngine *engine) -{ - QString name = context->argument(0).toString(); - context->thisObject().setProperty("name", name); - return engine->undefinedValue(); -} -//! [34] - - -//! [35] -QScriptValue Person_prototype_toString(QScriptContext *context, QScriptEngine *engine) -{ - QString name = context->thisObject().property("name").toString(); - QString result = QString::fromLatin1("Person(name: %0)").arg(name); - return result; -} -//! [35] - - -//! [36] -QScriptEngine engine; -QScriptValue ctor = engine.newFunction(Person_ctor); -ctor.property("prototype").setProperty("toString", engine.newFunction(Person_prototype_toString)); -QScriptValue global = engine.globalObject(); -global.setProperty("Person", ctor); -//! [36] - - -//! [37] -QScriptValue Employee_ctor(QScriptContext *context, QScriptEngine *engine) -{ - QScriptValue super = context->callee().property("prototype").property("constructor"); - super.call(context->thisObject(), QScriptValueList() << context->argument(0)); - context->thisObject().setProperty("salary", context->argument(1)); - return engine->undefinedValue(); -} -//! [37] - - -//! [38] -QScriptValue empCtor = engine.newFunction(Employee_ctor); -empCtor.setProperty("prototype", global.property("Person").construct()); -global.setProperty("Employee", empCtor); -//! [38] - - -//! [39] -Q_DECLARE_METATYPE(QPointF) -Q_DECLARE_METATYPE(QPointF*) - -QScriptValue QPointF_prototype_x(QScriptContext *context, QScriptEngine *engine) -{ - // Since the point is not to be modified, it's OK to cast to a value here - QPointF point = qscriptvalue_cast<QPointF>(context->thisObject()); - return point.x(); -} - -QScriptValue QPointF_prototype_setX(QScriptContext *context, QScriptEngine *engine) -{ - // Cast to a pointer to be able to modify the underlying C++ value - QPointF *point = qscriptvalue_cast<QPointF*>(context->thisObject()); - if (!point) - return context->throwError(QScriptContext::TypeError, "QPointF.prototype.setX: this object is not a QPointF"); - point->setX(context->argument(0).toNumber()); - return engine->undefinedValue(); -} -//! [39] - - -//! [40] -var o = new Object(); -(o.__proto__ === Object.prototype); // this evaluates to true -//! [40] - - -//! [41] -var o = new Object(); -o.__defineGetter__("x", function() { return 123; }); -var y = o.x; // 123 -//! [41] - - -//! [42] -var o = new Object(); -o.__defineSetter__("x", function(v) { print("and the value is:", v); }); -o.x = 123; // will print "and the value is: 123" -//! [42] - - -//! [43] -class MyObject : public QObject -{ - Q_OBJECT - ... -}; - -Q_DECLARE_METATYPE(MyObject*) - -QScriptValue myObjectToScriptValue(QScriptEngine *engine, MyObject* const &in) -{ return engine->newQObject(in); } - -void myObjectFromScriptValue(const QScriptValue &object, MyObject* &out) -{ out = qobject_cast<MyObject*>(object.toQObject()); } - -... - -qScriptRegisterMetaType(&engine, myObjectToScriptValue, myObjectFromScriptValue); -//! [43] - -//! [44] -QScriptValue QPoint_ctor(QScriptContext *context, QScriptEngine *engine) -{ - int x = context->argument(0).toInt32(); - int y = context->argument(1).toInt32(); - return engine->toScriptValue(QPoint(x, y)); -} - -... - -engine.globalObject().setProperty("QPoint", engine.newFunction(QPoint_ctor)); -//! [44] - -//! [45] -QScriptValue myPrintFunction(QScriptContext *context, QScriptEngine *engine) -{ - QString result; - for (int i = 0; i < context->argumentCount(); ++i) { - if (i > 0) - result.append(" "); - result.append(context->argument(i).toString()); - } - - QScriptValue calleeData = context->callee().data(); - QPlainTextEdit *edit = qobject_cast<QPlainTextEdit*>(calleeData.toQObject()); - edit->appendPlainText(result); - - return engine->undefinedValue(); -} -//! [45] - -//! [46] -int main(int argc, char **argv) -{ - QApplication app(argc, argv); - - QScriptEngine eng; - QPlainTextEdit edit; - - QScriptValue fun = eng.newFunction(myPrintFunction); - fun.setData(eng.newQObject(&edit)); - eng.globalObject().setProperty("print", fun); - - eng.evaluate("print('hello', 'world')"); - - edit.show(); - return app.exec(); -} -//! [46] - - -//! [47] -QScriptEngine eng; -QLineEdit *edit = new QLineEdit(...); -QScriptValue handler = eng.evaluate("(function(text) { print('text was changed to', text); })"); -qScriptConnect(edit, SIGNAL(textChanged(const QString &)), QScriptValue(), handler); -//! [47] - -//! [48] -QLineEdit *edit1 = new QLineEdit(...); -QLineEdit *edit2 = new QLineEdit(...); - -QScriptValue handler = eng.evaluate("(function() { print('I am', this.name); })"); -QScriptValue obj1 = eng.newObject(); -obj1.setProperty("name", "the walrus"); -QScriptValue obj2 = eng.newObject(); -obj2.setProperty("name", "Sam"); - -qScriptConnect(edit1, SIGNAL(returnPressed()), obj1, handler); -qScriptConnect(edit2, SIGNAL(returnPressed()), obj2, handler); -//! [48] - -//! [49] -var getProperty = function(name) { return this[name]; }; - -name = "Global Object"; // creates a global variable -print(getProperty("name")); // "Global Object" - -var myObject = { name: 'My Object' }; -print(getProperty.call(myObject, "name")); // "My Object" - -myObject.getProperty = getProperty; -print(myObject.getProperty("name")); // "My Object" - -getProperty.name = "The getProperty() function"; -getProperty.getProperty = getProperty; -getProperty.getProperty("name"); // "The getProperty() function" -//! [49] - -//! [50] -var o = { a: 1, b: 2, sum: function() { return a + b; } }; -print(o.sum()); // reference error, or sum of global variables a and b!! -//! [50] - -//! [51] -var o = { a: 1, b: 2, sum: function() { return this.a + this.b; } }; -print(o.sum()); // 3 -//! [51] - -//! [52] -QScriptValue getProperty(QScriptContext *ctx, QScriptEngine *eng) -{ - QString name = ctx->argument(0).toString(); - return ctx->thisObject().property(name); -} -//! [52] - -//! [53] -QScriptValue myCompare(QScriptContext *ctx, QScriptEngine *eng) -{ - double first = ctx->argument(0).toNumber(); - double second = ctx->argument(1).toNumber(); - int result; - if (first == second) - result = 0; - else if (first < second) - result = -1; - else - result = 1; - return result; -} -//! [53] - -//! [54] -QScriptEngine eng; -QScriptValue comparefn = eng.newFunction(myCompare); -QScriptValue array = eng.evaluate("new Array(10, 5, 20, 15, 30)"); -array.property("sort").call(array, QScriptValueList() << comparefn); - -// prints "5,10,15,20,30" -qDebug() << array.toString(); -//! [54] - -//! [55] -QScriptValue rectifier(QScriptContext *ctx, QScriptEngine *eng) -{ - QRectF magicRect = qscriptvalue_cast<QRectF>(ctx->callee().data()); - QRectF sourceRect = qscriptvalue_cast<QRectF>(ctx->argument(0)); - return eng->toScriptValue(sourceRect.intersected(magicRect)); -} - -... - -QScriptValue fun = eng.newFunction(rectifier); -QRectF magicRect = QRectF(10, 20, 30, 40); -fun.setData(eng.toScriptValue(magicRect)); -eng.globalObject().setProperty("rectifier", fun); -//! [55] - -//! [56] -function add(a, b) { - return a + b; -} -//! [56] - -//! [57] -function add() { - return arguments[0] + arguments[1]; -} -//! [57] - -//! [58] -QScriptValue add(QScriptContext *ctx, QScriptEngine *eng) -{ - double a = ctx->argument(0).toNumber(); - double b = ctx->argument(1).toNumber(); - return a + b; -} -//! [58] - -//! [59] -function add() { - if (arguments.length != 2) - throw Error("add() takes exactly two arguments"); - return arguments[0] + arguments[1]; -} -//! [59] - -//! [60] -function add() { - if (arguments.length != 2) - throw Error("add() takes exactly two arguments"); - if (typeof arguments[0] != "number") - throw TypeError("add(): first argument is not a number"); - if (typeof arguments[1] != "number") - throw TypeError("add(): second argument is not a number"); - return arguments[0] + arguments[1]; -} -//! [60] - -//! [61] -function add() { - if (arguments.length != 2) - throw Error("add() takes exactly two arguments"); - return Number(arguments[0]) + Number(arguments[1]); -} -//! [61] - -//! [62] -QScriptValue add(QScriptContext *ctx, QScriptEngine *eng) -{ - if (ctx->argumentCount() != 2) - return ctx->throwError("add() takes exactly two arguments"); - double a = ctx->argument(0).toNumber(); - double b = ctx->argument(1).toNumber(); - return a + b; -} -//! [62] - -//! [63] -QScriptValue add(QScriptContext *ctx, QScriptEngine *eng) -{ - if (ctx->argumentCount() != 2) - return ctx->throwError("add() takes exactly two arguments"); - if (!ctx->argument(0).isNumber()) - return ctx->throwError(QScriptContext::TypeError, "add(): first argument is not a number"); - if (!ctx->argument(1).isNumber()) - return ctx->throwError(QScriptContext::TypeError, "add(): second argument is not a number"); - double a = ctx->argument(0).toNumber(); - double b = ctx->argument(1).toNumber(); - return a + b; -} -//! [63] - -//! [64] -function concat() { - var result = ""; - for (var i = 0; i < arguments.length; ++i) - result += String(arguments[i]); - return result; -} -//! [64] - -//! [65] -QScriptValue concat(QScriptContext *ctx, QScriptEngine *eng) -{ - QString result = ""; - for (int i = 0; i < ctx->argumentCount(); ++i) - result += ctx->argument(i).toString(); - return result; -} -//! [65] - -//! [66] -function sort(comparefn) { - if (comparefn == undefined) - comparefn = /* the built-in comparison function */; - else if (typeof comparefn != "function") - throw TypeError("sort(): argument must be a function"); - ... -} -//! [66] - -//! [67] -QScriptValue sort(QScriptContext *ctx, QScriptEngine *eng) -{ - QScriptValue comparefn = ctx->argument(0); - if (comparefn.isUndefined()) - comparefn = /* the built-in comparison function */; - else if (!comparefn.isFunction()) - return ctx->throwError(QScriptContext::TypeError, "sort(): argument is not a function"); - ... -} -//! [67] - -//! [68] -function foo() { - // Let bar() take care of this. - print("calling bar() with " + arguments.length + "arguments"); - var result = return bar.apply(this, arguments); - print("bar() returned" + result); - return result; -} -//! [68] - -//! [69] -QScriptValue foo(QScriptContext *ctx, QScriptEngine *eng) -{ - QScriptValue bar = eng->globalObject().property("bar"); - QScriptValue arguments = ctx->argumentsObject(); - qDebug() << "calling bar() with" << arguments.property("length").toInt32() << "arguments"; - QScriptValue result = bar.apply(ctx->thisObject(), arguments); - qDebug() << "bar() returned" << result.toString(); - return result; -} -//! [69] - -//! [70] -function counter() { - var count = 0; - return function() { - return count++; - } -} -//! [70] - -//! [71] -var c1 = counter(); // create a new counter function -var c2 = counter(); // create a new counter function -print(c1()); // 0 -print(c1()); // 1 -print(c2()); // 0 -print(c2()); // 1 -//! [71] - -//! [72] -QScriptValue counter(QScriptContext *ctx, QScriptEngine *eng) -{ - QScriptValue act = ctx->activationObject(); - act.setProperty("count", 0); - QScriptValue result = eng->newFunction(counter_inner); - result.setScope(act); - return result; -} -//! [72] - -//! [73] -QScriptValue counter_inner(QScriptContext *ctx, QScriptEngine *eng) -{ - QScriptValue outerAct = ctx->callee().scope(); - double count = outerAct.property("count").toNumber(); - outerAct.setProperty("count", count+1); - return count; -} -//! [73] - -//! [74] -QScriptValue counter_hybrid(QScriptContext *ctx, QScriptEngine *eng) -{ - QScriptValue act = ctx->activationObject(); - act.setProperty("count", 0); - return eng->evaluate("(function() { return count++; })"); -} -//! [74] - -//! [75] -function Book(isbn) { - this.isbn = isbn; -} - -var coolBook1 = new Book("978-0131872493"); -var coolBook2 = new Book("978-1593271473"); -//! [75] - -//! [76] -QScriptValue Person_ctor(QScriptContext *ctx, QScriptEngine *eng) -{ - QScriptValue object; - if (ctx->isCalledAsConstructor()) { - object = ctx->thisObject(); - } else { - object = eng->newObject(); - object.setPrototype(ctx->callee().property("prototype")); - } - object.setProperty("name", ctx->argument(0)); - return object; -} -//! [76] - -//! [77] -QScriptContext *ctx = eng.pushContext(); -QScriptValue act = ctx->activationObject(); -act.setProperty("digit", 7); - -qDebug() << eng.evaluate("digit + 1").toNumber(); // 8 - -eng.popContext(); -//! [77] - -//! [78] -QScriptValue getSet(QScriptContext *ctx, QScriptEngine *eng) -{ - QScriptValue obj = ctx->thisObject(); - QScriptValue data = obj.data(); - if (!data.isValid()) { - data = eng->newObject(); - obj.setData(data); - } - QScriptValue result; - if (ctx->argumentCount() == 1) { - QString str = ctx->argument(0).toString(); - str.replace("Roberta", "Ken"); - result = str; - data.setProperty("x", result); - } else { - result = data.property("x"); - } - return result; -} -//! [78] - -//! [79] -QScriptEngine eng; -QScriptValue obj = eng.newObject(); -obj.setProperty("x", eng.newFunction(getSet), - QScriptValue::PropertyGetter|QScriptValue::PropertySetter); -//! [79] - -//! [80] -obj.x = "Roberta sent me"; -print(obj.x); // "Ken sent me" -obj.x = "I sent the bill to Roberta"; -print(obj.x); // "I sent the bill to Ken" -//! [80] - -//! [81] -obj = {}; -obj.__defineGetter__("x", function() { return this._x; }); -obj.__defineSetter__("x", function(v) { print("setting x to", v); this._x = v; }); -obj.x = 123; -//! [81] - -//! [82] -myButton.text = qsTr("Hello world!"); -//! [82] - -//! [83] -myButton.text = qsTranslate("MyAwesomeScript", "Hello world!"); -//! [83] - -//! [84] -FriendlyConversation.prototype.greeting = function(type) -{ - if (FriendlyConversation['greeting_strings'] == undefined) { - FriendlyConversation['greeting_strings'] = [ - QT_TR_NOOP("Hello"), - QT_TR_NOOP("Goodbye") - ]; - } - return qsTr(FriendlyConversation.greeting_strings[type]); -} -//! [84] - -//! [85] -FriendlyConversation.prototype.greeting = function(type) -{ - if (FriendlyConversation['greeting_strings'] == undefined) { - FriendlyConversation['greeting_strings'] = [ - QT_TRANSLATE_NOOP("FriendlyConversation", "Hello"), - QT_TRANSLATE_NOOP("FriendlyConversation", "Goodbye") - ]; - } - return qsTranslate("FriendlyConversation", FriendlyConversation.greeting_strings[type]); -} -//! [85] - -//! [86] -FileCopier.prototype.showProgress = function(done, total, currentFileName) -{ - this.label.text = qsTr("%1 of %2 files copied.\nCopying: %3") - .arg(done) - .arg(total) - .arg(currentFileName)); -} -//! [86] - //! [87] lupdate myscript.qs -ts myscript_la.ts //! [87] @@ -925,64 +49,3 @@ lupdate -extensions qs scripts/ -ts scripts_la.ts //! [89] lrelease myscript_la.ts //! [89] - -//! [90] -({ unitName: "Celsius", - toKelvin: function(x) { return x + 273; } - }) -//! [90] - -//! [91] -QScriptValue object = engine.evaluate("({ unitName: 'Celsius', toKelvin: function(x) { return x + 273; } })"); -QScriptValue toKelvin = object.property("toKelvin"); -QScriptValue result = toKelvin.call(object, QScriptValueList() << 100); -qDebug() << result.toNumber(); // 373 -//! [91] - -//! [92] -QScriptValue add = engine.globalObject().property("add"); -qDebug() << add.call(QScriptValue(), QScriptValueList() << 1 << 2).toNumber(); // 3 -//! [92] - -//! [93] -typedef QSharedPointer<QXmlStreamReader> XmlStreamReaderPointer; - -Q_DECLARE_METATYPE(XmlStreamReaderPointer) - -QScriptValue constructXmlStreamReader(QScriptContext *context, QScriptEngine *engine) -{ - if (!context->isCalledAsConstructor()) - return context->throwError(QScriptContext::SyntaxError, "please use the 'new' operator"); - - QIODevice *device = qobject_cast<QIODevice*>(context->argument(0).toQObject()); - if (!device) - return context->throwError(QScriptContext::TypeError, "please supply a QIODevice as first argument"); - - // Create the C++ object - QXmlStreamReader *reader = new QXmlStreamReader(device); - - XmlStreamReaderPointer pointer(reader); - - // store the shared pointer in the script object that we are constructing - return engine->newVariant(context->thisObject(), QVariant::fromValue(pointer)); -} -//! [93] - -//! [94] -QScriptValue xmlStreamReader_atEnd(QScriptContext *context, QScriptEngine *) -{ - XmlStreamReaderPointer reader = qscriptvalue_cast<XmlStreamReaderPointer>(context->thisObject()); - if (!reader) - return context->throwError(QScriptContext::TypeError, "this object is not an XmlStreamReader"); - return reader->atEnd(); -} -//! [94] - -//! [95] - QScriptEngine engine; - QScriptValue xmlStreamReaderProto = engine.newObject(); - xmlStreamReaderProto.setProperty("atEnd", engine.newFunction(xmlStreamReader_atEnd)); - - QScriptValue xmlStreamReaderCtor = engine.newFunction(constructXmlStreamReader, xmlStreamReaderProto); - engine.globalObject().setProperty("XmlStreamReader", xmlStreamReaderCtor); -//! [95] diff --git a/doc/src/snippets/code/doc_src_qtscriptextensions.qdoc b/doc/src/snippets/code/doc_src_qtscriptextensions.js index 456077d..456077d 100644 --- a/doc/src/snippets/code/doc_src_qtscriptextensions.qdoc +++ b/doc/src/snippets/code/doc_src_qtscriptextensions.js diff --git a/doc/src/snippets/code/doc_src_qtscripttools.cpp b/doc/src/snippets/code/doc_src_qtscripttools.cpp new file mode 100644 index 0000000..258c7df --- /dev/null +++ b/doc/src/snippets/code/doc_src_qtscripttools.cpp @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +//! [0] +#include <QtScriptTools> +//! [0] diff --git a/doc/src/snippets/code/doc_src_qtscripttools.pro b/doc/src/snippets/code/doc_src_qtscripttools.pro new file mode 100644 index 0000000..e87644d --- /dev/null +++ b/doc/src/snippets/code/doc_src_qtscripttools.pro @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +#! [1] +QT += scripttools +#! [1] diff --git a/doc/src/snippets/code/doc_src_qtsql.qdoc b/doc/src/snippets/code/doc_src_qtsql.cpp index 1bc7518..9c0c16e 100644 --- a/doc/src/snippets/code/doc_src_qtsql.qdoc +++ b/doc/src/snippets/code/doc_src_qtsql.cpp @@ -41,8 +41,3 @@ //! [0] #include <QtSql> //! [0] - - -//! [1] -QT += sql -//! [1] diff --git a/doc/src/snippets/code/doc_src_qtsql.pro b/doc/src/snippets/code/doc_src_qtsql.pro new file mode 100644 index 0000000..4e31846 --- /dev/null +++ b/doc/src/snippets/code/doc_src_qtsql.pro @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +#! [1] +QT += sql +#! [1] diff --git a/doc/src/snippets/code/doc_src_qtsvg.qdoc b/doc/src/snippets/code/doc_src_qtsvg.cpp index 57db6de..c66b4da 100644 --- a/doc/src/snippets/code/doc_src_qtsvg.qdoc +++ b/doc/src/snippets/code/doc_src_qtsvg.cpp @@ -41,8 +41,3 @@ //! [0] #include <QtSvg> //! [0] - - -//! [1] -QT += svg -//! [1] diff --git a/doc/src/snippets/code/doc_src_qtsvg.pro b/doc/src/snippets/code/doc_src_qtsvg.pro new file mode 100644 index 0000000..1a75d03 --- /dev/null +++ b/doc/src/snippets/code/doc_src_qtsvg.pro @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +#! [1] +QT += svg +#! [1] diff --git a/doc/src/snippets/code/doc_src_qttest.qdoc b/doc/src/snippets/code/doc_src_qttest.cpp index 354d188..5b21c9e 100644 --- a/doc/src/snippets/code/doc_src_qttest.qdoc +++ b/doc/src/snippets/code/doc_src_qttest.cpp @@ -41,8 +41,3 @@ //! [0] #include <QtTest> //! [0] - - -//! [1] -CONFIG += qtestlib -//! [1] diff --git a/doc/src/snippets/code/doc_src_qttest.pro b/doc/src/snippets/code/doc_src_qttest.pro new file mode 100644 index 0000000..73d210e --- /dev/null +++ b/doc/src/snippets/code/doc_src_qttest.pro @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +#! [1] +CONFIG += qtestlib +#! [1] diff --git a/doc/src/snippets/code/doc_src_qtuiloader.qdoc b/doc/src/snippets/code/doc_src_qtuiloader.cpp index b8d8019..de35e78 100644 --- a/doc/src/snippets/code/doc_src_qtuiloader.qdoc +++ b/doc/src/snippets/code/doc_src_qtuiloader.cpp @@ -38,11 +38,6 @@ ** ****************************************************************************/ -//! [0] -CONFIG += uitools -//! [0] - - //! [1] #include <QtUiTools> //! [1] diff --git a/doc/src/snippets/code/doc_src_qtuiloader.pro b/doc/src/snippets/code/doc_src_qtuiloader.pro new file mode 100644 index 0000000..a050213 --- /dev/null +++ b/doc/src/snippets/code/doc_src_qtuiloader.pro @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +#! [0] +CONFIG += uitools +#! [0] diff --git a/doc/src/snippets/code/doc_src_qtxml.cpp b/doc/src/snippets/code/doc_src_qtxml.cpp new file mode 100644 index 0000000..5413fd2 --- /dev/null +++ b/doc/src/snippets/code/doc_src_qtxml.cpp @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +//! [0] +#include <QtXml> +//! [0] diff --git a/doc/src/snippets/code/doc_src_qtxml.pro b/doc/src/snippets/code/doc_src_qtxml.pro new file mode 100644 index 0000000..d69b2ce --- /dev/null +++ b/doc/src/snippets/code/doc_src_qtxml.pro @@ -0,0 +1,43 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +#! [1] +QT += xml +#! [1] diff --git a/doc/src/snippets/code/doc_src_qtxml.qdoc b/doc/src/snippets/code/doc_src_qtxml.qdoc index 6576815..1e864ea 100644 --- a/doc/src/snippets/code/doc_src_qtxml.qdoc +++ b/doc/src/snippets/code/doc_src_qtxml.qdoc @@ -38,21 +38,6 @@ ** ****************************************************************************/ -//! [0] -#include <QtXml> -//! [0] - - -//! [1] -QT += xml -//! [1] - - -//! [2] -QT += xml -//! [2] - - //! [3] <quote>A quotation.</quote> //! [3] diff --git a/doc/src/snippets/code/doc_src_qtxmlpatterns.cpp b/doc/src/snippets/code/doc_src_qtxmlpatterns.cpp new file mode 100644 index 0000000..2c3235c --- /dev/null +++ b/doc/src/snippets/code/doc_src_qtxmlpatterns.cpp @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + + +//! [0] +#include <QtXmlPatterns> +//! [0] diff --git a/doc/src/snippets/code/doc_src_qtxmlpatterns.pro b/doc/src/snippets/code/doc_src_qtxmlpatterns.pro new file mode 100644 index 0000000..61ee910 --- /dev/null +++ b/doc/src/snippets/code/doc_src_qtxmlpatterns.pro @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + + +#! [1] +QT += xmlpatterns +#! [1] diff --git a/doc/src/snippets/code/doc_src_qtxmlpatterns.qdoc b/doc/src/snippets/code/doc_src_qtxmlpatterns.qdoc index 560cc53..22e2dde 100644 --- a/doc/src/snippets/code/doc_src_qtxmlpatterns.qdoc +++ b/doc/src/snippets/code/doc_src_qtxmlpatterns.qdoc @@ -42,15 +42,6 @@ void wrapInFunction() { -//! [0] -#include <QtXmlPatterns> -//! [0] - - -//! [1] -QT += xmlpatterns -//! [1] - //! [2] xmlpatterns myQuery.xq //! [2] diff --git a/doc/src/snippets/code/doc_src_qvarlengtharray.qdoc b/doc/src/snippets/code/doc_src_qvarlengtharray.cpp index a938330..a938330 100644 --- a/doc/src/snippets/code/doc_src_qvarlengtharray.qdoc +++ b/doc/src/snippets/code/doc_src_qvarlengtharray.cpp diff --git a/doc/src/snippets/declarative/qml-intro/hello-world1.qml b/doc/src/snippets/code/doc_src_resources.cpp index 81ad333..b965cbe 100644 --- a/doc/src/snippets/declarative/qml-intro/hello-world1.qml +++ b/doc/src/snippets/code/doc_src_resources.cpp @@ -38,16 +38,17 @@ ** ****************************************************************************/ -//! [document] -import QtQuick 1.0 +//! [4] +QResource::registerResource("/path/to/myresource.rcc"); +//! [4] -Rectangle { - id: myRectangle - width: 500 - height: 400 - Text { text: "Hello World!" } - - color: "lightgray" +//! [5] +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + Q_INIT_RESOURCE(graphlib); + ... + return app.exec(); } -//! [document] +//! [5] diff --git a/doc/src/snippets/code/doc_src_resources.qdoc b/doc/src/snippets/code/doc_src_resources.qdoc index c524ae7..0b727da 100644 --- a/doc/src/snippets/code/doc_src_resources.qdoc +++ b/doc/src/snippets/code/doc_src_resources.qdoc @@ -63,19 +63,3 @@ //! [3] rcc -binary myresource.qrc -o myresource.rcc //! [3] - - -//! [4] -QResource::registerResource("/path/to/myresource.rcc"); -//! [4] - - -//! [5] -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - Q_INIT_RESOURCE(graphlib); - ... - return app.exec(); -} -//! [5] diff --git a/doc/src/snippets/code/doc_src_richtext.cpp b/doc/src/snippets/code/doc_src_richtext.cpp new file mode 100644 index 0000000..8de5f4c --- /dev/null +++ b/doc/src/snippets/code/doc_src_richtext.cpp @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +//! [0] +QTextDocument *newDocument = new QTextDocument; +//! [0] + + +//! [1] +QTextEdit *editor = new QTextEdit; +QTextDocument *editorDocument = editor->document(); +//! [1] + + +//! [2] +QTextEdit *editor = new QTextEdit(parent); +editor->setHtml(aStringContainingHTMLtext); +editor->show(); +//! [2] + + +//! [3] +QTextDocument *document = editor->document(); +//! [3] + + +//! [4] +QTextCursor cursor = editor->textCursor(); +//! [4] + + +//! [5] +editor->setTextCursor(cursor); +//! [5] + + +//! [6] +textEdit.show(); + +textCursor.beginEditBlock(); + +for (int i = 0; i < 1000; ++i) { + textCursor.insertBlock(); + textCursor.insertText(paragraphText.at(i)); +} + +textCursor.endEditBlock(); +//! [6] diff --git a/doc/src/snippets/code/doc_src_richtext.qdoc b/doc/src/snippets/code/doc_src_richtext.qdoc index e031d77..2b79fdb 100644 --- a/doc/src/snippets/code/doc_src_richtext.qdoc +++ b/doc/src/snippets/code/doc_src_richtext.qdoc @@ -38,53 +38,6 @@ ** ****************************************************************************/ -//! [0] -QTextDocument *newDocument = new QTextDocument; -//! [0] - - -//! [1] -QTextEdit *editor = new QTextEdit; -QTextDocument *editorDocument = editor->document(); -//! [1] - - -//! [2] -QTextEdit *editor = new QTextEdit(parent); -editor->setHtml(aStringContainingHTMLtext); -editor->show(); -//! [2] - - -//! [3] -QTextDocument *document = editor->document(); -//! [3] - - -//! [4] -QTextCursor cursor = editor->textCursor(); -//! [4] - - -//! [5] -editor->setTextCursor(cursor); -//! [5] - - -//! [6] -textEdit.show(); - -textCursor.beginEditBlock(); - -for (int i = 0; i < 1000; ++i) { - textCursor.insertBlock(); - textCursor.insertText(paragraphText.at(i)); -} - -textCursor.endEditBlock(); -//! [6] - - //! [7] <meta http-equiv="Content-Type" content="text/html; charset=EUC-JP" /> //! [7] diff --git a/doc/src/snippets/code/doc_src_sql-driver.cpp b/doc/src/snippets/code/doc_src_sql-driver.cpp new file mode 100644 index 0000000..56e4f9b --- /dev/null +++ b/doc/src/snippets/code/doc_src_sql-driver.cpp @@ -0,0 +1,82 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +//! [2] +QSqlQuery q; +q.exec("call qtestproc (@outval1, @outval2)"); +q.exec("select @outval1, @outval2"); +q.next(); +qDebug() << q.value(0) << q.value(1); // outputs "42" and "43" +//! [2] + + +//! [10] +// STORED_PROC uses the return statement or returns multiple result sets +QSqlQuery query; +query.setForwardOnly(true); +query.exec("{call STORED_PROC}"); +//! [10] + + +//! [24] +db.setHostName("MyServer"); +db.setDatabaseName("C:\\test.gdb"); +//! [24] + + +//! [25] +// connect to database using the Latin-1 character set +db.setConnectOptions("ISC_DPB_LC_CTYPE=Latin1"); +db.open(); +//! [25] + + +//! [26] +QSqlQuery q; +q.exec("execute procedure my_procedure"); +q.next(); +qDebug() << q.value(0); // outputs the first RETURN/OUT value +//! [26] + + +//! [31] +QSqlDatabase: QMYSQL driver not loaded +QSqlDatabase: available drivers: QMYSQL +//! [31] diff --git a/doc/src/snippets/code/doc_src_sql-driver.qdoc b/doc/src/snippets/code/doc_src_sql-driver.qdoc index 482e38c..46cd1b3 100644 --- a/doc/src/snippets/code/doc_src_sql-driver.qdoc +++ b/doc/src/snippets/code/doc_src_sql-driver.qdoc @@ -59,15 +59,6 @@ END //! [1] -//! [2] -QSqlQuery q; -q.exec("call qtestproc (@outval1, @outval2)"); -q.exec("select @outval1, @outval2"); -q.next(); -qDebug() << q.value(0) << q.value(1); // outputs "42" and "43" -//! [2] - - //! [3] cd $QTDIR/src/plugins/sqldrivers/mysql qmake "INCLUDEPATH+=/usr/local/include" "LIBS+=-L/usr/local/lib -lmysqlclient_r" mysql.pro @@ -116,14 +107,6 @@ set PATH=%PATH%;c:\oracle\bin //! [9] -//! [10] -\\ STORED_PROC uses the return statement or returns multiple result sets -QSqlQuery query; -query.setForwardOnly(true); -query.exec("{call STORED_PROC}"); -//! [10] - - //! [11] cd $QTDIR/src/plugins/sqldrivers/odbc qmake "INCLUDEPATH+=/usr/local/unixODBC/include" "LIBS+=-L/usr/local/unixODBC/lib -lodbc" @@ -212,27 +195,6 @@ nmake //! [23] -//! [24] -db.setHostName("MyServer"); -db.setDatabaseName("C:\\test.gdb"); -//! [24] - - -//! [25] -// connect to database using the Latin-1 character set -db.setConnectOptions("ISC_DPB_LC_CTYPE=Latin1"); -db.open(); -//! [25] - - -//! [26] -QSqlQuery q; -q.exec("execute procedure my_procedure"); -q.next(); -qDebug() << q.value(0); // outputs the first RETURN/OUT value -//! [26] - - //! [27] cd $QTDIR/src/plugins/sqldrivers/ibase qmake "INCLUDEPATH+=/opt/interbase/include" "LIBS+=-L/opt/interbase/lib" ibase.pro @@ -261,11 +223,6 @@ nmake //! [30] -//! [31] -QSqlDatabase: QMYSQL driver not loaded -QSqlDatabase: available drivers: QMYSQL -//! [31] - //! [32] configure -I /usr/include/oracle/10.1.0.3/client -L /usr/lib/oracle/10.1.0.3/client/lib -R /usr/lib/oracle/10.1.0.3/client/lib -lclntsh -lnnz10 make @@ -276,4 +233,3 @@ cd $QTDIR/src/plugins/sqldrivers/oci qmake "INCLUDEPATH+=/usr/include/oracle/10.1.0.3/client" "LIBS+=-L/usr/lib/oracle/10.1.0.3/client/lib -Wl,-rpath,/usr/lib/oracle/10.1.0.3/client/lib -lclntsh -lnnz10" oci.pro make //! [33] - diff --git a/doc/src/snippets/code/doc_src_styles.qdoc b/doc/src/snippets/code/doc_src_styles.cpp index a2a6fa9..a2a6fa9 100644 --- a/doc/src/snippets/code/doc_src_styles.qdoc +++ b/doc/src/snippets/code/doc_src_styles.cpp diff --git a/doc/src/snippets/code/doc_src_stylesheet.cpp b/doc/src/snippets/code/doc_src_stylesheet.cpp new file mode 100644 index 0000000..3faaf2d --- /dev/null +++ b/doc/src/snippets/code/doc_src_stylesheet.cpp @@ -0,0 +1,140 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +//! [21] +qApp->setStyleSheet("QPushButton { color: white }"); +//! [21] + + +//! [22] +myPushButton->setStyleSheet("* { color: blue }"); +//! [22] + + +//! [23] +myPushButton->setStyleSheet("color: blue"); +//! [23] + + +//! [24] +qApp->setStyleSheet("QGroupBox { color: red; } "); +//! [24] + +//! [25] +qApp->setStyleSheet("QGroupBox, QGroupBox * { color: red; }"); +//! [25] + + +//! [26] +class MyPushButton : public QPushButton { + // ... +} + +// ... +qApp->setStyleSheet("MyPushButton { background: yellow; }"); +//! [26] + + +//! [27] +namespace ns { + class MyPushButton : public QPushButton { + // ... + } +} + +// ... +qApp->setStyleSheet("ns--MyPushButton { background: yellow; }"); +//! [27] + + +//! [32] +void CustomWidget::paintEvent(QPaintEvent *) +{ + QStyleOption opt; + opt.init(this); + QPainter p(this); + style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); +} +//! [32] + + +//! [88] +qApp->setStyleSheet("QLineEdit { background-color: yellow }"); +//! [88] + + +//! [89] +myDialog->setStyleSheet("QLineEdit { background-color: yellow }"); +//! [89] + + +//! [90] +myDialog->setStyleSheet("QLineEdit#nameEdit { background-color: yellow }"); +//! [90] + + +//! [91] +nameEdit->setStyleSheet("background-color: yellow"); +//! [91] + + +//! [92] +nameEdit->setStyleSheet("color: blue; background-color: yellow"); +//! [92] + + +//! [93] +nameEdit->setStyleSheet("color: blue;" + "background-color: yellow;" + "selection-color: yellow;" + "selection-background-color: blue;"); +//! [93] + + +//! [95] +QLineEdit *nameEdit = new QLineEdit(this); +nameEdit->setProperty("mandatoryField", true); + +QLineEdit *emailEdit = new QLineEdit(this); +emailEdit->setProperty("mandatoryField", true); + +QSpinBox *ageSpinBox = new QSpinBox(this); +ageSpinBox->setProperty("mandatoryField", true); +//! [95] diff --git a/doc/src/snippets/code/doc_src_stylesheet.qdoc b/doc/src/snippets/code/doc_src_stylesheet.qdoc index 9b8a3b5..99b31c9 100644 --- a/doc/src/snippets/code/doc_src_stylesheet.qdoc +++ b/doc/src/snippets/code/doc_src_stylesheet.qdoc @@ -170,53 +170,6 @@ LI.red.level {} /* a=0 b=2 c=1 -> specificity = 21 */ //! [20] -//! [21] -qApp->setStyleSheet("QPushButton { color: white }"); -//! [21] - - -//! [22] -myPushButton->setStyleSheet("* { color: blue }"); -//! [22] - - -//! [23] -myPushButton->setStyleSheet("color: blue"); -//! [23] - - -//! [24] -qApp->setStyleSheet("QGroupBox { color: red; } "); -//! [24] - - -//! [25] -qApp->setStyleSheet("QGroupBox, QGroupBox * { color: red; }"); -//! [25] - - -//! [26] -class MyPushButton : public QPushButton { - // ... -} - -// ... -qApp->setStyleSheet("MyPushButton { background: yellow; }"); -//! [26] - - -//! [27] -namespace ns { - class MyPushButton : public QPushButton { - // ... - } -} - -// ... -qApp->setStyleSheet("ns--MyPushButton { background: yellow; }"); -//! [27] - - //! [28] MyLabel { qproperty-pixmap: url(pixmap.png); } MyGroupBox { qproperty-titleColor: rgb(100, 200, 100); } @@ -234,17 +187,6 @@ QToolButton { background-color: red; border: none; } //! [31] -//! [32] -void CustomWidget::paintEvent(QPaintEvent *) -{ - QStyleOption opt; - opt.init(this); - QPainter p(this); - style()->drawPrimitive(QStyle::PE_Widget, &opt, &p, this); -} -//! [32] - - //! [33] QTreeView { alternate-background-color: blue; @@ -617,56 +559,11 @@ QPushButton { color: palette(dark); } //! [87] -//! [88] -qApp->setStyleSheet("QLineEdit { background-color: yellow }"); -//! [88] - - -//! [89] -myDialog->setStyleSheet("QLineEdit { background-color: yellow }"); -//! [89] - - -//! [90] -myDialog->setStyleSheet("QLineEdit#nameEdit { background-color: yellow }"); -//! [90] - - -//! [91] -nameEdit->setStyleSheet("background-color: yellow"); -//! [91] - - -//! [92] -nameEdit->setStyleSheet("color: blue; background-color: yellow"); -//! [92] - - -//! [93] -nameEdit->setStyleSheet("color: blue;" - "background-color: yellow;" - "selection-color: yellow;" - "selection-background-color: blue;"); -//! [93] - - //! [94] *[mandatoryField="true"] { background-color: yellow } //! [94] -//! [95] -QLineEdit *nameEdit = new QLineEdit(this); -nameEdit->setProperty("mandatoryField", true); - -QLineEdit *emailEdit = new QLineEdit(this); -emailEdit->setProperty("mandatoryField", true); - -QSpinBox *ageSpinBox = new QSpinBox(this); -ageSpinBox->setProperty("mandatoryField", true); -//! [95] - - //! [96] QPushButton#evilButton { background-color: red } //! [96] diff --git a/doc/src/snippets/code/doc_src_unicode.qdoc b/doc/src/snippets/code/doc_src_unicode.cpp index 4415cf2..4415cf2 100644 --- a/doc/src/snippets/code/doc_src_unicode.qdoc +++ b/doc/src/snippets/code/doc_src_unicode.cpp diff --git a/doc/src/snippets/code/doc_src_unix-signal-handlers.qdoc b/doc/src/snippets/code/doc_src_unix-signal-handlers.cpp index fd5f386..fd5f386 100644 --- a/doc/src/snippets/code/doc_src_unix-signal-handlers.qdoc +++ b/doc/src/snippets/code/doc_src_unix-signal-handlers.cpp diff --git a/doc/src/snippets/declarative/animation-signalhandler.qml b/doc/src/snippets/code/doc_src_wince-customization.cpp index 416417f..90c2207 100644 --- a/doc/src/snippets/declarative/animation-signalhandler.qml +++ b/doc/src/snippets/code/doc_src_wince-customization.cpp @@ -37,19 +37,22 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -//![0] -import QtQuick 1.0 -Rectangle { - id: rect - width: 100; height: 100 - color: "red" +//! [9] +wchar_t* libraries[] = { + L"QtCore4.dll", + L"QtGui4.dll", + 0 +}; - MouseArea { - anchors.fill: parent - onClicked: PropertyAnimation { target: rect; properties: "x,y"; to: 50; duration: 1000 } +for (int i = 0; libraries[i] != 0; ++i) { + HINSTANCE instance = LoadLibraryW(libraries[i]); + OutputDebugStringW(libraries[i]); + if (instance != NULL) { + OutputDebugStringW(L" : Successfully instantiated\n"); + FreeLibrary(instance); + } else { + OutputDebugStringW(L" : Could not be loaded\n"); } } - -//![0] - +//! [9] diff --git a/doc/src/snippets/code/doc_src_wince-customization.qdoc b/doc/src/snippets/code/doc_src_wince-customization.qdoc index 657786f..ab09222 100644 --- a/doc/src/snippets/code/doc_src_wince-customization.qdoc +++ b/doc/src/snippets/code/doc_src_wince-customization.qdoc @@ -89,22 +89,3 @@ if(equals(TEMPLATE_PREFIX, "vc") | equals(TEMPLATE, "vc*")) { DEFINES -= _M_ARM } //! [8] - -//! [9] -wchar_t* libraries[] = { - L"QtCore4.dll", - L"QtGui4.dll", - 0 -}; - -for (int i = 0; libraries[i] != 0; ++i) { - HINSTANCE instance = LoadLibraryW(libraries[i]); - OutputDebugStringW(libraries[i]); - if (instance != NULL) { - OutputDebugStringW(L" : Successfully instantiated\n"); - FreeLibrary(instance); - } else { - OutputDebugStringW(L" : Could not be loaded\n"); - } -} -//! [9] diff --git a/doc/src/snippets/code/src_corelib_kernel_qmetaobject.cpp b/doc/src/snippets/code/src_corelib_kernel_qmetaobject.cpp index 7a752b1..86bad5e 100644 --- a/doc/src/snippets/code/src_corelib_kernel_qmetaobject.cpp +++ b/doc/src/snippets/code/src_corelib_kernel_qmetaobject.cpp @@ -43,7 +43,7 @@ void wrapInFunction() { //! [0] -class MyClass +class MyClass : public QObject { Q_OBJECT Q_CLASSINFO("author", "Sabrina Schweinsteiger") diff --git a/doc/src/snippets/code/src_gui_painting_qpen.cpp b/doc/src/snippets/code/src_gui_painting_qpen.cpp index 6973e0c..8674516 100644 --- a/doc/src/snippets/code/src_gui_painting_qpen.cpp +++ b/doc/src/snippets/code/src_gui_painting_qpen.cpp @@ -47,7 +47,7 @@ painter.setPen(pen); //! [1] QPainter painter(this); -QPen pen(); // creates a default pen +QPen pen; // creates a default pen pen.setStyle(Qt::DashDotLine); pen.setWidth(3); diff --git a/doc/src/snippets/declarative/qml-intro/anchors2.qml b/doc/src/snippets/declarative/Button.qml index 2c4ce11..214dfea 100644 --- a/doc/src/snippets/declarative/qml-intro/anchors2.qml +++ b/doc/src/snippets/declarative/Button.qml @@ -41,18 +41,27 @@ //! [document] import QtQuick 1.0 +//! [parent begin] Rectangle { - id: myWin - width: 500 - height: 400 - - Image { - id: image1 - source: "images/qt-logo.svg" - width: 150; height: 150 - anchors.bottom: myWin.bottom - anchors.horizontalCenter: myWin.horizontalCenter - anchors.bottomMargin: 10 - } +//! [parent begin] + +//! [property alias] +property alias buttonLabel: label.text +Text { + id: label + text: "empty label" +} + //! [property alias] + +//! [id alias] + property alias buttonImage: image + + Image {id: image} +//! [id alias] +//! [parent end] } +//! [parent end] + //! [document] + + diff --git a/doc/src/snippets/declarative/animation-elements.qml b/doc/src/snippets/declarative/animation-elements.qml deleted file mode 100644 index d9bfc28..0000000 --- a/doc/src/snippets/declarative/animation-elements.qml +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 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$ -** -****************************************************************************/ -//![0] -import QtQuick 1.0 - -Row { - -//![color] -Rectangle { - width: 100; height: 100 - - ColorAnimation on color { from: "red"; to: "yellow"; duration: 1000 } -} -//![color] - -//![rotation] -Item { - width: 300; height: 300 - - Rectangle { - width: 100; height: 100; anchors.centerIn: parent - color: "red" - - RotationAnimation on rotation { to: 90; direction: RotationAnimation.Clockwise } - } -} -//![rotation] - -} diff --git a/doc/src/snippets/declarative/animation-groups.qml b/doc/src/snippets/declarative/animation-groups.qml deleted file mode 100644 index f29ea48..0000000 --- a/doc/src/snippets/declarative/animation-groups.qml +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 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 - -Row { - -//![0] -Rectangle { - id: rect - width: 120; height: 200 - - Image { - id: img - source: "pics/qt.png" - anchors.horizontalCenter: parent.horizontalCenter - y: 0 - - SequentialAnimation on y { - loops: Animation.Infinite - NumberAnimation { to: rect.height - img.height; easing.type: Easing.OutBounce; duration: 2000 } - PauseAnimation { duration: 1000 } - NumberAnimation { to: 0; easing.type: Easing.OutQuad; duration: 1000 } - } - } -} -//![0] - -//![1] -Rectangle { - id: redRect - width: 100; height: 100 - color: "red" - - MouseArea { id: mouseArea; anchors.fill: parent } - - states: State { - name: "pressed"; when: mouseArea.pressed - PropertyChanges { target: redRect; color: "blue"; y: mouseArea.mouseY; width: mouseArea.mouseX } - } - - transitions: Transition { - - SequentialAnimation { - ColorAnimation { duration: 200 } - PauseAnimation { duration: 100 } - - ParallelAnimation { - NumberAnimation { - duration: 500 - easing.type: Easing.OutBounce - targets: redRect - properties: "y" - } - - NumberAnimation { - duration: 800 - easing.type: Easing.InOutQuad - targets: redRect - properties: "width" - } - } - } - } -} -//![1] - -} diff --git a/doc/src/snippets/declarative/animation-propertyvaluesource.qml b/doc/src/snippets/declarative/animation-propertyvaluesource.qml deleted file mode 100644 index 6f93967..0000000 --- a/doc/src/snippets/declarative/animation-propertyvaluesource.qml +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 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$ -** -****************************************************************************/ -//![0] -import QtQuick 1.0 - -Rectangle { - width: 100; height: 100 - color: "red" - - PropertyAnimation on x { to: 50; duration: 1000; loops: Animation.Infinite } - PropertyAnimation on y { to: 50; duration: 1000; loops: Animation.Infinite } -} -//![0] - diff --git a/doc/src/snippets/declarative/animation.qml b/doc/src/snippets/declarative/animation.qml new file mode 100644 index 0000000..ae6142d --- /dev/null +++ b/doc/src/snippets/declarative/animation.qml @@ -0,0 +1,226 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ +//! [document] +import QtQuick 1.0 + + +//! [parent begin] +Rectangle { +//! [parent begin] + width: 200; height: 600 + id: screen + +Column { + spacing: 12 +//! [direct property change] +Rectangle { + id: blob + width: 75; height: 75 + color: "blue" + + MouseArea { + anchors.fill: parent + onClicked: blob.color = "green" + } +} +//! [direct property change] + +//! [property animation] +Rectangle { + id: flashingblob + width: 75; height: 75 + color: "blue" + opacity: 1.0 + + MouseArea { + anchors.fill: parent + onClicked: { + animateColor.start() + animateOpacity.start() + } + } + + PropertyAnimation {id: animateColor; target: flashingblob; properties: "color"; to: "green"; duration: 100} + + NumberAnimation { + id: animateOpacity + target: flashingblob + properties: "opacity" + from: 0.99 + to: 1.0 + loops: Animation.Infinite + easing {type: Easing.OutBack; overshoot: 500} + } +} +//! [property animation] + +//! [transition animation] +Rectangle { + width: 75; height: 75 + id: button + state: "RELEASED" + + MouseArea { + anchors.fill: parent + onPressed: button.state = "PRESSED" + onReleased: button.state = "RELEASED" + } + + states: [ + State { + name: "PRESSED" + PropertyChanges { target: button; color: "lightblue"} + }, + State { + name: "RELEASED" + PropertyChanges { target: button; color: "lightsteelblue"} + } + ] + + transitions: [ + Transition { + from: "PRESSED" + to: "RELEASED" + ColorAnimation { target: button; duration: 100} + }, + Transition { + from: "RELEASED" + to: "PRESSED" + ColorAnimation { target: button; duration: 100} + } + ] +} +//! [transition animation] + +Rectangle { + width: 75; height: 75 + id: wildcard + color: "green" +//! [wildcard animation] + transitions: + Transition { + to: "*" + ColorAnimation { target: button; duration: 100} + } +//! [wildcard animation] + + MouseArea { + anchors.fill: parent + onPressed: { + ball.x = 10 + ball.color = "red" + } + onReleased: { + ball.x = screen.width / 2 + ball.color = "salmon" + } + } +} + +//! [behavior animation] +Rectangle { + width: 75; height: 75; radius: width + id: ball + color: "salmon" + + Behavior on x { + NumberAnimation { + id: bouncebehavior + easing { + type: Easing.OutElastic + amplitude: 1.0 + period: 0.5 + } + } + } + Behavior on y { + animation: bouncebehavior + } + Behavior { + ColorAnimation { target: ball; duration: 100 } + } +} +//! [behavior animation] + +//! [sequential animation] +Rectangle { + id: banner + width: 150; height: 100; border.color: "black" + + Column { + anchors.centerIn: parent + Text { + id: code + text: "Code less." + opacity: 0.01 + } + Text { + id: create + text: "Create more." + opacity: 0.01 + } + Text { + id: deploy + text: "Deploy everywhere." + opacity: 0.01 + } + } + + MouseArea { + anchors.fill: parent + onPressed: playbanner.start() + } + + SequentialAnimation { + id: playbanner + running: false + NumberAnimation { target: code; property: "opacity"; to: 1.0; duration: 200} + NumberAnimation { target: create; property: "opacity"; to: 1.0; duration: 200} + NumberAnimation { target: deploy; property: "opacity"; to: 1.0; duration: 200} + } +} +//! [sequential animation] + +}//end of col +//! [parent end] +} +//! [parent end] + +//! [document] diff --git a/doc/src/snippets/declarative/animation-easing.qml b/doc/src/snippets/declarative/bestpractices/group.qml index 64ba44c..8a2b398 100644 --- a/doc/src/snippets/declarative/animation-easing.qml +++ b/doc/src/snippets/declarative/bestpractices/group.qml @@ -37,15 +37,40 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -//![0] + + +//! [document] import QtQuick 1.0 +//! [parent begin] +Rectangle { +//! [parent begin] + width: 175; height: 175; color: "white" + +Rectangle{ +width: 170; height: 170 +//! [not grouped] +border.width: 1 +border.color: "red" +anchors.bottom: parent.bottom +anchors.left: parent.left +//! [not grouped] +} Rectangle { width: 100; height: 100 + +//! [grouped] +border { + width: 1; color: "red" - - PropertyAnimation on x { to: 50; duration: 1000; easing.type: Easing.OutBounce } - PropertyAnimation on y { to: 50; duration: 1000; easing.type: Easing.OutBounce } } -//![0] - +anchors { + bottom: parent.bottom; + left: parent.left +} +//! [grouped] +} +//! [parent end] +} +//! [parent end] +//! [document] diff --git a/doc/src/snippets/declarative/events.qml b/doc/src/snippets/declarative/events.qml new file mode 100644 index 0000000..3dc44f2 --- /dev/null +++ b/doc/src/snippets/declarative/events.qml @@ -0,0 +1,141 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ +//![document] +import QtQuick 1.0 + +//![parent begin] +Rectangle { +//![parent begin] + + id: screen + width: 400; height: 500 + +//! [signal declaration] + signal trigger + signal send (string notice) + signal perform (string task, variant object) +//! [signal declaration] + +//! [signal handler declaration] +onTrigger: console.log("trigger signal emitted") + +onSend: { + console.log("send signal emitted with notice: " + notice) +} + +onPerform: console.log("perform signal emitted") +//! [signal handler declaration] + +//! [automatic signals] +Rectangle { + id: sprite + width: 25; height: 25 + x: 50; y: 15 + + onXChanged: console.log("x property changed, emitted xChanged signal") + onYChanged: console.log("y property changed, emitted yChanged signal") +} +//! [automatic signals] + +//! [signal emit] +Rectangle { + id: messenger + + signal send( string person, string notice) + + onSend: { + console.log("For " + person + ", the notice is: " + notice) + } + + Component.onCompleted: messenger.send("Tom", "the door is ajar.") +} +//! [signal emit] + +//! [connect method] +Rectangle { + id: relay + + signal send( string person, string notice) + onSend: console.log("Send signal to: " + person + ", " + notice) + + Component.onCompleted: { + relay.send.connect(sendToPost) + relay.send.connect(sendToTelegraph) + relay.send.connect(sendToEmail) + relay.send("Tom", "Happy Birthday") + } + + function sendToPost(person, notice) { + console.log("Sending to post: " + person + ", " + notice) + } + function sendToTelegraph(person, notice) { + console.log("Sending to telegraph: " + person + ", " + notice) + } + function sendToEmail(person, notice) { + console.log("Sending to email: " + person + ", " + notice) + } +} +//! [connect method] + +//! [forward signal] +Rectangle { + id: forwarder + width: 100; height: 100 + + signal send() + onSend: console.log("Send clicked") + + MouseArea { + id: mousearea + anchors.fill: parent + onClicked: console.log("MouseArea clicked") + } + Component.onCompleted: { + mousearea.clicked.connect(send) + } +} +//! [forward signal] + +//! [connect method] +//![parent end] +} +//![parent end] + +//![document] diff --git a/doc/src/snippets/declarative/focus/advancedFocus.qml b/doc/src/snippets/declarative/focus/advancedFocus.qml index fda37c1..409663b 100644 --- a/doc/src/snippets/declarative/focus/advancedFocus.qml +++ b/doc/src/snippets/declarative/focus/advancedFocus.qml @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the FOO module of the Qt Toolkit. +** 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: diff --git a/doc/src/snippets/declarative/focus/basicwidget.qml b/doc/src/snippets/declarative/focus/basicwidget.qml index b74c1cd..bf834b4 100644 --- a/doc/src/snippets/declarative/focus/basicwidget.qml +++ b/doc/src/snippets/declarative/focus/basicwidget.qml @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the FOO module of the Qt Toolkit. +** 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: diff --git a/doc/src/snippets/declarative/focus/focusscopewidget.qml b/doc/src/snippets/declarative/focus/focusscopewidget.qml index 7421a63..6a97512 100644 --- a/doc/src/snippets/declarative/focus/focusscopewidget.qml +++ b/doc/src/snippets/declarative/focus/focusscopewidget.qml @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the FOO module of the Qt Toolkit. +** 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: @@ -37,6 +37,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ +//! [document] import QtQuick 1.0 //! [focusscope window] @@ -59,3 +60,4 @@ Rectangle { } //! [focusscope window] +//! [document] diff --git a/doc/src/snippets/declarative/focus/myclickablewidget.qml b/doc/src/snippets/declarative/focus/myclickablewidget.qml index 4777dd1..30b1c69 100644 --- a/doc/src/snippets/declarative/focus/myclickablewidget.qml +++ b/doc/src/snippets/declarative/focus/myclickablewidget.qml @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the FOO module of the Qt Toolkit. +** 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: diff --git a/doc/src/snippets/declarative/focus/myfocusscopewidget.qml b/doc/src/snippets/declarative/focus/myfocusscopewidget.qml index c87a47e..6462301 100644 --- a/doc/src/snippets/declarative/focus/myfocusscopewidget.qml +++ b/doc/src/snippets/declarative/focus/myfocusscopewidget.qml @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the FOO module of the Qt Toolkit. +** 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: @@ -37,12 +37,13 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ +//! [document] import QtQuick 1.0 //! [widget in focusscope] FocusScope { - //FocusScope needs to bind to visual properties of the children + //FocusScope needs to bind to visual properties of the Rectangle property alias color: rectangle.color x: rectangle.x; y: rectangle.y width: rectangle.width; height: rectangle.height @@ -64,3 +65,4 @@ FocusScope { } } //! [widget in focusscope] +//! [document] diff --git a/doc/src/snippets/declarative/focus/mywidget.qml b/doc/src/snippets/declarative/focus/mywidget.qml index 86d2d0f..0cca747 100644 --- a/doc/src/snippets/declarative/focus/mywidget.qml +++ b/doc/src/snippets/declarative/focus/mywidget.qml @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the FOO module of the Qt Toolkit. +** 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: @@ -37,10 +37,10 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ +//! [document] import QtQuick 1.0 //! [mywidget] -//MyWidget code Rectangle { id: widget color: "lightsteelblue"; width: 175; height: 25; radius: 10; smooth: true diff --git a/doc/src/snippets/declarative/focus/widget.qml b/doc/src/snippets/declarative/focus/widget.qml index a5053d9..a3a726e 100644 --- a/doc/src/snippets/declarative/focus/widget.qml +++ b/doc/src/snippets/declarative/focus/widget.qml @@ -4,7 +4,7 @@ ** All rights reserved. ** Contact: Nokia Corporation (qt-info@nokia.com) ** -** This file is part of the FOO module of the Qt Toolkit. +** 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: diff --git a/doc/src/snippets/declarative/grid/grid-spacing.qml b/doc/src/snippets/declarative/grid-spacing.qml index 8914ce3..8914ce3 100644 --- a/doc/src/snippets/declarative/grid/grid-spacing.qml +++ b/doc/src/snippets/declarative/grid-spacing.qml diff --git a/doc/src/snippets/declarative/grid/grid-items.qml b/doc/src/snippets/declarative/grid/grid-items.qml deleted file mode 100644 index 3c60d12..0000000 --- a/doc/src/snippets/declarative/grid/grid-items.qml +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 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 - -Rectangle { - width: 112; height: 112 - color: "#303030" - - Grid { - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - columns: 2 - spacing: 6 - - Rectangle { color: "#aa6666"; width: 50; height: 50 } - Rectangle { color: "#aaaa66"; width: 50; height: 50 } - Rectangle { color: "#9999aa"; width: 50; height: 50 } - Rectangle { color: "#6666aa"; width: 50; height: 50 } - } -} diff --git a/doc/src/snippets/declarative/grid/grid-no-spacing.qml b/doc/src/snippets/declarative/grid/grid-no-spacing.qml deleted file mode 100644 index 7c8b0f8..0000000 --- a/doc/src/snippets/declarative/grid/grid-no-spacing.qml +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 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 - -Rectangle { - width: 112; height: 112 - color: "#303030" - - Grid { - anchors.horizontalCenter: parent.horizontalCenter - anchors.verticalCenter: parent.verticalCenter - columns: 2 - - Rectangle { color: "#aa6666"; width: 50; height: 50 } - Rectangle { color: "#aaaa66"; width: 50; height: 50 } - Rectangle { color: "#9999aa"; width: 50; height: 50 } - Rectangle { color: "#6666aa"; width: 50; height: 50 } - } -} diff --git a/doc/src/snippets/code/doc_src_phonon.qdoc b/doc/src/snippets/declarative/imports/best-practices.qml index 61ee189..17e5b7a 100644 --- a/doc/src/snippets/code/doc_src_phonon.qdoc +++ b/doc/src/snippets/declarative/imports/best-practices.qml @@ -38,16 +38,12 @@ ** ****************************************************************************/ -//! [0] -QT += phonon -//! [0] +//! [imports] +import QtQuick 1.0 +import QtWebKit 1.0 +import "subdirectory" +import "script.js" +//! [imports] - -//! [1] -QT += phonon -//! [1] - - -//! [2] -#include <Phonon/MediaObject> -//! [2] +Item { +} diff --git a/doc/src/snippets/declarative/imports/chart.qml b/doc/src/snippets/declarative/imports/chart.qml new file mode 100644 index 0000000..6de02c1 --- /dev/null +++ b/doc/src/snippets/declarative/imports/chart.qml @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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] +import Charts 1.0 +//! [import] + +Item { +} diff --git a/doc/src/snippets/declarative/imports/installed-module.qml b/doc/src/snippets/declarative/imports/installed-module.qml new file mode 100644 index 0000000..288bdd3 --- /dev/null +++ b/doc/src/snippets/declarative/imports/installed-module.qml @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +//! [imports] +import QtQuick 1.0 +import com.nokia.qml.mymodule 1.0 +//! [imports] + +Item { +} diff --git a/doc/src/snippets/code/doc.src.qtscripttools.qdoc b/doc/src/snippets/declarative/imports/merged-named-imports.qml index 76840b3..366e76e 100644 --- a/doc/src/snippets/code/doc.src.qtscripttools.qdoc +++ b/doc/src/snippets/declarative/imports/merged-named-imports.qml @@ -38,11 +38,10 @@ ** ****************************************************************************/ -//! [0] - #include <QtScriptTools> -//! [0] +//! [imports] +import QtQuick 1.0 as Nokia +import Ovi 1.0 as Nokia +//! [imports] - -//! [1] - QT += scripttools -//! [1] +Item { +} diff --git a/doc/src/snippets/declarative/qml-intro/hello-world4.qml b/doc/src/snippets/declarative/imports/named-imports.qml index 832e37d..a8fa743 100644 --- a/doc/src/snippets/declarative/qml-intro/hello-world4.qml +++ b/doc/src/snippets/declarative/imports/named-imports.qml @@ -38,24 +38,24 @@ ** ****************************************************************************/ -import QtQuick 1.0 +//! [imports] +import QtQuick 1.0 as QtLibrary +import "../MyComponents" as MyComponents +import com.nokia.qml.mymodule 1.0 as MyModule +//! [imports] -Rectangle { - id: myRectangle - width: 500 - height: 400 - - Text { - text: "<h1>Hello world again</h1>" - color: "#002288" - x: 100; y: 100 +Item { + //! [imported items] + QtLibrary.Rectangle { + // ... } -//! [added an image] - Image { - source: "images/qt-logo.svg" + MyComponents.Slider { + // ... } -//! [added an image] - color: "lightgray" + MyModule.SomeComponent { + // ... + } + //! [imported items] } diff --git a/doc/src/snippets/declarative/imports/network-imports.qml b/doc/src/snippets/declarative/imports/network-imports.qml new file mode 100644 index 0000000..54e177a --- /dev/null +++ b/doc/src/snippets/declarative/imports/network-imports.qml @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ + +//! [imports] +import "http://www.my-server.com/MyQMLProject/MyComponents" +import "http://www.my-server.com/MyQMLProject/MyComponents" 1.0 +//! [imports] + +Item { +} diff --git a/doc/src/snippets/declarative/imports/qtquick-1.0.qml b/doc/src/snippets/declarative/imports/qtquick-1.0.qml new file mode 100644 index 0000000..e2a642d --- /dev/null +++ b/doc/src/snippets/declarative/imports/qtquick-1.0.qml @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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] +import QtQuick 1.0 +//! [import] + +Item { +} diff --git a/doc/src/snippets/declarative/imports/timeexample.qml b/doc/src/snippets/declarative/imports/timeexample.qml new file mode 100644 index 0000000..24eafd7 --- /dev/null +++ b/doc/src/snippets/declarative/imports/timeexample.qml @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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] +import com.nokia.TimeExample 1.0 +//! [import] + +Item { +} diff --git a/doc/src/snippets/declarative/qml-intro/transformations1.qml b/doc/src/snippets/declarative/listview-decorations.qml index 7be79c8..9ba9b70 100644 --- a/doc/src/snippets/declarative/qml-intro/transformations1.qml +++ b/doc/src/snippets/declarative/listview-decorations.qml @@ -41,40 +41,71 @@ //! [document] import QtQuick 1.0 +//! [parent begin] Rectangle { - id: myWin - width: 500 - height: 400 +//! [parent begin] + width: 550; height: 220; color: "white" - Image { - id: image1 - source: "images/qt-logo.svg" - width: 150; height: 150 - anchors.bottom: myWin.bottom - anchors.horizontalCenter: myWin.horizontalCenter - anchors.bottomMargin: 10 - - transform: Rotation { - origin.x: 75; origin.y: 75 - axis{ x: 0; y: 0; z:1 } angle: -90 - } - - } +//! [model] +ListModel { + id: nameModel + ListElement { name: "Alice" } + ListElement { name: "Bob" } + ListElement { name: "Jane" } + ListElement { name: "Harry" } + ListElement { name: "Wendy" } +} +//! [model] +//! [delegate] +Component { + id: nameDelegate Text { - text: "<h2>The Qt Logo -- taking it easy</h2>" - anchors.bottom: image1.top - anchors.horizontalCenter: myWin.horizontalCenter - anchors.bottomMargin: 15 + text: name; + font.pixelSize: 24 + } +} +//! [delegate] - transform: [ - Scale { xScale: 1.5; yScale: 1.2 } , +//! [decorations] +ListView { + anchors.fill: parent + clip: true + model: nameModel + delegate: nameDelegate + header: bannercomponent + footer: Rectangle { + width: parent.width; height: 30; + gradient: clubcolors + } + highlight: Rectangle { + width: parent.width + color: "lightgray" + } +} - Rotation { - origin.x: 75; origin.y: 75 - axis{ x: 0; y: 0; z:1 } angle: -45 - } - ] +Component { //instantiated when header is processed + id: bannercomponent + Rectangle { + id: banner + width: parent.width; height: 50 + gradient: clubcolors + border {color: "#9EDDF2"; width: 2} + Text { + anchors.centerIn: parent + text: "Club Members" + font.pixelSize: 32 + } } } +Gradient { + id: clubcolors + GradientStop { position: 0.0; color: "#8EE2FE"} + GradientStop { position: 0.66; color: "#7ED2EE"} +} +//! [decorations] + +//! [parent end] +} +//! [parent end] //! [document] diff --git a/doc/src/snippets/declarative/qml-intro/states1.qml b/doc/src/snippets/declarative/listview-sections.qml index 270d6c3..74c96dd 100644 --- a/doc/src/snippets/declarative/qml-intro/states1.qml +++ b/doc/src/snippets/declarative/listview-sections.qml @@ -37,58 +37,65 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ - //! [document] import QtQuick 1.0 +//! [parent begin] Rectangle { - id: mainRectangle - width: 600 - height: 400 - color: "black" +//! [parent begin] + width: 150; height: 300; color: "white" - Rectangle { - id: sky - width: 600 - height: 200 - y: 0 - color: "lightblue" - } +//! [model] +ListModel { + id: nameModel + ListElement { name: "Alice"; team: "Crypto" } + ListElement { name: "Bob"; team: "Crypto" } + ListElement { name: "Jane"; team: "QA" } + ListElement { name: "Victor"; team: "QA" } + ListElement { name: "Wendy"; team: "Graphics" } +} +//! [model] - Rectangle { - id: ground - width: 600; height: 200 - y: 200 - color: "green" +//! [delegate] +Component { + id: nameDelegate + Text { + text: name; + font.pixelSize: 24 + anchors.left: parent.left + anchors.leftMargin: 2 } +} +//! [delegate] - MouseArea { - id: mousearea - anchors.fill: mainRectangle +//! [section] +ListView { + anchors.fill: parent + model: nameModel + delegate: nameDelegate + focus: true + highlight: Rectangle { + color: "lightblue" + width: parent.width } - - states: [ State { - name: "night" - when: mousearea.pressed == true - PropertyChanges { target: sky; color: "darkblue" } - PropertyChanges { target: ground; color: "black" } - }, - State { - name: "daylight" - when: mousearea.pressed == false - PropertyChanges { target: sky; color: "lightblue" } - PropertyChanges { target: ground; color: "green" } + section { + property: "team" + criteria: ViewSection.FullString + delegate: Rectangle { + color: "#b0dfb0" + width: parent.width + height: childrenRect.height + 4 + Text { anchors.horizontalCenter: parent.horizontalCenter + font.pixelSize: 16 + font.bold: true + text: section + } } - ] + } +} +//! [section] - transitions: [ Transition { - from: "daylight"; to: "night" - ColorAnimation { duration: 1000 } - }, - Transition { - from: "night"; to: "daylight" - ColorAnimation { duration: 500 } - } - ] +//! [parent end] } +//! [parent end] //! [document] diff --git a/doc/src/snippets/declarative/qml-intro/number-animation1.qml b/doc/src/snippets/declarative/listview.qml index ccf2d36..081d2b0 100644 --- a/doc/src/snippets/declarative/qml-intro/number-animation1.qml +++ b/doc/src/snippets/declarative/listview.qml @@ -41,24 +41,47 @@ //! [document] import QtQuick 1.0 +//! [parent begin] Rectangle { - id: mainRec - width: 600 - height: 400 +//! [parent begin] + width: 175; height: 175; color: "white" - Image { - id: image1 - source: "images/qt-logo.svg" - x: 200; y: 100 - width: 100; height: 100 +//! [model] +ListModel { + id: petlist + ListElement { type: "Cat" } + ListElement { type: "Dog" } + ListElement { type: "Mouse" } + ListElement { type: "Rabbit" } + ListElement { type: "Horse" } +} +//! [model] - // Animate a rotation - transformOrigin: Item.Center - NumberAnimation on rotation { - from: 0; to: 360 - duration: 2000 - loops: Animation.Infinite - } +//! [delegate] +Component { + id: petdelegate + Text { + id: label + font.pixelSize: 24 + text: if (index == 0) + label.text = type + " (default)" + else + text: type } } +//! [delegate] + +//! [view] +ListView { + id: view + anchors.fill: parent + + model: petlist + delegate: petdelegate +} +//! [view] + +//! [parent end] +} +//! [parent end] //! [document] diff --git a/doc/src/snippets/declarative/listview/listview-snippet.qml b/doc/src/snippets/declarative/listview/listview-snippet.qml deleted file mode 100644 index f73dec9..0000000 --- a/doc/src/snippets/declarative/listview/listview-snippet.qml +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 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$ -** -****************************************************************************/ - -//! [document] -import QtQuick 1.0 - -ListView { - width: 50; height: 200 - model: 4 - delegate: Text { - text: index; - font.pixelSize: 40 - } -} -//! [document] diff --git a/doc/src/snippets/declarative/animation-behavioral.qml b/doc/src/snippets/declarative/models/views-models-delegates.qml index 93cf2fa..2f76856 100644 --- a/doc/src/snippets/declarative/animation-behavioral.qml +++ b/doc/src/snippets/declarative/models/views-models-delegates.qml @@ -37,25 +37,42 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -//![0] -import QtQuick 1.0 -Item { - width: 100; height: 100 +//! [rectangle] +Rectangle { + width: 200; height: 200 - Rectangle { - id: rect - width: 100; height: 100 - color: "red" - - Behavior on x { PropertyAnimation { duration: 500 } } - Behavior on y { PropertyAnimation { duration: 500 } } + ListModel { + id: fruitModel + property string language: "en" + ListElement { + name: "Apple" + cost: 2.45 + } + ListElement { + name: "Orange" + cost: 3.25 + } + ListElement { + name: "Banana" + cost: 1.95 + } } - MouseArea { + Component { + id: fruitDelegate + Row { + Text { text: " Fruit: " + name; color: ListView.view.fruit_color } + Text { text: " Cost: $" + cost } + Text { text: " Language: " + ListView.view.model.language } + } + } + + ListView { + property color fruit_color: "green" + model: fruitModel + delegate: fruitDelegate anchors.fill: parent - onClicked: { rect.x = mouse.x; rect.y = mouse.y } } } -//![0] - +//! [rectangle] diff --git a/doc/src/snippets/declarative/animation-transitions.qml b/doc/src/snippets/declarative/models/visual-model-and-view.qml index 62bef23..4d42b65 100644 --- a/doc/src/snippets/declarative/animation-transitions.qml +++ b/doc/src/snippets/declarative/models/visual-model-and-view.qml @@ -37,26 +37,21 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -//![0] -import QtQuick 1.0 Rectangle { - id: rect - width: 100; height: 100 - color: "red" - - MouseArea { - anchors.fill: parent - onClicked: rect.state = "moved" - } - - states: State { - name: "moved" - PropertyChanges { target: rect; x: 50; y: 50 } + width: 200; height: 200 + + //! [visual model and view] + VisualItemModel { + id: itemModel + Rectangle { height: 30; width: 80; color: "red" } + Rectangle { height: 30; width: 80; color: "green" } + Rectangle { height: 30; width: 80; color: "blue" } } - - transitions: Transition { - PropertyAnimation { properties: "x,y"; duration: 1000 } + + ListView { + anchors.fill: parent + model: itemModel } + //! [visual model and view] } -//![0] diff --git a/doc/src/snippets/declarative/mousearea/mousearea-snippet.qml b/doc/src/snippets/declarative/mousearea/mousearea-snippet.qml index 3c2e143..03473ba 100644 --- a/doc/src/snippets/declarative/mousearea/mousearea-snippet.qml +++ b/doc/src/snippets/declarative/mousearea/mousearea-snippet.qml @@ -41,13 +41,60 @@ //! [document] import QtQuick 1.0 -Rectangle { - width: 100; height: 100 +//! [parent begin] +Rectangle { +//! [parent begin] + width: 500; height: 500 color: "green" - MouseArea { +Column { +//! [anchor fill] +Rectangle { + id: button + width: 100; height: 100 + + MouseArea { anchors.fill: parent - onClicked: { parent.color = 'red' } + onClicked: console.log("button clicked") + } + MouseArea { + width:150; height: 75 + onClicked: console.log("irregular area clicked") + } +} +//! [anchor fill] + +Rectangle { + id: button + width: 100; height: 100 + +//! [enable handlers] + MouseArea { + hoverEnabled: true + acceptedButtons: Qt.LeftButton | Qt.RightButton + onEntered: console.log("mouse entered the area") + onExited: console.log("mouse left the area") } +//! [enable handlers] +} + +Rectangle { + id: button + width: 100; height: 100 + +//! [mouse handlers] + MouseArea { + anchors.fill: parent + onClicked: console.log("area clicked") + onDoubleClicked: console.log("area double clicked") + onEntered: console.log("mouse entered the area") + onExited: console.log("mouse left the area") + } +//! [mouse handlers] +} + +} //end of column +//! [parent end] } +//! [parent end] //! [document] diff --git a/doc/src/snippets/declarative/pics/qt.png b/doc/src/snippets/declarative/pics/qt.png Binary files differindex cbed1a9..4f68e16 100644 --- a/doc/src/snippets/declarative/pics/qt.png +++ b/doc/src/snippets/declarative/pics/qt.png diff --git a/doc/src/snippets/declarative/properties.qml b/doc/src/snippets/declarative/properties.qml new file mode 100644 index 0000000..330d1cf --- /dev/null +++ b/doc/src/snippets/declarative/properties.qml @@ -0,0 +1,315 @@ +/**************************************************************************** +** +** 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$ +** +****************************************************************************/ + +//! [document] +import QtQuick 1.0 + +//! [parent begin] +Rectangle { +//! [parent begin] + + //! [inherited properties] + width: 320; height: 240 + color: "lightblue" + focus: true + //! [inherited properties] + + //! [custom properties] + property int counter + property real area: 100.45 + //! [custom properties] + + //! [property types] + property int number + property real volume: 100.45 + property date today: "2011-01-01" + property color background: "yellow" + //! [property types] + + +//! [grouped properties] +Text { + //dot notation + font.pixelSize: 12 + font.bold: true +} + +Text { + //group notation + font {pixelSize: 12; bold: true} +} +//! [grouped properties] + + +//! [property binding] +Rectangle { + width: parent.width +} +//! [property binding] + +//! [property assignment] +Rectangle { + Component.onCompleted: { + width = 150 + } +} +//! [property assignment] + +Rectangle { + //placeholder slider + id: slider + property real value +} +Rectangle { + //placeholder system + id: system + property real brightness +} +//! [binding element] +Binding { + target: system + property: "brightness" + value: slider.value +} +//! [binding element] + +Rectangle { + //placeholder warning + id: warning + color: "red" +} +//! [PropertyChanges element] +Rectangle { + id: rectangle + + states: State { + name: "WARNING" + PropertyChanges { + target: rectangle + color: warning.color + } + } +} +//! [PropertyChanges element] + +//! [list property] +Item { + id: multistate + states: [ + State {name: "FETCH"}, + State {name: "DECODE"}, + State {name: "EXECUTE"} + ] +} +//! [list property] +//! [single property] +Item { + id: monostate + states: State {name: "RUNNING"} +} +//! [single property] + +Item { + id: printstate +//! [print list property] + Component.onCompleted: console.log (multistate.states[0].name) +//! [print list property] +} + +//! [JavaScript sample] +function calculateArea(width, height) { + return (width * height) * 0.5 +} + +Rectangle { + width: 150; height: 75 + property real area: calculateArea(width, height) + property real parentArea: calculateArea(parent.width,parent.height) + color: { if (area > parentArea) "blue"; else "red" } +} +//! [JavaScript sample] + +//! [id property] +Rectangle { + id: container + width: 100; height: 100 + Rectangle { + width: parent.width; height: parent.height + } +} +Rectangle { + width: container.width; height: container.height +} +//! [id property] + +//! [default property] +Item { + Text {} + Rectangle {} + Timer {} +} + +Item { + //without default property + children: [ + Text {}, + Rectangle {} + ] + resources: [ + Timer {} + ] +} +//! [default property] + +//! [state default] +State { + changes: [ + PropertyChanges {}, + PropertyChanges {} + ] +} + +State { + PropertyChanges {} + PropertyChanges {} +} +//! [state default] + +//! [object binding] +Rectangle { + + id: parentrectangle + gradient: + Gradient { //not a child of parentrectangle + + //generates a TypeError + //Component.onCompleted: console.log(parent.width) + } + + //child of parentrectangle + Rectangle {property string name: "childrectangle"} + + //prints "childrectangle" + Component.onCompleted: console.log(children[0].name) +} +//! [object binding] + +//! [list attached property] +Component { + id: listdelegate + Text { + text: "Hello" + color: ListView.isCurrentItem ? "red" : "blue" + } +} +ListView { + delegate: listdelegate +} +//! [list attached property] + +//! [attached signal handler] +Item { + Keys.onPressed: console.log("Key Press Detected") + Component.onCompleted: console.log("Completed initialization") +} +//! [attached signal handler] + +//! [alias usage] +Button { + id: textbutton + buttonLabel: "Click Me!" +} +//! [alias usage] + +//! [image alias] +Button { + id: imagebutton + buttonImage.source: "http://qt.nokia.com/logo.png" + buttonLabel: buttonImage.source +} +//! [image alias] + +Item { +id: widget + +//! [alias complete] +property alias widgetLabel: label + +//will generate an error +//widgetLabel.text: "Initial text" + +//will generate an error +//property alias widgetLabelText: widgetLabel.text + +Component.onCompleted: widgetLabel.text = "Alias completed Initialization" +//! [alias complete] + + Text {id: label} +} + +//![alias overwrite] +Rectangle { + id: coloredrectangle + property alias color: bluerectangle.color + color: "red" + + Rectangle { + id: bluerectangle + color: "#1234ff" + } + + Component.onCompleted: { + console.log (coloredrectangle.color) //prints "#1234ff" + setInternalColor() + console.log (coloredrectangle.color) //prints "#111111" + coloredrectangle.color = "#884646" + console.log (coloredrectangle.color) //prints #884646 + } + + //internal function that has access to internal properties + function setInternalColor() { + color = "#111111" + } +} +//![alias overwrite] +//! [parent end] +} +//! [parent end] +//! [document] diff --git a/doc/src/snippets/declarative/qml-intro/anchors3.qml b/doc/src/snippets/declarative/qml-intro/anchors3.qml deleted file mode 100644 index 24851af..0000000 --- a/doc/src/snippets/declarative/qml-intro/anchors3.qml +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 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 - -Rectangle { - id: myWin - width: 500 - height: 400 - - Image { - id: image1 - source: "images/qt-logo.svg" - width: 150; height: 150 - anchors.bottom: myWin.bottom - anchors.horizontalCenter: myWin.horizontalCenter - anchors.bottomMargin: 10 - } - -//! [adding some text] - Text { - text: "<h2>The Qt Logo</h2>" - anchors.bottom: image1.top - anchors.horizontalCenter: myWin.horizontalCenter - anchors.bottomMargin: 15 - } -//! [adding some text] -} diff --git a/doc/src/snippets/declarative/qml-intro/hello-world2.qml b/doc/src/snippets/declarative/qml-intro/hello-world2.qml deleted file mode 100644 index 2564e25..0000000 --- a/doc/src/snippets/declarative/qml-intro/hello-world2.qml +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 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 - -Rectangle { - id: myRectangle - width: 500 - height: 400 - -//! [updated text] - Text { - text: "<h2>Hello World</h2>"; color: "darkgreen" - x: 100; y:100 - } -//! [updated text] - - color: "lightgray" -} diff --git a/doc/src/snippets/declarative/qml-intro/hello-world3.qml b/doc/src/snippets/declarative/qml-intro/hello-world3.qml deleted file mode 100644 index 03358d0..0000000 --- a/doc/src/snippets/declarative/qml-intro/hello-world3.qml +++ /dev/null @@ -1,57 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 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 - -Rectangle { - id: myRectangle - width: 500 - height: 400 - -//! [updated text] - Text { - text: "<h1>Hello world again</h1>" - color: "#002288" - x: 100; y: 100 - } -//! [updated text] - - color: "lightgray" -} diff --git a/doc/src/snippets/declarative/qml-intro/images/qt-logo.svg b/doc/src/snippets/declarative/qml-intro/images/qt-logo.svg deleted file mode 100644 index 8c018be..0000000 --- a/doc/src/snippets/declarative/qml-intro/images/qt-logo.svg +++ /dev/null @@ -1,104 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://creativecommons.org/ns#" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - clip-rule="evenodd" - stroke-miterlimit="10" - viewBox="0 0 174.35 209.78" - id="svg2" - sodipodi:version="0.32" - inkscape:version="0.46" - width="744.09186" - height="895.29858" - sodipodi:docname="qt-logo.svg" - inkscape:output_extension="org.inkscape.output.svg.inkscape" - version="1.0" - style="stroke-miterlimit:10"> - <metadata - id="metadata29"> - <rdf:RDF> - <cc:Work - rdf:about=""> - <dc:format>image/svg+xml</dc:format> - <dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - </cc:Work> - </rdf:RDF> - </metadata> - <sodipodi:namedview - inkscape:window-height="668" - inkscape:window-width="722" - inkscape:pageshadow="2" - inkscape:pageopacity="0.0" - guidetolerance="10.0" - gridtolerance="10.0" - objecttolerance="10.0" - borderopacity="1.0" - bordercolor="#666666" - pagecolor="#ffffff" - id="base" - showgrid="false" - inkscape:zoom="0.12195802" - inkscape:cx="525.6108" - inkscape:cy="-287.87189" - inkscape:window-x="476" - inkscape:window-y="228" - inkscape:current-layer="svg2" /> - <desc - id="desc4">SVG generated by Lineform</desc> - <defs - id="defs6"> - <inkscape:perspective - sodipodi:type="inkscape:persp3d" - inkscape:vp_x="0 : 526.18109 : 1" - inkscape:vp_y="0 : 1000 : 0" - inkscape:vp_z="744.09448 : 526.18109 : 1" - inkscape:persp3d-origin="372.04724 : 350.78739 : 1" - id="perspective31" /> - </defs> - <g - id="g8" - transform="translate(-1.5304326e-4,-3.775985e-4)"> - <path - d="M 43.08,0.36 C 40.94,0 38.84,-0.08 36.81,0.08 L 36.8,0.08 C 36.8,0.08 22.92,1.02 22.29,1.07 C 9.62,2.08 0,12.5 0,26.89 L 0,196.55 L 14.19,209.78 L 156.79,185.81 C 166.6,184.11 174.35,172.54 174.35,160.04 L 174.35,21.88 L 43.08,0.36" - id="path10" - style="fill:#0c481e" /> - <path - d="M 174.35,160.04 C 174.35,172.54 166.6,184.11 156.79,185.82 L 14.19,209.78 L 14.19,25.99 C 14.19,9.27 27.53,-2.21 43.08,0.36 L 174.35,21.88 L 174.35,160.04" - id="path12" - style="fill:#66b036" /> - <path - d="M 130.42,45.91 L 141.94,47.15 L 141.94,67.36 L 154.9,68.28 L 154.9,80.96 L 141.94,80.36 L 141.94,126.69 C 141.94,130.72 142.38,133.31 143.28,134.48 C 144.08,135.55 145.32,136.07 146.99,136.07 C 147.15,136.07 147.32,136.07 147.48,136.06 C 150.03,135.91 152.81,135.13 155.83,133.75 L 155.83,145.4 C 150.69,147.65 145.65,149 140.7,149.42 C 139.99,149.47 139.29,149.5 138.62,149.5 C 134.14,149.5 130.72,148.2 128.38,145.57 C 125.65,142.52 124.29,137.62 124.29,130.9 L 124.29,79.54 L 118.06,79.26 L 118.06,65.67 L 125.65,66.22 L 130.42,45.91" - id="path14" - style="fill:#ffffff" /> - <path - d="M 154.9,80.96 L 141.94,80.36 L 141.94,80.64 L 148.88,80.96 L 154.9,80.96" - id="path16" - style="fill:#0c481e" /> - <path - d="M 144.64,135.6 C 145.3,135.92 146.07,136.07 146.99,136.07 C 147.15,136.07 147.32,136.07 147.48,136.06 C 150.03,135.91 152.81,135.13 155.83,133.75 L 149.81,133.75 C 147.99,134.58 146.28,135.21 144.64,135.6" - id="path18" - style="fill:#0c481e" /> - <path - d="M 128.38,145.57 C 125.65,142.52 124.29,137.62 124.29,130.9 L 124.29,79.54 L 118.06,79.26 L 118.06,65.67 L 112.05,65.67 L 112.05,68.71 C 112.92,71.98 113.6,75.53 114.11,79.35 L 118.28,79.54 L 118.28,130.9 C 118.28,137.62 119.64,142.52 122.37,145.57 C 124.71,148.2 128.13,149.5 132.61,149.5 L 138.62,149.5 C 134.14,149.5 130.72,148.2 128.38,145.57 z M 130.42,45.91 L 124.41,45.91 L 119.74,65.79 L 125.65,66.22 L 130.42,45.91" - id="path20" - style="fill:#0c481e" /> - <path - d="M 91.15,132.4 C 93.5,126.36 94.66,114.49 94.66,96.79 C 94.66,80.9 93.51,69.97 91.18,63.98 C 88.84,57.95 85.35,54.69 80.66,54.28 C 80.3,54.25 79.95,54.23 79.6,54.23 C 75.26,54.23 71.92,56.77 69.59,61.86 C 67.07,67.4 65.8,78.9 65.8,96.3 C 65.8,113.11 67.04,125.05 69.54,132.05 C 71.89,138.72 75.41,142.03 80.04,142.03 C 80.25,142.03 80.45,142.02 80.66,142.01 C 85.29,141.71 88.78,138.51 91.15,132.4 M 109.13,136.15 C 105.01,145.86 98.73,152.21 90.14,155.15 C 91.01,159.6 92.32,162.6 94.06,164.17 C 95.41,165.39 97.49,165.99 100.28,165.99 C 101.09,165.99 101.96,165.94 102.87,165.84 L 102.87,178.96 L 96.91,179.75 C 95.16,179.97 93.49,180.09 91.91,180.09 C 86.69,180.09 82.47,178.82 79.29,176.26 C 75.08,172.89 71.98,166.37 69.99,156.73 C 60.86,154.78 53.73,148.97 48.8,139.23 C 43.8,129.32 41.25,114.83 41.25,95.89 C 41.25,75.46 44.74,60.38 51.6,50.81 C 57.38,42.75 65.46,38.78 75.62,38.78 C 77.24,38.78 78.93,38.88 80.66,39.08 C 92.61,40.46 101.28,46.1 106.92,55.87 C 112.46,65.43 115.17,79.14 115.17,97.13 C 115.17,113.62 113.17,126.58 109.13,136.15" - id="path22" - style="fill:#ffffff" /> - <path - d="M 100.28,165.99 C 101.09,165.99 101.95,165.94 102.87,165.84 L 98.04,165.84 C 98.71,165.94 99.49,165.99 100.28,165.99" - id="path24" - style="fill:#0c481e" /> - <path - d="M 84.85,63.98 C 87.19,69.97 88.34,80.9 88.34,96.79 C 88.34,114.49 87.18,126.36 84.82,132.4 C 82.93,137.28 80.3,140.31 76.96,141.48 C 77.93,141.84 78.96,142.03 80.04,142.03 C 80.25,142.03 80.45,142.02 80.66,142.01 C 85.29,141.71 88.78,138.51 91.15,132.4 C 93.5,126.36 94.66,114.49 94.66,96.79 C 94.66,80.9 93.51,69.97 91.18,63.98 C 88.84,57.95 85.35,54.69 80.66,54.28 C 80.3,54.25 79.95,54.23 79.6,54.23 C 78.51,54.23 77.48,54.39 76.52,54.72 L 76.52,54.72 C 80.12,55.83 82.89,58.93 84.85,63.98 z M 82.51,178.25 C 82.4,178.2 82.28,178.15 82.17,178.09 C 82.16,178.09 82.15,178.08 82.14,178.08 C 82.03,178.03 81.93,177.97 81.83,177.92 C 81.81,177.91 81.79,177.9 81.77,177.89 C 81.68,177.84 81.59,177.79 81.49,177.74 C 81.46,177.72 81.44,177.71 81.41,177.69 C 81.33,177.65 81.24,177.6 81.16,177.55 C 81.12,177.53 81.09,177.51 81.05,177.48 C 80.98,177.44 80.91,177.4 80.84,177.36 C 80.79,177.33 80.74,177.3 80.7,177.27 C 80.64,177.23 80.58,177.19 80.52,177.15 C 80.46,177.12 80.41,177.08 80.35,177.04 C 80.3,177.01 80.25,176.98 80.2,176.94 C 80.14,176.9 80.07,176.85 80.01,176.81 C 79.97,176.78 79.93,176.75 79.89,176.72 C 79.82,176.67 79.74,176.61 79.67,176.55 C 79.64,176.54 79.61,176.52 79.59,176.5 C 79.49,176.42 79.39,176.34 79.29,176.26 C 75.08,172.89 71.98,166.37 69.99,156.73 C 60.86,154.78 53.73,148.97 48.8,139.23 C 43.8,129.32 41.25,114.83 41.25,95.89 C 41.25,75.46 44.74,60.38 51.6,50.81 C 57.38,42.75 65.46,38.78 75.62,38.78 C 75.65,38.78 69.27,38.77 69.27,38.77 L 69.27,38.78 C 59.12,38.78 51.05,42.75 45.27,50.81 C 38.41,60.38 34.92,75.46 34.92,95.89 C 34.92,114.83 37.47,129.32 42.47,139.23 C 47.41,148.97 54.53,154.78 63.67,156.73 C 65.65,166.37 68.76,172.89 72.96,176.26 C 76.14,178.82 80.36,180.09 85.58,180.09 C 85.68,180.09 85.78,180.09 85.88,180.09 L 91.42,180.09 C 88.01,180.03 85.04,179.43 82.52,178.26 C 82.51,178.26 82.51,178.26 82.51,178.25" - id="path26" - style="fill:#0c481e" /> - </g> -</svg> diff --git a/doc/src/snippets/declarative/qml-intro/number-animation2.qml b/doc/src/snippets/declarative/qml-intro/number-animation2.qml deleted file mode 100644 index 7be22b5..0000000 --- a/doc/src/snippets/declarative/qml-intro/number-animation2.qml +++ /dev/null @@ -1,66 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 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$ -** -****************************************************************************/ - -//! [document] -import QtQuick 1.0 - -Rectangle { - id: mainRec - width: 600 - height: 400 - - Image { - id: image1 - source: "images/qt-logo.svg" - x: 200; y: 100 - width: 100; height: 100 - - // Animate a rotation - transform: Rotation { - origin.x: 50; origin.y: 50; axis {x:0; y:1; z:0} angle:0 - NumberAnimation on angle { - from: 0; to: 360; - duration: 3000; - loops: Animation.Infinite - } - } - } -} -//! [document] diff --git a/doc/src/snippets/declarative/qml-intro/rectangle.qml b/doc/src/snippets/declarative/qml-intro/rectangle.qml deleted file mode 100644 index b25accc..0000000 --- a/doc/src/snippets/declarative/qml-intro/rectangle.qml +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 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$ -** -****************************************************************************/ - -//! [document] -import QtQuick 1.0 - -// This is a comment. And below myRectangle is defined. -Rectangle { - id: myRectangle - width: 500 - height: 400 -} -//! [document] diff --git a/doc/src/snippets/declarative/qml-intro/sequential-animation1.qml b/doc/src/snippets/declarative/qml-intro/sequential-animation1.qml deleted file mode 100644 index c789bbe..0000000 --- a/doc/src/snippets/declarative/qml-intro/sequential-animation1.qml +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 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$ -** -****************************************************************************/ - -//! [document] -import QtQuick 1.0 - -Rectangle { - id: mainRec - width: 600 - height: 400 - z: 0 - - Image { - id: image1 - source: "images/qt-logo.svg" - x: 20; y: 20 ; z: 1 - width: 100; height: 100 - } - - Image { - id: image2 - source: "images/qt-logo.svg" - width: 100; height: 100 - x: (mainRec.width - 100)/2; y: (mainRec.height - 100)/2 - z: 2 - } -} -//! [document] diff --git a/doc/src/snippets/declarative/qml-intro/sequential-animation2.qml b/doc/src/snippets/declarative/qml-intro/sequential-animation2.qml deleted file mode 100644 index b2b1a57..0000000 --- a/doc/src/snippets/declarative/qml-intro/sequential-animation2.qml +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 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 - -Rectangle { - id: mainRec - width: 600 - height: 400 - z: 0 - -//! [adding a sequential animation] - Image { - id: image1 - source: "images/qt-logo.svg" - width: 100; height: 100 - - SequentialAnimation on x { - loops: Animation.Infinite - NumberAnimation { - from: 20; to: 450; easing.type: "InOutQuad"; - duration: 2000 - } - PauseAnimation { duration: 500 } - } - } -//! [adding a sequential animation] - - Image { - id: image2 - source: "images/qt-logo.svg" - width: 100; height: 100 - x: (mainRec.width - 100)/2; y: (mainRec.height - 100)/2 - z: 2 - } -} diff --git a/doc/src/snippets/declarative/reusablecomponents/Button.qml b/doc/src/snippets/declarative/reusablecomponents/Button.qml new file mode 100644 index 0000000..3b97e00 --- /dev/null +++ b/doc/src/snippets/declarative/reusablecomponents/Button.qml @@ -0,0 +1,84 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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$ +** +****************************************************************************/ +//! [document] +//contents of Button.qml +import QtQuick 1.0 + +//! [parent begin] +Rectangle { +//! [parent begin] + id: button +//! [properties] + width: 145; height: 60 + color: "blue" + smooth: true; radius: 9 + property alias text: label.text +//! [properties] + border {color: "#B9C5D0"; width: 1} + + gradient: Gradient { + GradientStop {color: "#CFF7FF"; position: 0.0} + GradientStop {color: "#99C0E5"; position: 0.57} + GradientStop {color: "#719FCB"; position: 0.9} + } + + Text { + id: label + anchors.centerIn: parent + text: "Click Me!" + font.pointSize: 12 + color: "blue" + } + + MouseArea { + anchors.fill: parent + onClicked: console.log(text + " clicked") + } +//! [parent end] +} +//! [parent end] + +//! [document] + +//! [ellipses] + //... +//! [ellipses] + + diff --git a/doc/src/snippets/declarative/qml-intro/anchors1.qml b/doc/src/snippets/declarative/reusablecomponents/application.qml index b958138..a09b276 100644 --- a/doc/src/snippets/declarative/qml-intro/anchors1.qml +++ b/doc/src/snippets/declarative/reusablecomponents/application.qml @@ -37,20 +37,19 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ - //! [document] import QtQuick 1.0 Rectangle { - id: myWin - width: 500 - height: 400 + width: 175; height: 350 + color: "lightgrey" - Image { - id: image1 - source: "images/qt-logo.svg" - width: 150; height: 150 - anchors.bottom: myWin.bottom + Column { + anchors.centerIn: parent + spacing: 15 + Button {} + Button {text: "Me Too!"} + Button {text: "Me Three!"} } } //! [document] diff --git a/doc/src/snippets/declarative/animation-standalone.qml b/doc/src/snippets/declarative/reusablecomponents/component.qml index 0bf3020..8660c50 100644 --- a/doc/src/snippets/declarative/animation-standalone.qml +++ b/doc/src/snippets/declarative/reusablecomponents/component.qml @@ -37,27 +37,41 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -//![0] +//! [document] import QtQuick 1.0 +//! [parent begin] Rectangle { - id: rect - width: 100; height: 100 - color: "red" - - PropertyAnimation { - id: animation - target: rect - properties: "x,y" - duration: 1000 +//! [parent begin] + id: screen + width: 175; height: 175 + color: "lightgrey" + +//! [define inline component] + Component { + id: inlinecomponent + Rectangle { + id: display + width: 50; height: 50 + color: "blue" + } } - +//! [define inline component] +//! [create inline component] MouseArea { anchors.fill: parent onClicked: { - animation.to = 50; - animation.running = true; + inlinecomponent.createObject(parent) + + var second = inlinecomponent.createObject(parent) + + var third = inlinecomponent.createObject(parent) + third.x = second.width + 10 + third.color = "red" } - } + } +//! [create inline component] +//! [parent end] } -//![0] +//! [parent end] +//! [document] diff --git a/doc/src/snippets/declarative/qml-intro/sequential-animation3.qml b/doc/src/snippets/declarative/reusablecomponents/focusbutton.qml index d840575..2522a98 100644 --- a/doc/src/snippets/declarative/qml-intro/sequential-animation3.qml +++ b/doc/src/snippets/declarative/reusablecomponents/focusbutton.qml @@ -37,56 +37,62 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ - -import QtQuick 1.0 - //! [document] +//contents of focusbutton.qml import QtQuick 1.0 -Rectangle { - id: mainRec - width: 600 - height: 400 - z: 0 +//! [parent begin] +FocusScope { +//! [parent begin] - Image { - id: image2 - source: "images/qt-logo.svg" - width: 100; height: 100 - x: (mainRec.width - 100)/2; y: (mainRec.height - 100)/2 - z: 2 - } + //! [expose visuals] + //FocusScope needs to bind to visual properties of the children + property alias color: button.color + x: button.x; y: button.y + width: button.width; height: button.height + //! [expose visuals] - Image { - id: image1 - source: "images/qt-logo.svg" - x: 20; y: 20 ; z: 1 - width: 100; height: 100 + //! [rectangle begin] + Rectangle { + //! [rectangle begin] + id: button + //! [properties] + width: 145; height: 60 + color: "blue" + smooth: true; radius: 9 + property alias text: label.text + //! [properties] + border {color: "#B9C5D0"; width: 1} - SequentialAnimation on x { - loops: Animation.Infinite - NumberAnimation { - from: 20; to: 450 - easing.type: "InOutQuad"; duration: 2000 - } - PauseAnimation { duration: 500 } + gradient: Gradient { + GradientStop {color: "#CFF7FF"; position: 0.0} + GradientStop {color: "#99C0E5"; position: 0.57} + GradientStop {color: "#719FCB"; position: 0.9} } - SequentialAnimation on y { - loops: Animation.Infinite - NumberAnimation { - from: 20; to: 250 - easing.type: "InOutQuad"; duration: 2000 - } - PauseAnimation { duration: 500 } + Text { + id: label + anchors.centerIn: parent + text: "Click Me!" + font.pointSize: 12 + color: "blue" } - SequentialAnimation on scale { - loops: Animation.Infinite - NumberAnimation { from: 1; to: 0.5; duration: 1000 } - NumberAnimation { from: 0.5; to: 1; duration: 1000 } - PauseAnimation { duration: 500 } + MouseArea { + anchors.fill: parent + onClicked: console.log(text + " clicked") } + //! [rectangle end] } + //! [rectangle end] +//! [parent end] } +//! [parent end] + //! [document] + +//! [ellipses] + //... +//! [ellipses] + + diff --git a/doc/src/snippets/declarative/reusablecomponents/qmldir b/doc/src/snippets/declarative/reusablecomponents/qmldir new file mode 100644 index 0000000..253732d --- /dev/null +++ b/doc/src/snippets/declarative/reusablecomponents/qmldir @@ -0,0 +1,4 @@ +//! [document] +Button ./Button.qml +FocusButton ./focusbutton.qml +//! [document] diff --git a/doc/src/snippets/declarative/states.qml b/doc/src/snippets/declarative/states.qml index c3b7197..ab6b8d0 100644 --- a/doc/src/snippets/declarative/states.qml +++ b/doc/src/snippets/declarative/states.qml @@ -37,24 +37,85 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -//![0] +//![document] import QtQuick 1.0 - + +//![parent begin] Rectangle { - id: myRect - width: 200; height: 200 - color: "red" +//![parent begin] + + id: screen + width: 400; height: 500 - MouseArea { - anchors.fill: parent - onClicked: myRect.state = 'moved' - } + +Rectangle { + id: flag +} +Column { + spacing: 15 +//![signal states] +Rectangle { + id: signal + width: 200; height: 200 + state: "NORMAL" states: [ State { - name: "moved" - PropertyChanges { target: myRect; x: 50; y: 50 } + name: "NORMAL" + PropertyChanges { target: signal; color: "green"} + PropertyChanges { target: flag; state: "FLAG_DOWN"} + }, + State { + name: "CRITICAL" + PropertyChanges { target: signal; color: "red"} + PropertyChanges { target: flag; state: "FLAG_UP"} } ] } -//![0] +//![signal states] + +//![switch states] +Rectangle { + id: signalswitch + width: 75; height: 75 + color: "blue" + + MouseArea { + anchors.fill: parent + onClicked: { + if (signal.state == "NORMAL") + signal.state = "CRITICAL" + else + signal.state = "NORMAL" + } + } +} +//![switch states] + +//![when property] +Rectangle { + id: bell + width: 75; height: 75 + color: "yellow" + + states: State { + name: "RINGING" + when: (signal.state == "CRITICAL") + PropertyChanges {target: speaker; play: "RING!"} + } +} +//![when property] + +Text { + id: speaker + property alias play: speaker.text + text: "NORMAL" +} + +} // end of row + +//![parent end] +} +//![parent end] + +//![document] diff --git a/doc/src/snippets/declarative/qml-intro/hello-world5.qml b/doc/src/snippets/declarative/texthandling.qml index 7357282..377bb8b 100644 --- a/doc/src/snippets/declarative/qml-intro/hello-world5.qml +++ b/doc/src/snippets/declarative/texthandling.qml @@ -37,29 +37,53 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ - //! [document] import QtQuick 1.0 + +//! [parent begin] Rectangle { - id: myRectangle - width: 500 - height: 400 +//! [parent begin] + width: 300; height: 300 + id: screen + +Column { + anchors.centerIn:parent + +//! [int validator] +Column { + spacing: 10 Text { - text: "<h1>Hello world again</h1>" - color: "#002288" - x: 100; y: 100 + text: "Enter a value from 0 to 2000" } + TextInput { + focus: true + validator: IntValidator { bottom:0; top: 2000} + } +} +//! [int validator] + +//! [regexp validator] +Column { + spacing: 10 -//! [positioning the image] - Image { - source: "images/qt-logo.svg" - x: 100; y: 150 - width: 150; height: 150 + Text { + text: "Which basket?" + } + TextInput { + focus: true + validator: RegExpValidator { regExp: /fruit basket/ } } -//! [positioning the image] +} +//! [regexp validator] - color: "lightgray" +//end of column } + +//! [parent end] +} +//! [parent end] + //! [document] + diff --git a/doc/src/snippets/declarative/webview/webview.qml b/doc/src/snippets/declarative/webview/webview.qml index dac8010..f652369 100644 --- a/doc/src/snippets/declarative/webview/webview.qml +++ b/doc/src/snippets/declarative/webview/webview.qml @@ -39,7 +39,9 @@ ****************************************************************************/ //! [document] +//! [import] import QtWebKit 1.0 +//! [import] WebView { url: "http://www.nokia.com" diff --git a/doc/src/snippets/qtreeview-dnd/dragdropmodel.h b/doc/src/snippets/qtreeview-dnd/dragdropmodel.h index ed01540..a20b1bb 100644 --- a/doc/src/snippets/qtreeview-dnd/dragdropmodel.h +++ b/doc/src/snippets/qtreeview-dnd/dragdropmodel.h @@ -38,17 +38,6 @@ ** ****************************************************************************/ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of an example program for Qt. -** EDITIONS: NOLIMITS -** -****************************************************************************/ - #ifndef DRAGDROPMODEL_H #define DRAGDROPMODEL_H diff --git a/doc/src/snippets/qtscript/evaluation/main.cpp b/doc/src/snippets/qtscript/evaluation/main.cpp index e7efd8e..01e06b6 100644 --- a/doc/src/snippets/qtscript/evaluation/main.cpp +++ b/doc/src/snippets/qtscript/evaluation/main.cpp @@ -42,9 +42,9 @@ int main(int argc, char *argv[]) { -//! [0] + //! [0] QScriptEngine engine; qDebug() << "the magic number is:" << engine.evaluate("1 + 2").toNumber(); -//! [0] + //! [0] return 0; } diff --git a/doc/src/snippets/qtscript/registeringobjects/main.cpp b/doc/src/snippets/qtscript/registeringobjects/main.cpp index 1911442..9dab25a 100644 --- a/doc/src/snippets/qtscript/registeringobjects/main.cpp +++ b/doc/src/snippets/qtscript/registeringobjects/main.cpp @@ -44,12 +44,12 @@ int main(int argc, char *argv[]) { -//! [0] + //! [0] QScriptEngine engine; QObject *someObject = new MyObject; QScriptValue objectValue = engine.newQObject(someObject); engine.globalObject().setProperty("myObject", objectValue); -//! [0] + //! [0] qDebug() << "myObject's calculate() function returns" << engine.evaluate("myObject.calculate(10)").toNumber(); return 0; diff --git a/doc/src/snippets/qtscript/registeringvalues/main.cpp b/doc/src/snippets/qtscript/registeringvalues/main.cpp index 3defc1f..6dc5b7c 100644 --- a/doc/src/snippets/qtscript/registeringvalues/main.cpp +++ b/doc/src/snippets/qtscript/registeringvalues/main.cpp @@ -43,10 +43,10 @@ int main(int argc, char *argv[]) { QScriptEngine engine; -//! [0] + //! [0] engine.globalObject().setProperty("foo", 123); qDebug() << "foo times two is:" << engine.evaluate("foo * 2").toNumber(); -//! [0] + //! [0] return 0; } diff --git a/doc/src/snippets/textblock-fragments/xmlwriter.cpp b/doc/src/snippets/textblock-fragments/xmlwriter.cpp index 9f66d9a..252720b 100644 --- a/doc/src/snippets/textblock-fragments/xmlwriter.cpp +++ b/doc/src/snippets/textblock-fragments/xmlwriter.cpp @@ -102,11 +102,10 @@ void XmlWriter::readFragment(const QTextBlock ¤tBlock, QDomText fragmentText = document->createTextNode(currentFragment.text()); fragmentElement.appendChild(fragmentText); -//! [6] } -//! [7] - } //! [6] //! [7] + } +//! [7] //! [6] } void XmlWriter::processBlock(const QTextBlock ¤tBlock) diff --git a/doc/src/snippets/textdocument-frames/xmlwriter.cpp b/doc/src/snippets/textdocument-frames/xmlwriter.cpp index 31f08f3..8988100 100644 --- a/doc/src/snippets/textdocument-frames/xmlwriter.cpp +++ b/doc/src/snippets/textdocument-frames/xmlwriter.cpp @@ -100,6 +100,8 @@ void XmlWriter::processFrame(QDomElement &parent, QTextFrame *frame) parent.appendChild(frameElement); //! [1] + QDomElement frameElement = ... + QTextFrame::iterator it; for (it = frame->begin(); !(it.atEnd()); ++it) { diff --git a/doc/src/snippets/textdocument-tables/xmlwriter.cpp b/doc/src/snippets/textdocument-tables/xmlwriter.cpp index d1d6798..8f98295 100644 --- a/doc/src/snippets/textdocument-tables/xmlwriter.cpp +++ b/doc/src/snippets/textdocument-tables/xmlwriter.cpp @@ -98,6 +98,8 @@ void XmlWriter::processFrame(QDomElement &parent, QTextFrame *frame) parent.appendChild(frameElement); //! [0] + QDomElement frameElement = ... + QTextFrame::iterator it; for (it = frame->begin(); !(it.atEnd()); ++it) { diff --git a/doc/src/sql-programming/sql-driver.qdoc b/doc/src/sql-programming/sql-driver.qdoc index a4bcb97..2cb7aab 100644 --- a/doc/src/sql-programming/sql-driver.qdoc +++ b/doc/src/sql-programming/sql-driver.qdoc @@ -121,7 +121,7 @@ Source code to access the OUT values: - \snippet doc/src/snippets/code/doc_src_sql-driver.qdoc 2 + \snippet doc/src/snippets/code/doc_src_sql-driver.cpp 2 \bold{Note:} \c{@outval1} and \c{@outval2} are variables local to the current connection and will not be affected by queries sent from another host @@ -394,7 +394,7 @@ sets, will be accessible only if you set the query's forward only mode to \e forward using \l QSqlQuery::setForwardOnly(). - \snippet doc/src/snippets/code/doc_src_sql-driver.qdoc 10 + \snippet doc/src/snippets/code/doc_src_sql-driver.cpp 10 \bold{Note:} The value returned by the stored procedure's return statement is discarded. @@ -681,7 +681,7 @@ database file, no matter whether it is stored locally or on another server. - \snippet doc/src/snippets/code/doc_src_sql-driver.qdoc 24 + \snippet doc/src/snippets/code/doc_src_sql-driver.cpp 24 You need the InterBase/Firebird development headers and libraries to build this plugin. @@ -696,7 +696,7 @@ be overridden by setting the ISC_DPB_LC_CTYPE parameter with QSqlDatabase::setConnectOptions() before opening the connection. - \snippet doc/src/snippets/code/doc_src_sql-driver.qdoc 25 + \snippet doc/src/snippets/code/doc_src_sql-driver.cpp 25 If Qt doesn't support the given text encoding the driver will issue a warning message and connect to the database using UNICODE_FSS. @@ -710,7 +710,7 @@ procedure, only IN values need to be bound via QSqlQuery::bindValue(). The RETURN/OUT values can be retrieved via QSqlQuery::value(). Example: - \snippet doc/src/snippets/code/doc_src_sql-driver.qdoc 26 + \snippet doc/src/snippets/code/doc_src_sql-driver.cpp 26 \section3 How to Build the QIBASE Plugin on Unix and Mac OS X @@ -777,7 +777,7 @@ Make sure you have followed the guide to \l{Deploying Plugins}. If you experience plugin load problems and see output like this: - \snippet doc/src/snippets/code/doc_src_sql-driver.qdoc 31 + \snippet doc/src/snippets/code/doc_src_sql-driver.cpp 31 the problem is usually that the plugin had the wrong \l{Deploying Plugins#The Build Key}{build key}. This might require removing an diff --git a/doc/src/template/style/offline.css b/doc/src/template/style/offline.css index 4083a75..44abb3c 100644 --- a/doc/src/template/style/offline.css +++ b/doc/src/template/style/offline.css @@ -26,14 +26,14 @@ { text-decoration: none; } - li - { - list-style: none; - } ol li { list-style: decimal; } + ul li + { + list-style: none; + } caption, th { text-align: left; @@ -76,6 +76,8 @@ { margin-left: 0.5em; margin-right: 0.5em; + font-family: sans-serif; + line-height: normal } a { @@ -124,13 +126,13 @@ } th { - padding: 0.5em 1.5em 0.5em 1.5em; + padding: 0.5em 1.5em 0.5em 1em; background-color: #E1E1E1; border-left: 1px solid #E6E6E6; } td { - padding: 0.25em 1.5em 0.25em 2em; + padding: 0.25em 1.5em 0.25em 1em; } td.rightAlign @@ -141,13 +143,13 @@ { border-left: 1px solid #E6E6E6; background-color: #F6F6F6; - color: #66666E; + color: black; } table tr.even { border-left: 1px solid #E6E6E6; background-color: #ffffff; - color: #66666E; + color: #202020; } div.float-left @@ -239,10 +241,6 @@ margin-bottom: 0.5em } - .naviNextPrevious - { - display: none - } .header .breadcrumb { font-size: 90%; @@ -309,19 +307,19 @@ .content h1 { font-weight: bold; - font-size: 150% + font-size: 130% } .content h2 { font-weight: bold; - font-size: 135%; + font-size: 120%; width: 100%; } .content h3 { font-weight: bold; - font-size: 120%; + font-size: 110%; width: 100%; } .content table p @@ -471,6 +469,11 @@ padding: 0.25em 0.5em 0.25em 0.5em; } + .toc + { + font-size: 80% + } + .header .content .toc ul { padding-left: 0px; diff --git a/doc/src/template/style/style.css b/doc/src/template/style/style.css index df2729c..4071145 100755 --- a/doc/src/template/style/style.css +++ b/doc/src/template/style/style.css @@ -7,7 +7,7 @@ color: #000000; background: #FFFFFF; } - body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, code, form, fieldset, legend, input, button, textarea, p, blockquote, th, td + body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, pre, code, form, fieldset, legend, input, button, textarea, p, th, td { margin: 0; padding: 0; @@ -146,13 +146,13 @@ } th { - padding: 5px 15px 5px 15px; + padding: 5px 15px 5px 10px; background-color: #E1E1E1; border-left: 1px solid #E6E6E6; } td { - padding: 3px 15px 3px 20px; + padding: 3px 15px 3px 10px; } tr.odd td:hover, tr.even td:hover {} @@ -185,10 +185,165 @@ { float: right; margin-left: 2em } + div.clear-both + { + clear: both + } + div.clear-left + { + clear: left + } + div.clear-right + { + clear: right + } + #color-white + { + background: #ffffff; + color: #000000; + } + #color-black + { + background: #000000; + color: #ffffff; + } + #color-red + { + background: #ff0000; + color: #000000; + } + #color-darkRed + { + background: #800000; + color: #ffffff; + } + #color-green + { + background: #00ff00; + color: #000000; + } + #color-darkGreen + { + background: #008000; + color: #ffffff; + } + #color-blue + { + background: #0000ff; + color: #ffffff; + } + #color-darkBlue + { + background: #000080; + color: #ffffff; + } + #color-cyan + { + background: #00ffff; + color: #000000; + } + #color-darkCyan + { + background: #008080; + color: #ffffff; + } + #color-magenta + { + background: #ff00ff; + color: #000000; + } + #color-darkMagenta + { + background: #800080; + color: #ffffff; + } + #color-yellow + { + background: #ffff00; + color: #000000; + } + #color-darkYellow + { + background: #808000; + color: #ffffff; + } + #color-gray + { + background: #a0a0a4; + color: #000000; + } + #color-darkGray + { + background: #808080; + color: #ffffff; + } + #color-lightGray + { + background: #c0c0c0; + color: #000000; + } + #QtGuiColor + { + background-color: #98fd00; + color: black; + } + #QtCoreColor + { + background-color: #9c9cff; + color: black; + } + #DefaultColor + { + background-color: #f6f6dc; + color: black; + } + #FreetypeColor + { + background-color: #e6e6fa; + color: black; + } + #GLColor + { + background-color: #ffc0cb; + color: black; + } + #PthreadColor + { + background-color: #bdb76b; + color: black; + } + #OptionalColor + { + background-color: #cae1ff; + color: black; + } + #SMColor + { + background-color: #c2fafa; + color: black; + } + #MiscColor + { + background-color: #f0f9ff; + color: black; + } + #GlibColor + { + background-color: #b3b3b3; + color: black; + } + .figCaption + { + color:#363534; + font:italic 11px/1.2 Verdana; + text-align: center; + padding-top:0; + } span.comment { color: #008B00; + font-style: italic } span.string, span.char { @@ -1030,11 +1185,28 @@ padding:0px; } - .content .alignedsummary - { - margin: 15px; - } - + .content .alignedsummary + { + margin: 15px; + } + + .details + { + text-align: left; + font-size: 80%; + color: blue + } + .variableName + { + font-family: courier; + color: blue + } + .newStuff + { + text-align: left; + font-size: 80%; + color: red + } .qmltype { @@ -1381,6 +1553,10 @@ font: normal bold 13px/1 Verdana; } + .content .normallist li + { + font: normal 13px/1 Verdana; + } .indexbox a:hover, .indexbox a:visited:hover { color: #4c0033; @@ -1417,6 +1593,13 @@ background: url(../images/sprites-combined.png) no-repeat -111px -376px; padding: 0; } + .indexbox.tools .indexIcon2 + { + width: 115px; + height: 137px; + background: url(../images/sprites-combined.png) no-repeat -111px -376px; + padding: 0; + } .indexboxcont:after { content: "."; diff --git a/doc/src/tutorials/modelview.qdoc b/doc/src/tutorials/modelview.qdoc index cae7764..efd0ff2 100644 --- a/doc/src/tutorials/modelview.qdoc +++ b/doc/src/tutorials/modelview.qdoc @@ -27,7 +27,7 @@ /*! \page modelview.html - + \ingroup tutorials \startpage {index.html}{Qt Reference Documentation} \title Model/View Tutorial diff --git a/doc/src/tutorials/threads.qdoc b/doc/src/tutorials/threads.qdoc new file mode 100644 index 0000000..1d807a0 --- /dev/null +++ b/doc/src/tutorials/threads.qdoc @@ -0,0 +1,572 @@ +/**************************************************************************** +** +** Copyright (C) 2011 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:FDL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Free Documentation License +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of this +** file. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \page thread-basics.html + \ingroup tutorials + \startpage {index.html}{Qt Reference Documentation} + + \title Threading Basics + \brief An introduction to threads + + \section1 What Are Threads + + Threads are about doing things in parallel, just like processes. So how do + threads differ from processes? While you are making calculations on a + spreadsheet, there may also be a media player running on the same desktop + playing your favorite song. Here is an example of two processes working in + parallel: one running the spreadsheet program; one running a media player. + Multitasking is a well known term for this. A closer look at the media + player reveals that there are again things going on in parallel within one + single process. While the media player is sending music to the audio driver, + the user interface with all its bells and whistles is being constantly + updated. This is what threads are for \mdash concurrency within one single + process. + + So how is concurrency implemented? Parallel work on single core CPUs is an + illusion which is somewhat similar to the illusion of moving images in + cinema. + For processes, the illusion is produced by interrupting the processor's + work on one process after a very short time. Then the processor moves on to + the next process. In order to switch between processes, the current program + counter is saved and the next processor's program counter is loaded. This + is not sufficient because the same needs to be done with registers and + certain architecture and OS specific data. + + Just as one CPU can power two or more processes, it is also possible to let + the CPU run on two different code segments of one single process. When a + process starts, it always executes one code segment and therefore the + process is said to have one thread. However, the program may decide to + start a second thread. Then, two different code sequences are processed + simultaneously inside one process. Concurrency is achieved on single core + CPUs by repeatedly saving program counters and registers then loading the + next thread's program counters and registers. No cooperation from the + program is required to cycle between the active threads. A thread may be in + any state when the switch to the next thread occurs. + + The current trend in CPU design is to have several cores. A typical + single-threaded application can make use of only one core. However, a + program with multiple threads can be assigned to multiple cores, making + things happen in a truly concurrent way. As a result, distributing work + to more than one thread can make a program run much faster on multicore + CPUs because additional cores can be used. + + \section2 GUI Thread and Worker Thread + + As mentioned, each program has one thread when it is started. This thread + is called the "main thread" (also known as the "GUI thread" in Qt + applications). The Qt GUI must run in this thread. All widgets and several + related classes, for example QPixmap, don't work in secondary threads. + A secondary thread is commonly referred to as a "worker thread" because it + is used to offload processing work from the main thread. + + \section2 Simultaneous Access to Data + + Each thread has its own stack, which means each thread has its own call + history and local variables. Unlike processes, threads share the same + address space. The following diagram shows how the building blocks of + threads are located in memory. Program counter and registers of inactive + threads are typically kept in kernel space. There is a shared copy of the + code and a separate stack for each thread. + + \image threadvisual-example.png "Thread visualization" + + If two threads have a pointer to the same object, it is possible that both + threads will access that object at the same time and this can potentially + destroy the object's integrity. It's easy to imagine the many things that + can go wrong when two methods of the same object are executed + simultaneously. + + Sometimes it is necessary to access one object from different threads; + for example, when objects living in different threads need to communicate. + Since threads use the same address space, it is easier and faster for + threads to exchange data than it is for processes. Data does not have to be + serialized and copied. Passing pointers is possible, but there must be a + strict coordination of what thread touches which object. Simultaneous + execution of operations on one object must be prevented. There are several + ways of achieving this and some of them are described below. + + So what can be done safely? All objects created in a thread can be used + safely within that thread provided that other threads don't have references + to them and objects don't have implicit coupling with other threads. Such + implicit coupling may happen when data is shared between instances as with + static members, singletons or global data. Familiarize yourself with the + concept of \l{Reentrancy and Thread-Safety}{thread safe and reentrant} + classes and functions. + + \section1 Using Threads + + There are basically two use cases for threads: + + \list + \o Make processing faster by making use of multicore processors. + \o Keep the GUI thread or other time critical threads responsive by + offloading long lasting processing or blocking calls to other threads. + \endlist + + \section2 When to Use Alternatives to Threads + + Developers need to be very careful with threads. It is easy to start other + threads, but very hard to ensure that all shared data remains consistent. + Problems are often hard to find because they may only show up once in a + while or only on specific hardware configurations. Before creating threads + to solve certain problems, possible alternatives should be considered. + + \table + \header + \o Alternative + \o Comment + \row + \o QEventLoop::processEvents() + \o Calling QEventLoop::processEvents() repeatedly during a + time-consuming calculation prevents GUI blocking. However, this + solution doesn't scale well because the call to processEvents() may + occur too often, or not often enough, depending on hardware. + \row + \o QTimer + \o Background processing can sometimes be done conveniently using a + timer to schedule execution of a slot at some point in the future. + A timer with an interval of 0 will time out as soon as there are no + more events to process. + \row + \o QSocketNotifier QNetworkAccessManager QIODevice::readyRead() + \o This is an alternative to having one or multiple threads, each with + a blocking read on a slow network connection. As long as the + calculation in response to a chunk of network data can be executed + quickly, this reactive design is better than synchronous waiting in + threads. Reactive design is less error prone and energy efficient + than threading. In many cases there are also performance benefits. + \endtable + + In general, it is recommended to only use safe and tested paths and to + avoid introducing ad-hoc threading concepts. QtConcurrent provides an easy + interface for distributing work to all of the processor's cores. The + threading code is completely hidden in the QtConcurrent framework, so you + don't have to take care of the details. However, QtConcurrent can't be used + when communication with the running thread is needed, and it shouldn't be + used to handle blocking operations. + + \section2 Which Qt Thread Technology Should You Use? + + Sometimes you want to do more than just running a method in the context of + another thread. You may want to have an object which lives in another + thread that provides a service to the GUI thread. Maybe you want another + thread to stay alive forever to poll hardware ports and send a signal to + the GUI thread when something noteworthy has happened. Qt provides + different solutions for developing threaded applications. The right + solution depends on the purpose of the new thread as well as on the + thread's lifetime. + + \table + \header + \o Lifetime of thread + \o Development task + \o Solution + \row + \o One call + \o Run one method within another thread and quit the thread when the + method is finished. + \o Qt provides different solutions: + \list + \o Write a function and run it with QtConcurrent::run() + \o Derive a class from QRunnable and run it in the global thread + pool with QThreadPool::globalInstance()->start() + \o Derive a class from QThread, reimplement the QThread::run() + method and use QThread::start() to run it. + \endlist + + \row + \o One call + \o Operations are to be performed on all items of a container. + Processing should be performed using all available cores. A common + example is to produce thumbnails from a list of images. + \o QtConcurrent provides the \l{QtConcurrent::}{map()} function for + applying operations on every container element, + \l{QtConcurrent::}{filter()} for selecting container elements, and + the option of specifying a reduce function for combining the + remaining elements. + \row + \o One call + \o A long running operation has to be put in another thread. During the + course of processing, status information should be sent to the GUI + thread. + \o Use QThread, reimplement run and emit signals as needed. Connect the + signals to the GUI thread's slots using queued signal/slot + connections. + + \row + \o Permanent + \o Have an object living in another thread and let it perform different + tasks upon request. + This means communication to and from the worker thread is required. + \o Derive a class from QObject and implement the necessary slots and + signals, move the object to a thread with a running event loop and + communicate with the object over queued signal/slot connections. + \row + \o Permanent + \o Have an object living in another thread, let the object perform + repeated tasks such as polling a port and enable communication with + the GUI thread. + \o Same as above but also use a timer in the worker thread to implement + polling. However, the best solution for polling is to avoid it + completely. Sometimes using QSocketNotifier is an alternative. + \endtable + + + \section1 Qt Thread Basics + + QThread is a very convenient cross platform abstraction of native platform + threads. Starting a thread is very simple. Let us look at a short piece of + code that generates another thread which says hello in that thread and then + exits. + + \snippet examples/tutorials/threads/hellothread/hellothread.h 1 + + We derive a class from QThread and reimplement the \l{QThread::}{run()} + method. + + \snippet examples/tutorials/threads/hellothread/hellothread.cpp 1 + + The run method contains the code that will be run in a separate thread. In + this example, a message containing the thread ID will be printed. + QThread::start() will call the method in another thread. + + \snippet examples/tutorials/threads/hellothread/main.cpp 1 + + To start the thread, our thread object needs to be instantiated. The + \l{QThread::}{start()} method creates a new thread and calls the + reimplemented \l{QThread::}{run()} method in this new thread. Right after + \l{QThread::}{start()} is called, two program counters walk through the + program code. The main function starts with only the GUI thread running and + it should terminate with only the GUI thread running. Exiting the program + when another thread is still busy is a programming error, and therefore, + wait is called which blocks the calling thread until the + \l{QThread::}{run()} method has completed. + + This is the result of running the code: + + \badcode + hello from GUI thread 3079423696 + hello from worker thread 3076111216 + \endcode + + + \section2 QObject and Threads + + A QObject is said to have a \e{thread affinity} or, in other words, that it + lives in a certain thread. This means that, at creation time, QObject saves + a pointer to the current thread. This information becomes relevant when an + event is posted with \l{QCoreApplication::}{postEvent()}. The event will be + put in the corresponding thread's event loop. If the thread where the + QObject lives doesn't have an event loop, the event will never be delivered. + + To start an event loop, \l{QThread::}{exec()} must be called inside + \l{QThread::}{run()}. Thread affinity can be changed using + \l{QObject::}{moveToThread()}. + + As mentioned above, developers must always be careful when calling objects' + methods from other threads. Thread affinity does not change this situation. + Qt documentation marks several methods as thread-safe. + \l{QCoreApplication::}{postEvent()} is a noteworthy example. A thread-safe + method may be called from different threads simultaneously. + + In cases where there is usually no concurrent access to methods, calling + non-thread-safe methods of objects in other threads may work thousands + of times before a concurrent access occurs, causing unexpected behavior. + Writing test code does not entirely ensure thread correctness, but it is + still important. + On Linux, Valgrind and Helgrind can help detect threading errors. + + The anatomy of QThread is quite interesting: + + \list + \o QThread does not live in the new thread where \l{QThread::}{run()} is + executed. It lives in the old thread. + \o Most QThread methods are the thread's control interface and are meant to + be called from the old thread. Do not move this interface to the newly + created thread using \l{QObject::}{moveToThread()}; i.e., calling + \l{QObject::moveToThread()}{moveToThread(this)} is regarded as bad + practice. + \o \l{QThread::}{exec()} and the static methods + \l{QThread::}{usleep()}, \l{QThread::}{msleep()}, + \l{QThread::}{sleep()} are meant to be called from the newly created + thread. + \o Additional members defined in the QThread subclass are + accessible by both threads. The developer is responsible for + coordinating access. A typical strategy is to set the members before + \l{QThread::}{start()} is called. Once the worker thread is running, + the main thread should not touch the additional members anymore. After + the worker has terminated, the main thread can access the additional + members again. This is a convenient strategy for passing parameters to a + thread before it is started as well as for collecting the result once it + has terminated. + \endlist + + A QObject's parent must always be in the same thread. This has a surprising + consequence for objects generated within the \l{QThread::}{run()} method: + + \code + void HelloThread::run() + { + QObject *object1 = new QObject(this); //error, parent must be in the same thread + QObject object2; // OK + QSharedPointer <QObject> object3(new QObject); // OK + } + \endcode + + \section2 Using a Mutex to Protect the Integrity of Data + + A mutex is an object that has \l{QMutex::}{lock()} and \l{QMutex::}{unlock()} + methods and remembers if it is already locked. A mutex is designed to be + called from multiple threads. \l{QMutex::}{lock()} returns immediately if + the mutex is not locked. The next call from another thread will find the + mutex in a locked state and then \l{QMutex::}{lock()} will block the thread + until the other thread calls \l{QMutex::}{unlock()}. This functionality can + make sure that a code section will be executed by only one thread at a time. + + The following line sketches how a mutex can be used to make a method + thread-safe: + + \code + void Worker::work() + { + this->mutex.lock(); // first thread can pass, other threads will be blocked here + doWork(); + this->mutex.unlock(); + } + \endcode + + What happens if one thread does not unlock a mutex? The result can be a + frozen application. In the example above, an exception might be thrown and + \c{mutex.unlock()} will never be reached. To prevent problems like this, + QMutexLocker should be used. + + \code + void Worker::work() + { + QMutexLocker locker(&mutex); // Locks the mutex and unlocks when locker exits the scope + doWork(); + } + \endcode + + This looks easy, but mutexes introduce a new class of problems: deadlocks. + A deadlock happens when a thread waits for a mutex to become unlocked, but + the mutex remains locked because the owning thread is waiting for the first + thread to unlock it. The result is a frozen application. Mutexes can be + used to make a method thread safe. Most Qt methods aren't thread safe + because there is always a performance penalty when using mutexes. + + It isn't always possible to lock and unlock a mutex in a method. Sometimes + the need to lock spans several calls. For example, modifying a container + with an iterator requires a sequence of several calls which should not be + interrupted by other threads. In such a scenario, locking can be achieved + with a mutex that is kept outside of the object to be manipulated. With an + external mutex, the duration of locking can be adjusted to the needs of the + operation. One disadvantage is that external mutexes aid locking, but do + not enforce it because users of the object may forget to use it. + + \section2 Using the Event Loop to Prevent Data Corruption + + The event loops of Qt are a very valuable tool for inter-thread + communication. Every thread may have its own event loop. A safe way of + calling a slot in another thread is by placing that call in another + thread's event loop. This ensures that the target object finishes the + method that is currently running before another method is started. + + So how is it possible to put a method invocation in an event loop? Qt has + two ways of doing this. One way is via queued signal-slot connections; the + other way is to post an event with QCoreApplication::postEvent(). A queued + signal-slot connection is a signal slot connection that is executed + asynchronously. The internal implementation is based on posted events. The + arguments of the signal are put into the event loop and the signal method + returns immediately. + + The connected slot will be executed at a time which depends on what else is + in the event loop. + + Communication via the event loop eliminates the deadlock problem we face + when using mutexes. This is why we recommend using the event loop rather + than locking an object using a mutex. + + \section2 Dealing with Asynchronous Execution + + One way to obtain a worker thread's result is by waiting for the thread + to terminate. In many cases, however, a blocking wait isn't acceptable. The + alternative to a blocking wait are asynchronous result deliveries with + either posted events or queued signals and slots. This generates a certain + overhead because an operation's result does not appear on the next source + line, but in a slot located somewhere else in the source file. Qt + developers are used to working with this kind of asynchronous behavior + because it is much similar to the kind of event-driven programming used in + GUI applications. + + \section1 Examples + + This tutorial comes with examples for Qt's three basic ways of working with + threads. Two more examples show how to communicate with a running thread + and how a QObject can be placed in another thread, providing service to the + main thread. + + \list + \o Using QThread as shown \l{Qt thread basics}{above} + \o \l{Example 1: Using the Thread Pool}{Using the global QThreadPool} + \o \l{Example 2: Using QtConcurrent}{Using QtConcurrent} + \o \l{Example 3: Clock}{Communication with the GUI thread} + \o \l{Example 4: A Permanent Thread}{A permanent QObject in another thread + provides service to the main thread} + \endlist + + The following examples can all be compiled and run independently. The source can + be found in the examples directory: examples/tutorials/threads/ + + \section2 Example 1: Using the Thread Pool + + Creating and destroying threads frequently can be expensive. To avoid the + cost of thread creation, a thread pool can be used. A thread pool is a + place where threads can be parked and fetched. We can write the same + "hello thread" program as \l{Qt Thread Basics}{above} using the global + thread pool. We derive a class from QRunnable. The code we want to run in + another thread needs to be placed in the reimplemented QRunnable::run() + method. + + \snippet examples/tutorials/threads/hellothreadpool/hellothreadpool.cpp 1 + + We instantiate Work in main(), locate the global thread pool and use the + QThreadPool::start() method. Now the thread pool runs our worker in another + thread. Using the thread pool has a performance advantage because threads + are not destroyed after they have finished running. They are kept in a pool + and wait to be used again later. + + \section2 Example 2: Using QtConcurrent + + \snippet examples/tutorials/threads/helloconcurrent/helloconcurrent.cpp 1 + + We write a global function hello() to implement the work. QtConcurrent::run() + is used to run the function in another thread. The result is a QFuture. + QFuture provides a method called \l{QFuture::}{waitForFinished()}, which + blocks until the calculation is completed. The real power of QtConcurrent + becomes visible when data can be made available in a container. QtConcurrent + provides several functions that are able to process itemized data on all + available cores simultaneously. The use of QtConcurrent is very similar to + applying an STL algorithm to an STL container. + \l{examples-threadandconcurrent.html}{QtConcurrent Map} is a very short and + clear example about how a container of images can be scaled on all available + cores. The image scaling example uses the blocking variants of the functions + used. For every blocking function there is also a non-blocking, asynchronous + counterpart. Getting results asynchronously is implemented with QFuture and + QFutureWatcher. + + \section2 Example 3: Clock + + \image thread_clock.png "clock" + + We want to produce a clock application. The application has a GUI and a + worker thread. The worker thread checks every 10 milliseconds what time it + is. If the formatted time has changed, the result will be sent to the GUI + thread where it is displayed. + + Of course, this is an overly complicated way of designing a clock and, + actually, a separate thread is unnecessary. We would be better off placing + the timer in the main thread because the calculation made in the timer slot + is very short-lived. This example is purely for instructional use and shows + how to communicate from a worker thread to a GUI thread. Note that + communication in this direction is easy. We only need to add a signal + to QThread and make a queued signal/slot connection to the main thread. + Communication from the GUI to the worker thread is shown in the next + example. + + \snippet examples/tutorials/threads/clock/main.cpp 1 + + We've connected the \c clockThread with the label. The connection must be a + queued signal-slot connection because we want to put the call in the event + loop. + + \snippet examples/tutorials/threads/clock/clockthread.h 1 + + We have derived a class from QThread and declared the \c sendTime() signal. + + \snippet examples/tutorials/threads/clock/clockthread.cpp 1 + + The trickiest part of this example is that the timer is connected to its + slot via a direct connection. A default connection would produce a queued + signal-slot connection because the connected objects live in different + threads; remember that QThread does not live in the thread it creates. + + Still it is safe to access ClockThread::timerHit() from the worker thread + because ClockThread::timerHit() is private and only touches local variables + and a private member that isn't touched by public methods. + QDateTime::currentDateTime() isn't marked as thread-safe in Qt + documentation, however we can get away with using it in this small + example because we know that the QDateTime::currentDateTime() static + method isn't used in any other threads. + + \section2 Example 4: A Permanent Thread + + This example shows how it is possible to have a QObject in a worker thread + that accepts requests from the GUI thread, does polling using a timer and + continuously reports results back to the GUI thread. The actual work + including the polling must be implemented in a class derived from QObject. + We have called this class \c WorkerObject in the code shown below. The + thread-specific code is hidden in a class called \c Thread, derived from + QThread. + \c Thread has two additional public members. The \c launchWorker() member + takes the worker object and moves it to another thread with a started event + loop. + The call blocks for a very short moment until the thread creation operation + is completed, allowing the worker object to be used again on the next line. + The \c Thread class's code is short but somewhat involved, so we only show + how to use the class. + + \snippet examples/tutorials/threads/movedobject/main.cpp 1 + + QMetaObject::invokeMethod() calls a slot via the event loop. The worker + object's methods should not be called directly after the object has been + moved to another thread. We let the worker thread do some work and polling, + and use a timer to shut the application down after 3 seconds. Shutting the + worker down needs some care. We call \c{Thread::stop()} to exit the event + loop. We wait for the thread to terminate and, after this has occurred, we + delete the worker. + + \section1 Digging Deeper + + Threading is a very complicated subject. Qt offers more classes for + threading than we have presented in this tutorial. The following materials + can help you go into the subject in more depth: + + \list + \o Good video tutorials about threads with Qt can be found in the material + from the \l{Training Day at Qt Developer Days 2009}. + \o The \l{Thread Support in Qt} document is a good starting point into + the reference documentation. + \o Qt comes with several additional examples for + \l{Threading and Concurrent Programming Examples}{QThread and QtConcurrent}. + \o Several good books describe how to work with Qt threads. The most + extensive coverage can be found in \e{Advanced Qt Programming} by Mark + Summerfield, Prentice Hall - roughly 70 of 500 pages cover QThread and + QtConcurrent. + \endlist +*/ diff --git a/doc/src/tutorials/widgets-tutorial.qdoc b/doc/src/tutorials/widgets-tutorial.qdoc index 2125edc..4877339 100644 --- a/doc/src/tutorials/widgets-tutorial.qdoc +++ b/doc/src/tutorials/widgets-tutorial.qdoc @@ -27,6 +27,7 @@ /*! \page widgets-tutorial.html + \ingroup tutorials \title Widgets Tutorial \brief This tutorial covers basic usage of widgets and layouts, showing how they are used to build GUI applications. @@ -133,19 +134,13 @@ In the following example, we use QWidget to create and show a window with a default size: - \raw HTML - <table align="left" width="100%"> - <tr class="qt-code"><td> - \endraw - \snippet tutorials/widgets/toplevel/main.cpp main program - \raw HTML - </td><td align="right"> - \endraw - \inlineimage widgets-tutorial-toplevel.png - \raw HTML - </td></tr> - </table> - \endraw + \div {class="qt-code"} + \table + \row + \o \snippet tutorials/widgets/toplevel/main.cpp main program + \o \inlineimage widgets-tutorial-toplevel.png + \endtable + \enddiv To create a real GUI, we need to place widgets inside the window. To do this, we pass a QWidget instance to a widget's constructor, as we will @@ -161,19 +156,13 @@ passing \c window as the parent to its constructor. In this case, we add a button to the window and place it in a specific location: - \raw HTML - <table align="left" width="100%"> - <tr class="qt-code"><td> - \endraw - \snippet tutorials/widgets/childwidget/main.cpp main program - \raw HTML - </td><td align="right"> - \endraw - \inlineimage widgets-tutorial-childwidget.png - \raw HTML - </td></tr> - </table> - \endraw + \div {class="qt-code"} + \table + \row + \o \snippet tutorials/widgets/childwidget/main.cpp main program + \o \inlineimage widgets-tutorial-childwidget.png + \endtable + \enddiv The button is now a child of the window and will be deleted when the window is destroyed. Note that hiding or closing the window does not @@ -189,19 +178,13 @@ construct a label and line edit widget that we would like to arrange side-by-side. - \raw HTML - <table align="left" width="100%"> - <tr class="qt-code"><td> - \endraw - \snippet tutorials/widgets/windowlayout/main.cpp main program - \raw HTML - </td><td align="right"> - \endraw - \inlineimage widgets-tutorial-windowlayout.png - \raw HTML - </td></tr> - </table> - \endraw + \div {class="qt-code"} + \table + \row + \o \snippet tutorials/widgets/windowlayout/main.cpp main program + \o \inlineimage widgets-tutorial-windowlayout.png + \endtable + \enddiv The \c layout object we construct manages the positions and sizes of widgets supplied to it with the \l{QHBoxLayout::}{addWidget()} function. @@ -233,20 +216,14 @@ \c{mainLayout} is a QVBoxLayout that contains \c{queryLayout} and a QTableView arranged vertically. - \raw HTML - <table align="left" width="100%"> - <tr class="qt-code"><td> - \endraw - \snippet tutorials/widgets/nestedlayouts/main.cpp first part - \snippet tutorials/widgets/nestedlayouts/main.cpp last part - \raw HTML - </td><td align="right"> - \endraw - \inlineimage widgets-tutorial-nestedlayouts.png - \raw HTML - </td></tr> - </table> - \endraw + \div {class="qt-code"} + \table + \row + \o \snippet tutorials/widgets/nestedlayouts/main.cpp first part + \snippet tutorials/widgets/nestedlayouts/main.cpp last part + \o \inlineimage widgets-tutorial-nestedlayouts.png + \endtable + \enddiv Note that we call the \c{mainLayout}'s \l{QBoxLayout::}{addLayout()} function to insert the \c{queryLayout} above the \c{resultView} table. diff --git a/doc/src/widgets-and-layouts/layout.qdoc b/doc/src/widgets-and-layouts/layout.qdoc index c3db5fa..1d8214b 100644 --- a/doc/src/widgets-and-layouts/layout.qdoc +++ b/doc/src/widgets-and-layouts/layout.qdoc @@ -319,16 +319,16 @@ \section2 The Header File (\c card.h) - \snippet doc/src/snippets/code/doc_src_layout.qdoc 0 + \snippet doc/src/snippets/code/doc_src_layout.cpp 0 \section2 The Implementation File (\c card.cpp) - \snippet doc/src/snippets/code/doc_src_layout.qdoc 1 + \snippet doc/src/snippets/code/doc_src_layout.cpp 1 First we define \c{count()} to fetch the number of items in the list. - \snippet doc/src/snippets/code/doc_src_layout.qdoc 2 + \snippet doc/src/snippets/code/doc_src_layout.cpp 2 Then we define two functions that iterate over the layout: \c{itemAt()} and \c{takeAt()}. These functions are used internally by the layout system @@ -341,7 +341,7 @@ structure, we may have to spend more effort defining a linear order for the items. - \snippet doc/src/snippets/code/doc_src_layout.qdoc 3 + \snippet doc/src/snippets/code/doc_src_layout.cpp 3 \c{addItem()} implements the default placement strategy for layout items. This function must be implemented. It is used by QLayout::add(), by the @@ -351,26 +351,26 @@ QGridLayout::addItem(), QGridLayout::addWidget(), and QGridLayout::addLayout(). - \snippet doc/src/snippets/code/doc_src_layout.qdoc 4 + \snippet doc/src/snippets/code/doc_src_layout.cpp 4 The layout takes over responsibility of the items added. Since QLayoutItem does not inherit QObject, we must delete the items manually. In the destructor, we remove each item from the list using \c{takeAt()}, and then delete it. - \snippet doc/src/snippets/code/doc_src_layout.qdoc 5 + \snippet doc/src/snippets/code/doc_src_layout.cpp 5 The \c{setGeometry()} function actually performs the layout. The rectangle supplied as an argument does not include \c{margin()}. If relevant, use \c{spacing()} as the distance between items. - \snippet doc/src/snippets/code/doc_src_layout.qdoc 6 + \snippet doc/src/snippets/code/doc_src_layout.cpp 6 \c{sizeHint()} and \c{minimumSize()} are normally very similar in implementation. The sizes returned by both functions should include \c{spacing()}, but not \c{margin()}. - \snippet doc/src/snippets/code/doc_src_layout.qdoc 7 + \snippet doc/src/snippets/code/doc_src_layout.cpp 7 \section2 Further Notes diff --git a/doc/src/widgets-and-layouts/styles.qdoc b/doc/src/widgets-and-layouts/styles.qdoc index 8231fcb..9e9dd64 100644 --- a/doc/src/widgets-and-layouts/styles.qdoc +++ b/doc/src/widgets-and-layouts/styles.qdoc @@ -283,12 +283,12 @@ pointer type is correct. If the object isn't of the right type, qstyleoption_cast() returns 0. For example: - \snippet doc/src/snippets/code/doc_src_qt4-styles.qdoc 0 + \snippet doc/src/snippets/code/doc_src_qt4-styles.cpp 0 The following code snippet illustrates how to use QStyle to draw the focus rectangle from a custom widget's paintEvent(): - \snippet doc/src/snippets/code/doc_src_qt4-styles.qdoc 1 + \snippet doc/src/snippets/code/doc_src_qt4-styles.cpp 1 The next example shows how to derive from an existing style to customize the look of a graphical element: @@ -542,7 +542,7 @@ We start with a look at how QCheckBox builds it style option, which is QStyleOptionButton for checkboxes: - \snippet doc/src/snippets/code/doc_src_styles.qdoc 0 + \snippet doc/src/snippets/code/doc_src_styles.cpp 0 First we let QStyleOption set up the option with the information that is common for all widgets with \c initFrom(). We will look at @@ -561,7 +561,7 @@ attributes that are common for all widgets. We print its implementation here: - \snippet doc/src/snippets/code/doc_src_styles.qdoc 1 + \snippet doc/src/snippets/code/doc_src_styles.cpp 1 The State_Enabled is set when the widget is enabled. When the widget has focus the State_HasFocus flag is set. Equally, the @@ -625,7 +625,7 @@ notably, it wraps the methods in QStyle used for painting. The QCheckBox draws itself as follows: - \snippet doc/src/snippets/code/doc_src_styles.qdoc 2 + \snippet doc/src/snippets/code/doc_src_styles.cpp 2 QCommonStyle handles the CE_CheckBox element. The QCheckBox has two sub elements: SE_CheckBoxIndicator (the checked indicator) @@ -633,7 +633,7 @@ checkbox label). QCommonStyle also implements these sub element bounding rectangles. We have a look at the QCommonStyle code: - \snippet doc/src/snippets/code/doc_src_styles.qdoc 3 + \snippet doc/src/snippets/code/doc_src_styles.cpp 3 As can be seen from the code extract, the common style gets the bounding rectangles of the two sub elements of @@ -644,7 +644,7 @@ handles CE_CheckboxLabel. We will examine each implementation and start with CE_CheckBoxLabel: - \snippet doc/src/snippets/code/doc_src_styles.qdoc 4 + \snippet doc/src/snippets/code/doc_src_styles.cpp 4 \l{QStyle::}{visualAlignment()} adjusts the alignment of text according to the layout direction. We then draw an icon if it diff --git a/doc/src/widgets-and-layouts/stylesheet.qdoc b/doc/src/widgets-and-layouts/stylesheet.qdoc index be845c4..8cfa2b4 100644 --- a/doc/src/widgets-and-layouts/stylesheet.qdoc +++ b/doc/src/widgets-and-layouts/stylesheet.qdoc @@ -469,11 +469,11 @@ sheet. Consider the following example. First, we set a style sheet on the QApplication: - \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 21 + \snippet doc/src/snippets/code/doc_src_stylesheet.cpp 21 Then we set a style sheet on a QPushButton object: - \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 22 + \snippet doc/src/snippets/code/doc_src_stylesheet.cpp 22 The style sheet on the QPushButton forces the QPushButton (and any child widget) to have blue text, in spite of the more @@ -481,7 +481,7 @@ The result would have been the same if we had written - \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 23 + \snippet doc/src/snippets/code/doc_src_stylesheet.cpp 23 except that if the QPushButton had children (which is unlikely), the style sheet would have no impact on them. @@ -500,14 +500,14 @@ For example, consider a QPushButton inside a QGroupBox: - \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 24 + \snippet doc/src/snippets/code/doc_src_stylesheet.cpp 24 The QPushButton does not have an explicit color set. Hence, instead of inheriting color of its parent QGroupBox, it has the system color. If we want to set the color on a QGroupBox and its children, we can write: - \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 25 + \snippet doc/src/snippets/code/doc_src_stylesheet.cpp 25 In contrast, setting a font and propagate using QWidget::setFont() and QWidget::setPalette() propagates to child widgets. @@ -517,7 +517,7 @@ The Type Selector can be used to style widgets of a particular type. For example, - \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 26 + \snippet doc/src/snippets/code/doc_src_stylesheet.cpp 26 Qt Style Sheet uses QObject::className() of the widget to determine when to apply the Type Selector. When custom widgets are inside namespaces, @@ -526,7 +526,7 @@ when using the Type Selector for widgets inside namespaces, we must replace the "::" with "--". For example, - \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 27 + \snippet doc/src/snippets/code/doc_src_stylesheet.cpp 27 \section1 Setting QObject properties @@ -1328,7 +1328,7 @@ If you subclass from QWidget, you need to provide a paintEvent for your custom QWidget as below: - \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 32 + \snippet doc/src/snippets/code/doc_src_stylesheet.cpp 32 The above code is a no-operation if there is no stylesheet set. @@ -3373,35 +3373,35 @@ \l{QLineEdit}s in an application. This could be achieved like this: - \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 88 + \snippet doc/src/snippets/code/doc_src_stylesheet.cpp 88 If we want the property to apply only to the \l{QLineEdit}s that are children (or grandchildren or grand-grandchildren) of a specific dialog, we would rather do this: - \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 89 + \snippet doc/src/snippets/code/doc_src_stylesheet.cpp 89 If we want the property to apply only to one specific QLineEdit, we can give it a name using QObject::setObjectName() and use an ID Selector to refer to it: - \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 90 + \snippet doc/src/snippets/code/doc_src_stylesheet.cpp 90 Alternatively, we can set the \l{Qt Style Sheets Reference#background-prop}{background-color} property directly on the QLineEdit, omitting the selector: - \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 91 + \snippet doc/src/snippets/code/doc_src_stylesheet.cpp 91 To ensure a good contrast, we should also specify a suitable color for the text: - \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 92 + \snippet doc/src/snippets/code/doc_src_stylesheet.cpp 92 It might be a good idea to change the colors used for selected text as well: - \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 93 + \snippet doc/src/snippets/code/doc_src_stylesheet.cpp 93 \section2 Customizing Using Dynamic Properties @@ -3422,7 +3422,7 @@ \c mandatoryField property on the fly and set it to true. For example: - \snippet doc/src/snippets/code/doc_src_stylesheet.qdoc 95 + \snippet doc/src/snippets/code/doc_src_stylesheet.cpp 95 \section2 Customizing a QPushButton Using the Box Model diff --git a/doc/src/windows-and-dialogs/mainwindow.qdoc b/doc/src/windows-and-dialogs/mainwindow.qdoc index 0bf4909..e7df502 100644 --- a/doc/src/windows-and-dialogs/mainwindow.qdoc +++ b/doc/src/windows-and-dialogs/mainwindow.qdoc @@ -198,7 +198,7 @@ the first time it is called. You can also call QMainWindow::setMenuBar() to use a custom menu bar in the main window. - \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.qdoc 0 + \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.cpp 0 \dots \snippet examples/mainwindows/menus/mainwindow.cpp 5 \dots @@ -222,7 +222,7 @@ \snippet examples/mainwindows/sdi/mainwindow.cpp 0 \dots - \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.qdoc 1 + \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.cpp 1 In this example, the toolbar is restricted to the top and bottom toolbar areas of the main window, and is initially placed in the @@ -244,7 +244,7 @@ required, the default can be changed with the QMainWindow::setCorner() function: - \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.qdoc 2 + \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.cpp 2 The following diagram shows the configuration produced by the above code. Note that the left and right dock widgets will occupy the top and bottom @@ -255,7 +255,7 @@ Once all of the main window components have been set up, the central widget is created and installed by using code similar to the following: - \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.qdoc 3 + \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.cpp 3 The central widget can be any subclass of QWidget. */ diff --git a/doc/src/zh_CN/getting-started/how-to-learn-qt.qdoc b/doc/src/zh_CN/getting-started/how-to-learn-qt.qdoc index ad2d702..f734e43 100644 --- a/doc/src/zh_CN/getting-started/how-to-learn-qt.qdoc +++ b/doc/src/zh_CN/getting-started/how-to-learn-qt.qdoc @@ -41,7 +41,7 @@ 现在您已经编写了一些小型可用的应用程序,并对 Qt 编程有更加广泛的了解。您可以直接着手做自己的项目,但我们建议您阅读以下一些关键简介以加深您对 Qt 的了解:\l{Qt Object Model}Qt 对象模型}和\l{Signals and Slots}{信号和槽}。 - \div {float-left} + \div {class="float-left"} \inlineimage qtdemo-small.png \enddiv |