diff options
author | David Boddie <dboddie@trolltech.com> | 2010-05-20 13:24:30 (GMT) |
---|---|---|
committer | David Boddie <dboddie@trolltech.com> | 2010-05-20 13:24:30 (GMT) |
commit | ba2cc78943678173d21a4339839e63d16fe774a9 (patch) | |
tree | 691ac2916d5daf948cdac07bc4ef19d08f36cabd /doc/src | |
parent | 8f47373e3795d7ec50387d5f1a771a59567bdaea (diff) | |
parent | ef8cd7f2e68d6d34d70c3a12e82a67ed16b92b72 (diff) | |
download | Qt-ba2cc78943678173d21a4339839e63d16fe774a9.zip Qt-ba2cc78943678173d21a4339839e63d16fe774a9.tar.gz Qt-ba2cc78943678173d21a4339839e63d16fe774a9.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.7
Diffstat (limited to 'doc/src')
36 files changed, 682 insertions, 295 deletions
diff --git a/doc/src/declarative/examples.qdoc b/doc/src/declarative/examples.qdoc index cdc308a..a355f9f 100644 --- a/doc/src/declarative/examples.qdoc +++ b/doc/src/declarative/examples.qdoc @@ -75,14 +75,13 @@ For example, from your build directory, run: \list \o \l{declarative/animation/basics}{Basics} \o \l{declarative/animation/behaviors}{Behaviors} -\o \l{declarative/animation/easing}{Easing} +\o \l{declarative/animation/easing}{Easing types} \o \l{declarative/animation/states}{States} \endlist \section2 Image Elements \list \o \l{declarative/imageelements/borderimage}{BorderImage} -\o \l{declarative/imageelements/image}{Image} \endlist \section2 \l{declarative/positioners}{Positioners} @@ -122,7 +121,6 @@ For example, from your build directory, run: \section2 XML \list -\o \l{declarative/xml/xmldata}{XML data} \o \l{declarative/xml/xmlhttprequest}{XmlHttpRequest} \endlist @@ -138,22 +136,22 @@ For example, from your build directory, run: \section2 C++ Extensions \list -\o \l{declarative/cppextensions/referenceexamples}{Reference examples} (discussed in \l {Extending QML in C++}) +\o \l{declarative-cppextensions-reference.html}{Reference examples} (discussed in \l {Extending QML in C++}) \o \l{declarative/cppextensions/plugins}{Plugins} -\o \l{declarative/cppextensions/proxywidgets}{QtWidgets} -\o \l{declarative/cppextensions/qgraphicslayouts}{QGraphicsLayouts} +\o \l{declarative-cppextensions-qgraphicslayouts.html}{QGraphicsLayouts} +\o \l{declarative/cppextensions/qwidgets}{QWidgets} \o \l{declarative/cppextensions/imageprovider}{Image provider} -\o \l{declarative/cppextensions/proxyviewer}{Network access manager factory} +\o \l{declarative/cppextensions/networkaccessmanagerfactory}{Network access manager factory} \endlist \section2 Toys \list \o \l{declarative/toys/clocks}{Clocks} +\o \l{declarative/toys/corkboards}{Corkboards} \o \l{declarative/toys/dial}{Dial} -\o \l{declarative/toys/dynamic}{Dynamic} +\o \l{declarative/toys/dynamicscene}{Dynamic Scene} \o \l{declarative/toys/tic-tac-toe}{Tic Tac Toe} \o \l{declarative/toys/tvtennis}{TV Tennis} -\o \l{declarative/toys/velocity}{Velocity} \endlist @@ -161,12 +159,19 @@ For example, from your build directory, run: \list \o \l{demos/declarative/calculator}{Calculator} +\o \l{demos/declarative/flickr}{Flickr Mobile} \o \l{demos/declarative/minehunt}{Minehunt} \o \l{demos/declarative/photoviewer}{Photo Viewer} -\o \l{demos/declarative/flickr}{Flickr Mobile} +\o \l{demos/declarative/rssnews}{RSS News Reader} \o \l{demos/declarative/samegame}{Same Game} \o \l{demos/declarative/snake}{Snake} \endlist +\section1 Labs + +\list +\o \l{src/imports/folderlistmodel}{Folder List Model} - a C++ model plugin +\endlist + */ diff --git a/doc/src/declarative/extending.qdoc b/doc/src/declarative/extending.qdoc index 5b695f7..574b0b2 100644 --- a/doc/src/declarative/extending.qdoc +++ b/doc/src/declarative/extending.qdoc @@ -61,8 +61,11 @@ QML for their own independent use. The QML snippet shown above instantiates one \c Person instance and sets the \c name and \c shoeSize properties on it. Everything in QML ultimately comes down to either instantiating an object instance, or assigning a property a value. + QML relies heavily on Qt's meta object system and can only instantiate classes -that derive from QObject. +that derive from QObject. For visual element types, this will usually mean a subclass +of QDeclarativeItem; for models used with the view elements, a subclass of QAbstractItemModel; +and for abitrary objects with properties, a direct subclass of QObject. The QML engine has no intrinsic knowledge of any class types. Instead the programmer must register the C++ types with their corresponding QML names. diff --git a/doc/src/declarative/focus.qdoc b/doc/src/declarative/focus.qdoc index e2b8bb6..4c4a317 100644 --- a/doc/src/declarative/focus.qdoc +++ b/doc/src/declarative/focus.qdoc @@ -67,7 +67,12 @@ item and thus subsequently be \l {QEvent::ignore()}{ignored}. \code Item { Item { - Keys.onPressed: if (event.key == Qt.Key_A) { console.log('Key A was pressed'); event.accepted = true } + Keys.onPressed: { + if (event.key == Qt.Key_A) { + console.log('Key A was pressed'); + event.accepted = true; + } + } Rectangle {} } } diff --git a/doc/src/declarative/globalobject.qdoc b/doc/src/declarative/globalobject.qdoc index 2a83e30..bd0a9f5 100644 --- a/doc/src/declarative/globalobject.qdoc +++ b/doc/src/declarative/globalobject.qdoc @@ -219,8 +219,9 @@ Binary to ASCII - this function returns a base64 encoding of \c data. ASCII to binary - this function returns a base64 decoding of \c data. \section3 Qt.quit() -This function causes the QML engine to emit the quit signal, which in -\l {Qt Declarative UI Runtime}{qml} causes the runtime to quit. +This function causes the QDeclarativeEngine::quit() signal to be emitted. +Within the \l {Qt Declarative UI Runtime}{qml} application this causes the +launcher application to exit. \section3 Qt.resolvedUrl(url) This function returns \c url resolved relative to the URL of the @@ -257,7 +258,7 @@ If you are certain the files will be local, you could simplify to: The methods and properties of the Component element are defined in its own page, but when using it dynamically only two methods are usually used. \c Component.createObject() returns the created object or \c null if there is an error. -If there is an error, \l {Component::errorsString()}{Component.errorsString()} describes +If there is an error, \l {Component::errorString()}{Component.errorString()} describes the error that occurred. Note that createObject() takes exactly one argument, which is set to the parent of the created object. Graphical objects without a parent will not appear on the scene, but if you do not wish to parent the item at this point you can safely pass diff --git a/doc/src/declarative/integrating.qdoc b/doc/src/declarative/integrating.qdoc index 83380a1..c6f754b 100644 --- a/doc/src/declarative/integrating.qdoc +++ b/doc/src/declarative/integrating.qdoc @@ -110,7 +110,7 @@ of QML UIs: \section2 Loading QGraphicsWidget objects in QML 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}{graphics layouts example} +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. diff --git a/doc/src/declarative/pics/trivialListView.png b/doc/src/declarative/pics/listview-highlight.png Binary files differindex dc5c6b3..dc5c6b3 100644 --- a/doc/src/declarative/pics/trivialListView.png +++ b/doc/src/declarative/pics/listview-highlight.png diff --git a/doc/src/declarative/pics/listview-simple.png b/doc/src/declarative/pics/listview-simple.png Binary files differnew file mode 100644 index 0000000..71a1c51 --- /dev/null +++ b/doc/src/declarative/pics/listview-simple.png diff --git a/doc/src/declarative/qdeclarativemodels.qdoc b/doc/src/declarative/qdeclarativemodels.qdoc index 788d417..109d390 100644 --- a/doc/src/declarative/qdeclarativemodels.qdoc +++ b/doc/src/declarative/qdeclarativemodels.qdoc @@ -99,7 +99,8 @@ There are a number of QML elements that operate using data models: \endlist QML supports several types of data model, which may be provided by QML -or C++ (via QDeclarativeContext::setContextProperty(), for example). +or C++ (via QDeclarativeContext::setContextProperty() or as plugin types, +for example). \section1 QML Data Models @@ -210,8 +211,13 @@ will be positioned by the view. \section1 C++ Data Models +Models defined in C++ can be made available to QML either from a C++ application or from a +\l{QDeclarativeExtensionPlugin}{QML C++ plugin}. + \section2 QAbstractItemModel +A model can be defined by subclassing QAbstractItemModel. + QAbstractItemModel provides the roles set via the QAbstractItemModel::setRoleNames() method. The default role names set by Qt are: @@ -227,7 +233,18 @@ The default role names set by Qt are: \o decoration \endtable -QAbstractItemModel presents a heirachy of tables. Views currently provided by QML +The model could be made available to QML either directly: + +\code +QDeclarativeContext *ctxt = view.rootContext(); +MyModel *model = new MyModel; // subclass of QAbstractItemModel +ctxt->setContextProperty("myModel", model); +\endcode + +or by registering the subclass as a new QML type in +a \l{QDeclarativeExtensionPlugin}{QML C++ plugin}. + +QAbstractItemModel presents a heirachy of tables, but views currently provided by QML can only display list data. In order to display child lists of a heirachical model the VisualDataModel element provides several properties and functions for use @@ -242,7 +259,7 @@ with models of type QAbstractItemModel: \section2 QStringList -QStringList provides the contents of the list via the \e modelData role: +A model may be a simple QStringList, which provides the contents of the list via the \e modelData role: \table \row diff --git a/doc/src/declarative/qmlruntime.qdoc b/doc/src/declarative/qmlruntime.qdoc index b105df4..cef5e63 100644 --- a/doc/src/declarative/qmlruntime.qdoc +++ b/doc/src/declarative/qmlruntime.qdoc @@ -42,17 +42,17 @@ /*! \page qmlruntime.html \title Qt Declarative UI Runtime - \keyword qml runtime + \keyword QML Viewer \ingroup qttools This page documents the \e{Declarative UI Runtime} for the Qt GUI - toolkit, and the \QQL which can be used to run apps - written for the runtime. The \QQL reads a declarative + toolkit, and the \QQV which can be used to run apps + written for the runtime. The \QQV reads a declarative user interface definition (\c .qml) file and displays the user interface it describes. QML is a runtime, as you can run plain QML files which pull in their required modules. To run apps with the QML runtime, you can either start the runtime - from your own application (using a QDeclarativeView) or with the simple \QQL. + from your own application (using a QDeclarativeView) or with the simple \QQV. The launcher can be installed in a production environment, assuming that it is not already present in the system. It is generally packaged alongside Qt. @@ -61,16 +61,16 @@ \list \o Write your own Qt application including a QDeclarative view and deploy it the same as any other Qt application (not discussed further on this page), or - \o Write a main QML file for your application, and run your application using the included \QQL. + \o Write a main QML file for your application, and run your application using the included \QQV. \endlist - To run an application with the \QQL, pass the filename as an argument: + To run an application with the \QQV, pass the filename as an argument: \code - qml myQmlFile.qml + qmlviewer myQmlFile.qml \endcode - Deploying a QML application via the \QQL allows for QML only deployments, but can also + Deploying a QML application via the \QQV allows for QML only deployments, but can also include custom C++ modules just as easily. Below is an example of how you might structure a complex application deployed via the QML runtime, it is a listing of the files that would be included in the deployment package. @@ -92,8 +92,8 @@ as the appropriate module file is chosen based on platform naming conventions. The C++ modules must contain a QDeclarativeExtentionPlugin subclass. - The application would be executed either with your own application, the command 'qml MyApp.qml' or by - opening the file if your system has the \QQL registered as the handler for QML files. The MyApp.qml file would have access + The application would be executed either with your own application, the command 'qmlviewer MyApp.qml' or by + opening the file if your system has the \QQV registered as the handler for QML files. The MyApp.qml file would have access to all of the deployed types using the import statements such as the following: \code @@ -101,15 +101,15 @@ import "OtherModule" 1.0 as Other \endcode - \section1 Qt QML Launcher functionality - The \QQL implements some additional functionality to help it supporting + \section1 Qt QML Viewer functionality + The \QQV implements some additional functionality to help it supporting myriad applications. If you implement your own application, you may also wish to reimplement some or all of this functionality. However, much of this functionality is intended to aid the prototyping of QML applications and may not be necessary for a deployed application. \section2 Options - When run with the \c -help option, \c qml shows available options. + When run with the \c -help option, \c qmlviewer shows available options. \section2 Translations diff --git a/doc/src/diagrams/modelview-move-rows-3.sk b/doc/src/diagrams/modelview-move-rows-3.sk index 33a9ad1..6c28bb9 100644 --- a/doc/src/diagrams/modelview-move-rows-3.sk +++ b/doc/src/diagrams/modelview-move-rows-3.sk @@ -2,136 +2,135 @@ document() layout('A4',0) layer('Layer 1',1,1,0,0,(0,0,0)) +G() fp((1,1,1)) lw(1) -r(30,0,0,-30,220,425) +r(30,0,0,-30,211.449,486.649) fp((1,1,1)) lw(1) -r(30,0,0,-30,344.997,400) +r(30,0,0,-30,336.446,461.649) lw(1) -r(30,0,0,-30,220,335) +r(30,0,0,-30,211.449,396.649) lw(1) -r(30,0,0,-30,345,339.739) +r(30,0,0,-30,336.449,401.388) fp((1,1,1)) lw(1) -r(30,0,0,-30,220,305.262) +r(30,0,0,-30,211.449,366.911) fp((1,1,1)) lw(1) -r(30,0,0,-30,345,310) +r(30,0,0,-30,336.449,371.649) fp((1,1,1)) lw(1) -r(30,0,0,-30,220,455) +r(30,0,0,-30,211.449,516.649) fp((1,1,1)) lw(1) -r(30,0,0,-30,344.997,430) +r(30,0,0,-30,336.446,491.649) lw(1) -r(30,0,0,-30,220,365) +r(30,0,0,-30,211.449,426.649) lw(1) -r(30,0,0,-30,345,369.739) +r(30,0,0,-30,336.449,431.388) fp((0.753,0.753,1)) lw(1) -r(30,0,0,-30,272.5,455) +r(30,0,0,-30,263.949,516.649) fp((0.753,0.753,1)) lw(1) -r(30,0,0,-30,345,460) +r(30,0,0,-30,336.449,521.649) fp((0.753,0.753,1)) lw(1) -r(30,0,0,-30,220,395) -le() -lw(1) -r(165,0,0,-230,210,705) +r(30,0,0,-30,211.449,456.649) fp((0,0,0)) le() lw(1) Fn('Helvetica') Fs(20) -txt('0',(229.44,433.14)) +txt('0',(220.889,494.789)) fp((0.503,0.503,0.503)) le() lw(1) Fn('Helvetica') Fs(20) -txt('0',(354.437,408.14)) +txt('0',(345.886,469.789)) fp((0,0,0)) le() lw(1) Fn('Helvetica') Fs(20) -txt('1',(229.44,403.14)) +txt('1',(220.889,464.789)) fp((0.503,0.503,0.503)) le() lw(1) Fn('Helvetica') Fs(20) -txt('1',(354.437,378.14)) +txt('1',(345.886,439.789)) fp((0,0,0)) le() lw(1) Fn('Helvetica') Fs(20) -txt('2',(281.94,433.14)) +txt('2',(273.389,494.789)) fp((0,0,0)) le() lw(1) Fn('Helvetica') Fs(20) -txt('2',(354.44,438.14)) +txt('2',(345.889,499.789)) fp((0,0,0)) le() lw(1) Fn('Helvetica') Fs(20) -txt('2',(229.44,373.14)) +txt('2',(220.889,434.789)) fp((0,0,0)) le() lw(1) Fn('Helvetica') Fs(20) -txt('3',(229.44,343.14)) +txt('3',(220.889,404.789)) fp((0,0,0)) le() lw(1) Fn('Helvetica') Fs(20) -txt('3',(354.44,347.879)) +txt('3',(345.889,409.528)) fp((0,0,0)) le() lw(1) Fn('Helvetica') Fs(20) -txt('4',(229.44,313.14)) +txt('4',(220.889,374.789)) fp((0,0,0)) le() lw(1) Fn('Helvetica') Fs(20) -txt('4',(354.44,317.879)) +txt('4',(345.889,379.528)) fp((0,0,0)) le() lw(1) Fn('Helvetica') Fs(20) -txt('5',(229.133,283.402)) +txt('5',(220.582,345.051)) fp((0,0,0)) le() lw(1) Fn('Helvetica') Fs(20) -txt('5',(355.049,288.14)) +txt('5',(346.498,349.789)) lw(1.5) la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1)) b() -bs(272.5,455,0) -bs(252.5,455,0) +bs(263.949,516.649,0) +bs(243.949,516.649,0) lw(1.5) la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1)) b() -bs(287.5,380,0) -bs(287.5,422.5,0) +bs(278.949,441.649,0) +bs(278.949,484.149,0) lw(1.5) la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1)) b() -bs(250,380,0) -bs(285,380,0) +bs(241.449,441.649,0) +bs(276.449,441.649,0) +G_() guidelayer('Guide Lines',1,0,0,1,(0,0,1)) grid((0,0,2.5,2.5),1,(0,0,1),'Grid') diff --git a/doc/src/diagrams/modelview-move-rows-4.sk b/doc/src/diagrams/modelview-move-rows-4.sk index 0531749..c74fd28 100644 --- a/doc/src/diagrams/modelview-move-rows-4.sk +++ b/doc/src/diagrams/modelview-move-rows-4.sk @@ -2,136 +2,135 @@ document() layout('A4',0) layer('Layer 1',1,1,0,0,(0,0,0)) +G() fp((1,1,1)) lw(1) -r(30,0,0,-30,220,425) +r(30,0,0,-30,211.449,482.601) fp((1,1,1)) lw(1) -r(30,0,0,-30,345,430) +r(30,0,0,-30,336.449,487.601) lw(1) -r(30,0,0,-30,220,335.18) +r(30,0,0,-30,211.449,392.781) lw(1) -r(30,0,0,-30,345,339.739) +r(30,0,0,-30,336.449,397.34) fp((1,1,1)) lw(1) -r(30,0,0,-30.442,220,305.442) +r(30,0,0,-30.442,211.449,363.043) fp((1,1,1)) lw(1) -r(30,0,0,-30,345,310) +r(30,0,0,-30,336.449,367.601) fp((1,1,1)) lw(1) -r(30,0,0,-30,220,455) +r(30,0,0,-30,211.449,512.601) fp((1,1,1)) lw(1) -r(30,0,0,-30,345,460) +r(30,0,0,-30,336.449,517.601) lw(1) -r(30,0,0,-30,220,365) +r(30,0,0,-30,211.449,422.601) lw(1) -r(30,0,0,-30,345,400) +r(30,0,0,-30,336.449,457.601) fp((0.753,0.753,1)) lw(1) -r(30,0,0,-30,272.5,335) +r(30,0,0,-30,263.949,392.601) fp((0.753,0.753,1)) lw(1) -r(30,0,0,-30,345,370) +r(30,0,0,-30,336.449,427.601) fp((0.753,0.753,1)) lw(1) -r(30,0,0,-30,220,395) -le() -lw(1) -r(165,0,0,-230,210,705) +r(30,0,0,-30,211.449,452.601) fp((0,0,0)) le() lw(1) Fn('Helvetica') Fs(20) -txt('0',(229.44,433.14)) +txt('0',(220.889,490.741)) fp((0,0,0)) le() lw(1) Fn('Helvetica') Fs(20) -txt('0',(354.44,438.14)) +txt('0',(345.889,495.741)) fp((0,0,0)) le() lw(1) Fn('Helvetica') Fs(20) -txt('1',(229.44,403.14)) +txt('1',(220.889,460.741)) fp((0,0,0)) le() lw(1) Fn('Helvetica') Fs(20) -txt('1',(354.44,408.14)) +txt('1',(345.889,465.741)) fp((0,0,0)) le() lw(1) Fn('Helvetica') Fs(20) -txt('2',(281.94,313.14)) +txt('2',(273.389,370.741)) fp((0,0,0)) le() lw(1) Fn('Helvetica') Fs(20) -txt('2',(354.44,348.14)) +txt('2',(345.889,405.741)) fp((0,0,0)) le() lw(1) Fn('Helvetica') Fs(20) -txt('2',(229.44,373.14)) +txt('2',(220.889,430.741)) fp((0,0,0)) le() lw(1) Fn('Helvetica') Fs(20) -txt('3',(229.44,343.14)) +txt('3',(220.889,400.741)) fp((0.503,0.503,0.503)) le() lw(1) Fn('Helvetica') Fs(20) -txt('3',(354.44,378.14)) +txt('3',(345.889,435.741)) fp((0,0,0)) le() lw(1) Fn('Helvetica') Fs(20) -txt('4',(229.44,313.14)) +txt('4',(220.889,370.741)) fp((0,0,0)) le() lw(1) Fn('Helvetica') Fs(20) -txt('4',(354.44,317.879)) +txt('4',(345.889,375.48)) fp((0,0,0)) le() lw(1) Fn('Helvetica') Fs(20) -txt('5',(229.44,283.582)) +txt('5',(220.889,341.183)) fp((0,0,0)) le() lw(1) Fn('Helvetica') Fs(20) -txt('5',(354.44,288.14)) +txt('5',(345.889,345.741)) lw(1.5) la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1)) b() -bs(272.5,335,0) -bs(252.5,335,0) +bs(263.949,392.601,0) +bs(243.949,392.601,0) lw(1.5) la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1)) b() -bs(287.5,380,0) -bs(287.5,337.5,0) +bs(278.949,437.601,0) +bs(278.949,395.101,0) lw(1.5) la2(([(-4.0, 3.0), (2.0, 0.0), (-4.0, -3.0), (-4.0, 3.0)], 1)) b() -bs(250,380,0) -bs(285,380,0) +bs(241.449,437.601,0) +bs(276.449,437.601,0) +G_() guidelayer('Guide Lines',1,0,0,1,(0,0,1)) grid((0,0,2.5,2.5),1,(0,0,1),'Grid') diff --git a/doc/src/examples/qml-examples.qdoc b/doc/src/examples/qml-examples.qdoc index 22113ee..c2237d6 100644 --- a/doc/src/examples/qml-examples.qdoc +++ b/doc/src/examples/qml-examples.qdoc @@ -40,76 +40,130 @@ ****************************************************************************/ /*! - \title Animation basics + \title Animation: Basics \example declarative/animation/basics - This example shows how to use animations in QML. + This example shows how to create \l{QML Animation}{animations} in QML. */ /*! - \title Behaviors + \title Animation: Behaviors \example declarative/animation/behaviors + + This example shows how to use QML behaviors. */ /*! - \title Easing types + \title Animation: Easing types \example declarative/animation/easing - This example shows the different easing modes available for animations. + This example shows the different easing modes available for \l{QML Animation}{animations}. */ /*! - \title States + \title Animation: States \example declarative/animation/states + + This example shows how to use \l{States}{states} and \l{Transitions}{transitions}. */ /*! - \title Border Image + \title Image Elements: Border Image \example declarative/imageelements/borderimage - This example shows how to use a BorderImage in QML. + This example shows how to use the BorderImage element. */ /*! - \title Image - \example declarative/imageelements/image + \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 + documentation, which highlights the main principles demonstrated in each example. - This example shows uses of the \l Image element in QML. + Furthermore, here are additional pages that discuss each example in detail: + + \list + \o \l {declarative/cppextensions/referenceexamples/adding}{Adding Types} + \o \l {declarative/cppextensions/referenceexamples/properties}{Object and List Property Types} + \o \l {declarative/cppextensions/referenceexamples/coercion}{Inheritance and Coercion} + \o \l {declarative/cppextensions/referenceexamples/default}{Default Property} + \o \l {declarative/cppextensions/referenceexamples/grouped}{Grouped Properties} + \o \l {declarative/cppextensions/referenceexamples/attached}{Attached Properties} + \o \l {declarative/cppextensions/referenceexamples/signal}{Signal Support} + \o \l {declarative/cppextensions/referenceexamples/valuesource}{Property Value Source} + \o \l {declarative/cppextensions/referenceexamples/binding}{Binding} + \endlist + + \note These examples all print information to the console to demonstrate the concepts presented. + Ensure that you are able to view the application output when running these examples. + For example, the dbgView tool on Windows can be used to display application output. */ /*! - \title Reference examples - \example declarative/cppextensions/referenceexamples + \title C++ Extensions: Plugins + \example declarative/cppextensions/plugins + + This example shows how to create a C++ plugin extension by subclassing QDeclarativeExtensionPlugin. */ /*! - \title Plugins - \example declarative/cppextensions/plugins + \title Graphics Layouts + \example declarative/cppextensions/qgraphicslayouts/graphicsLayouts + + This example show how to integrate Qt \l{Graphics View Framework}{Graphics View} components + like QGraphicsLayoutItem, QGraphicsLinearLayout and QGraphicsGridLayout into QML. */ +/*! + \title Layout Item + \example declarative/cppextensions/qgraphicslayouts/layoutItem + This example show how to integrate QML into an existing + \l{Graphics View Framework}{Graphics View}-based application. +*/ /*! - \title QtWidgets - \example declarative/cppextensions/proxywidgets + \page declarative-cppextensions-qgraphicslayouts.html + \title C++ Extensions: QGraphicsLayouts + + These examples show how to integrate \l{Graphics View Framework}{Graphics View} + layout components with QML: + + \list + \o \l{declarative/cppextensions/qgraphicslayouts/graphicsLayouts}{Graphics Layouts} + \o \l{declarative/cppextensions/qgraphicslayouts/layoutItem}{Layout Item} + \endlist */ /*! - \title QGraphicsLayouts - \example declarative/cppextensions/qgraphicslayouts + \title C++ Extensions: QWidgets + \example declarative/cppextensions/qwidgets + + This example shows how to embed QWidget-based objects into QML using QGraphicsProxyWidget. */ /*! - \title Image Provider + \title C++ Extensions: Image Provider \example declarative/cppextensions/imageprovider + + This examples shows how to use QDeclarativeImageProvider to serve images asynchronously + into a QML item. */ /*! - \title Network access manager - \example declarative/cppextensions/proxyviewer + \title C++ Extensions: Network access manager + \example declarative/cppextensions/networkaccessmanagerfactory + + This example shows how to use QDeclarativeNetworkAccessManagerFactory to create a QNetworkAccessManager + with a proxy. */ /*! \title Internationlization \example declarative/i18n + + This example shows how to enable text translation in QML. */ /*! @@ -121,7 +175,7 @@ */ /*! - \title Focus + \title Key Interaction: Focus \example declarative/keyinteraction/focus This example shows how to handle keys and focus in QML. @@ -130,149 +184,204 @@ */ /*! - \title GridView + \title Models and Views: GridView \example declarative/modelviews/gridview + + This example shows how to use the GridView element. */ /*! - \title ListView + \title Models and Views: ListView \example declarative/modelviews/listview + + This example shows how to use the ListView element. */ /*! - \title Object ListModel + \title Models and Views: Object ListModel \example declarative/modelviews/objectlistmodel + + This example shows how to create a C++ extension that exposes a + QList<QObject*> as a model in QML. */ /*! - \title Package + \title Models and Views: Package \example declarative/modelviews/package + + This example shows how to use the Package element. */ /*! - \title Parallax + \title Models and Views: Parallax \example declarative/modelviews/parallax + + This example shows how to combine and switch between views. */ /*! - \title String ListModel + \title Models and Views: String ListModel \example declarative/modelviews/stringlistmodel + + This example shows how to create a C++ extension that exposes a + QStringList as a model in QML. */ /*! - \title WebView + \title Models and Views: WebView \example declarative/modelviews/webview + + This example shows how to use the WebView element. */ /*! \title SQL Local Storage \example declarative/sqllocalstorage + + This example shows how to use the SQL Local Storage API in QML. */ /*! - \title Fonts + \title Text: Fonts \example declarative/text/fonts + + This example shows how to discover available fonts from QML and use + fonts in different ways. */ /*! - \title Threaded ListModel + \title Threading: Threaded ListModel \example declarative/threading/threadedlistmodel + + This example shows how to use a ListModel from multiple threads using + WorkerScript. */ /*! - \title WorkerScript + \title Threading: WorkerScript \example declarative/threading/workerscript + + This example shows how to use the WorkerScript element for threading in QML. */ /*! - \title Clocks + \title Toys: Clocks \example declarative/toys/clocks - This example shows how to create a Clock component and reuse it in a grid. + 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 + and \l SpringFollow animations. */ /*! - \title Dial + \title Toys: Corkboards + \example declarative/toys/corkboards + + This example presents a flickable set of interactive corkboards. It is created + through a combination of elements like \l ListModel, \l Repeater and \l TextEdit + together with rotation and scaling transforms, animation and mouse interaction. +*/ + +/*! + \title Toys: Dial \example declarative/toys/dial - This example shows how to implement a dial in QML. + This example presents an interactive speedometer-type dial by combining + \l Image elements with \l Rotation transforms and \l SpringFollow animations. */ /*! - \title Dynamic - \example declarative/toys/dynamic + \title Toys: Dynamic Scene + \example declarative/toys/dynamicscene - This example shows how to create dynamic objects QML. + This example presents an interactive drag-and-drop scene. It demonstrates + how to use QML's \l{Dynamic Object Creation} support to dynamically create and + destroy objects. */ /*! - \title Tic-Tac-Toe + \title Toys: Tic-Tac-Toe \example declarative/toys/tic-tac-toe + + This example presents a simple implementation of Tic Tac Toe. */ /*! - \title TV Tennis + \title Toys: TV Tennis \example declarative/toys/tvtennis -*/ -/*! - \title Velocity - \example declarative/toys/velocity + This example shows how to use animation components such as \l SpringFollow, + \l SequentialAnimation and \l PropertyAction to create a game of TV tennis. */ /*! - \title Gestures + \title Touch Interaction: Gestures \example declarative/touchinteraction/gestures + + This example shows how to use the GestureArea element. */ /*! - \title Mouse Area + \title Touch Interaction: Mouse Area \example declarative/touchinteraction/mousearea + + This example shows how to use the MouseArea element. */ /*! - \title Flipable + \title UI Components: Flipable \example declarative/ui-components/flipable - This example shows how to use a Flipable element in QML. + This example shows how to use the Flipable element. */ /*! - \title Progress Bars + \title UI Components: Progress Bars \example declarative/ui-components/progressbar + + This example shows how to create a progress bar. */ /*! - \title Scrollbar + \title UI Components: Scroll Bar \example declarative/ui-components/scrollbar + + This example shows how to create scroll bars for a Flickable element + using the \l {Flickable::visibleArea.xPosition}{Flickable::visibleArea} + properties. */ /*! - \title Search Box + \title UI Components: Search Box \example declarative/ui-components/searchbox + + This example shows how to create a search box. */ /*! - \title Slide Switch + \title UI Components: Slide Switch \example declarative/ui-components/slideswitch + + This example shows how to create a slide switch. */ /*! - \title Spinner + \title UI Components: Spinner \example declarative/ui-components/spinner + + This example shows how to create a spinner-type component. */ /*! - \title Tab Widget + \title UI Components: Tab Widget \example declarative/ui-components/tabwidget -*/ -/*! - \title XML Data - \example declarative/xml/xmldata + This example shows how to create a tab widget. */ /*! - \title XMLHttpRequest + \title XML: XMLHttpRequest \example declarative/xml/xmlhttprequest + + This example shows how to use \l XmlHttpRequest in QML. */ diff --git a/doc/src/declarative/extending-examples.qdoc b/doc/src/examples/qml-extending.qdoc index 577ab78..09108d6 100644 --- a/doc/src/declarative/extending-examples.qdoc +++ b/doc/src/examples/qml-extending.qdoc @@ -236,7 +236,7 @@ This example builds on: */ /*! -\example declarative/cppextensions/referenceexamples/grouped +\example declarative/cppextensions/referenceexamples/attached \title Extending QML - Attached Properties Example This example builds on: diff --git a/doc/src/examples/qml-folderlistmodel.qdoc b/doc/src/examples/qml-folderlistmodel.qdoc new file mode 100644 index 0000000..b820528 --- /dev/null +++ b/doc/src/examples/qml-folderlistmodel.qdoc @@ -0,0 +1,144 @@ +/**************************************************************************** +** +** 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:LGPL$ +** 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 Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + +\title FolderListModel - a C++ model plugin +\example src/imports/folderlistmodel + +This plugin shows how to make a C++ model available to QML. It presents +a simple file list for a single folder (directory) and allows the presented +folder to be changed. + +\image declarative-folderlistmodel.png The FolderListModel used to choose a QML file + +We do not explain the model implementation in detail, but rather focus on the mechanics of +making the model available to QML. + +\section1 Usage from QML + +The type we are creating can be used from QML like this: + +\snippet doc/src/snippets/declarative/folderlistmodel.qml 0 + +\section1 Defining the Model + +We are subclassing QAbstractListModel which will allow us to give data to QML and +send notifications when the data changes: + +\snippet src/imports/folderlistmodel/qdeclarativefolderlistmodel.h class begin + +As you see, we also inherit the QDeclarativeParserStatus interface, so that we +can delay initial processing until we have all properties set (via componentComplete() below). + +The first thing to do when devising a new type for QML is to define the properties +you want the type to have: + +\snippet src/imports/folderlistmodel/qdeclarativefolderlistmodel.h class props + +The purposes of each of these should be pretty obvious - in QML we will set the folder +to display (a file: URL), and the kinds of files we want to show in the view of the model. + +Next are the constructor, destructor, and standard QAbstractListModel subclassing requirements: + +\snippet src/imports/folderlistmodel/qdeclarativefolderlistmodel.h abslistmodel + +The data() function is where we provide model values. The rowCount() function +is also a standard part of the QAbstractListModel interface, but we also want to provide +a simpler count property: + +\snippet src/imports/folderlistmodel/qdeclarativefolderlistmodel.h count + +Then we have the functions for the remaining properties which we defined above: + +\snippet src/imports/folderlistmodel/qdeclarativefolderlistmodel.h prop funcs + +Imperative actions upon the model are made available to QML via a Q_INVOKABLE tag on +a normal member function. The isFolder(index) function says whether the value at \e index +is a folder: + +\snippet src/imports/folderlistmodel/qdeclarativefolderlistmodel.h isfolder + +Then we have the QDeclarativeParserStatus interface: + +\snippet src/imports/folderlistmodel/qdeclarativefolderlistmodel.h parserstatus + +Then the NOTIFY function for the folders property. The implementation will emit this +when the folder property is changed. + +\snippet src/imports/folderlistmodel/qdeclarativefolderlistmodel.h notifier + +The class ends with some implementation details: + +\snippet src/imports/folderlistmodel/qdeclarativefolderlistmodel.h class end + +Lastly, the boilerplare to declare the type for QML use: + +\snippet src/imports/folderlistmodel/qdeclarativefolderlistmodel.h qml decl + +\section1 Connecting the Model to QML + +To make this class available to QML, we only need to make a simple subclass of QDeclarativeExtensionPlugin: + +\snippet src/imports/folderlistmodel/plugin.cpp class decl + +and then use the standard Qt plugin export macro: + +\snippet src/imports/folderlistmodel/plugin.cpp plugin export decl + +Finally, in order for QML to connect the "import" statement to our plugin, we list it in the qmldir file: + +\l{src/imports/folderlistmodel/qmldir} + +This qmldir file and the compiled plugin will be installed in \c $QTDIR/imports/Qt/labs/folderlistmodel/ where +the QML engine will find it (since \c $QTDIR/imports is the value of QLibraryInf::libraryPath()). + +\section1 Implementing the Model + +We'll not discuss the model implementation in detail, as it is not specific to QML - any Qt C++ model +can be interfaced to QML. +This implementation is basically just takes the krufty old QDirModel, +which is a tree with lots of detailed roles and re-presents it as a simpler list model where +each item is just a fileName and a filePath (as a file: URL rather than a plain file, since QML +works with URLs for all content). + +\l{src/imports/folderlistmodel/qdeclarativefolderlistmodel.cpp} +*/ diff --git a/doc/src/examples/qml-rssnews.qdoc b/doc/src/examples/qml-rssnews.qdoc new file mode 100644 index 0000000..0e7bdef --- /dev/null +++ b/doc/src/examples/qml-rssnews.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:LGPL$ +** 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 Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \title RSS News + \example demos/declarative/rssnews + + This demo shows how to write a RSS news reader in QML. + + \image qml-rssnews-example.png +*/ diff --git a/doc/src/frameworks-technologies/activeqt.qdoc b/doc/src/frameworks-technologies/activeqt.qdoc index 6f4ec30..979d885 100644 --- a/doc/src/frameworks-technologies/activeqt.qdoc +++ b/doc/src/frameworks-technologies/activeqt.qdoc @@ -58,6 +58,7 @@ \ingroup qt-activex \keyword ActiveQt + \target ActiveQt Framework Qt's ActiveX and COM support allows Qt for Windows developers to: diff --git a/doc/src/frameworks-technologies/ipc.qdoc b/doc/src/frameworks-technologies/ipc.qdoc index 5139f04..b49a816 100644 --- a/doc/src/frameworks-technologies/ipc.qdoc +++ b/doc/src/frameworks-technologies/ipc.qdoc @@ -45,7 +45,7 @@ \brief Inter-Process communication in Qt applications. \ingroup technology-apis - \ingout qt-network + \ingroup qt-network Qt provides several ways to implement Inter-Process Communication (IPC) in Qt applications. diff --git a/doc/src/getting-started/examples.qdoc b/doc/src/getting-started/examples.qdoc index bc08e93..61fa1cd 100644 --- a/doc/src/getting-started/examples.qdoc +++ b/doc/src/getting-started/examples.qdoc @@ -40,16 +40,6 @@ ****************************************************************************/ /*! - \page examples-overview.html - \raw HTML - <script> - document.location.href = "examples.html"; - </script> - \endraw - Click this \l{Qt Examples}{link} if you don't get redirected. -*/ - -/*! \group all-examples \title Qt Examples @@ -581,7 +571,7 @@ \page examples-mainwindow.html \ingroup all-examples \title Main Window Examples - \building applications around a main window. + \brief Building applications around a main window. \previouspage Dialog Examples \contentspage Qt Examples diff --git a/doc/src/images/declarative-folderlistmodel.png b/doc/src/images/declarative-folderlistmodel.png Binary files differnew file mode 100644 index 0000000..a469f96 --- /dev/null +++ b/doc/src/images/declarative-folderlistmodel.png diff --git a/doc/src/images/modelview-move-rows-1.png b/doc/src/images/modelview-move-rows-1.png Binary files differnew file mode 100644 index 0000000..b629a72 --- /dev/null +++ b/doc/src/images/modelview-move-rows-1.png diff --git a/doc/src/images/modelview-move-rows-2.png b/doc/src/images/modelview-move-rows-2.png Binary files differnew file mode 100644 index 0000000..674ca18 --- /dev/null +++ b/doc/src/images/modelview-move-rows-2.png diff --git a/doc/src/images/modelview-move-rows-3.png b/doc/src/images/modelview-move-rows-3.png Binary files differnew file mode 100644 index 0000000..5445dd5 --- /dev/null +++ b/doc/src/images/modelview-move-rows-3.png diff --git a/doc/src/images/modelview-move-rows-4.png b/doc/src/images/modelview-move-rows-4.png Binary files differnew file mode 100644 index 0000000..ecd65ba --- /dev/null +++ b/doc/src/images/modelview-move-rows-4.png diff --git a/doc/src/images/qml-rssnews-example.png b/doc/src/images/qml-rssnews-example.png Binary files differnew file mode 100644 index 0000000..948ef4d --- /dev/null +++ b/doc/src/images/qml-rssnews-example.png diff --git a/doc/src/objectmodel/metaobjects.qdoc b/doc/src/objectmodel/metaobjects.qdoc index e891183..f6fcc44 100644 --- a/doc/src/objectmodel/metaobjects.qdoc +++ b/doc/src/objectmodel/metaobjects.qdoc @@ -45,6 +45,7 @@ \ingroup qt-basic-concepts \brief An overview of Qt's meta-object system and introspection capabilities. \keyword meta-object + \target Meta-Object System Qt's meta-object system provides the signals and slots mechanism for inter-object communication, run-time type information, and the dynamic diff --git a/doc/src/objectmodel/object.qdoc b/doc/src/objectmodel/object.qdoc index e0ba6ed..f81577d 100644 --- a/doc/src/objectmodel/object.qdoc +++ b/doc/src/objectmodel/object.qdoc @@ -45,8 +45,6 @@ \ingroup qt-basic-concepts \brief A description of the powerful features made possible by Qt's dynamic object model. - \ingroup frameworks-technologies - The standard C++ object model provides very efficient runtime support for the object paradigm. But its static nature is inflexibile in certain problem domains. Graphical user interface diff --git a/doc/src/objectmodel/properties.qdoc b/doc/src/objectmodel/properties.qdoc index bc9554c..7f876c3 100644 --- a/doc/src/objectmodel/properties.qdoc +++ b/doc/src/objectmodel/properties.qdoc @@ -44,6 +44,7 @@ \title The Property System \ingroup qt-basic-concepts \brief An overview of Qt's property system. + \target Qt's Property System Qt provides a sophisticated property system similar to the ones supplied by some compiler vendors. However, as a compiler- and diff --git a/doc/src/painting-and-printing/coordsys.qdoc b/doc/src/painting-and-printing/coordsys.qdoc index b360d0b..d6714b8 100644 --- a/doc/src/painting-and-printing/coordsys.qdoc +++ b/doc/src/painting-and-printing/coordsys.qdoc @@ -46,10 +46,6 @@ \brief Information about the coordinate system used by the paint system. - \previouspage Drawing and Filling - \contentspage The Paint System - \nextpage Reading and Writing Image Files - The coordinate system is controlled by the QPainter class. Together with the QPaintDevice and QPaintEngine classes, QPainter form the basis of Qt's painting system, Arthur. QPainter diff --git a/doc/src/platforms/emb-qvfb.qdoc b/doc/src/platforms/emb-qvfb.qdoc index bcadb73..ceec027 100644 --- a/doc/src/platforms/emb-qvfb.qdoc +++ b/doc/src/platforms/emb-qvfb.qdoc @@ -146,17 +146,13 @@ \list \o ClamshellPhone - \o pda - \o PDAPhone - \o Qt ExtendedPDA - \o Qt ExtendedPhone-Advanced - \o Qt ExtendedPhone-Simple + \o PortableMedia + \o S60-nHD-Touchscreen + \o S60-QVGA-Candybar \o SmartPhone \o SmartPhone2 \o SmartPhoneWithButtons \o TouchscreenPhone - \o Trolltech-Keypad - \o Trolltech-Touchscreen \endlist In addition, it is possible to create custom skins. diff --git a/doc/src/snippets/declarative/componentCreation.js b/doc/src/snippets/declarative/componentCreation.js index f6fb379..25bc10c 100644 --- a/doc/src/snippets/declarative/componentCreation.js +++ b/doc/src/snippets/declarative/componentCreation.js @@ -14,7 +14,7 @@ function finishCreation() { } } else if (component.status == Component.Error) { // Error Handling - console.log("Error loading component:", component.errorsString()); + console.log("Error loading component:", component.errorString()); } } //![0] @@ -35,7 +35,7 @@ sprite = component.createObject(appWindow); if (sprite == null) { // Error Handling - console.log("Error loading component:", component.errorsString()); + console.log("Error loading component:", component.errorString()); } else { sprite.x = 100; sprite.y = 100; diff --git a/doc/src/snippets/declarative/folderlistmodel.qml b/doc/src/snippets/declarative/folderlistmodel.qml new file mode 100644 index 0000000..e90f9fd --- /dev/null +++ b/doc/src/snippets/declarative/folderlistmodel.qml @@ -0,0 +1,17 @@ +//![0] +import Qt 4.7 +import Qt.labs.folderlistmodel 1.0 + +ListView { + FolderListModel { + id: foldermodel + nameFilters: ["*.qml"] + } + Component { + id: filedelegate + Text { text: fileName } + } + model: foldermodel + delegate: filedelegate +} +//![0] diff --git a/doc/src/snippets/declarative/gridview/gridview.qml b/doc/src/snippets/declarative/gridview/gridview.qml index cf345aa..1d3df97 100644 --- a/doc/src/snippets/declarative/gridview/gridview.qml +++ b/doc/src/snippets/declarative/gridview/gridview.qml @@ -4,7 +4,7 @@ import Qt 4.7 Rectangle { width: 240; height: 180; color: "white" // ContactModel model is defined in dummydata/ContactModel.qml - // The launcher automatically loads files in dummydata/* to assist + // The viewer automatically loads files in dummydata/* to assist // development without a real data source. // Define a delegate component. A component will be diff --git a/doc/src/snippets/declarative/listview/dummydata/ContactModel.qml b/doc/src/snippets/declarative/listview/ContactModel.qml index 20687cf..b930c06 100644 --- a/doc/src/snippets/declarative/listview/dummydata/ContactModel.qml +++ b/doc/src/snippets/declarative/listview/ContactModel.qml @@ -1,7 +1,7 @@ +//![0] import Qt 4.7 ListModel { - id: contactModel ListElement { name: "Bill Smith" number: "555 3264" @@ -15,3 +15,4 @@ ListModel { number: "555 0473" } } +//![0] diff --git a/doc/src/snippets/declarative/listview/highlight.qml b/doc/src/snippets/declarative/listview/highlight.qml index 1282f8d..794b3f2 100644 --- a/doc/src/snippets/declarative/listview/highlight.qml +++ b/doc/src/snippets/declarative/listview/highlight.qml @@ -4,7 +4,7 @@ Rectangle { width: 180; height: 200; color: "white" // ContactModel model is defined in dummydata/ContactModel.qml - // The launcher automatically loads files in dummydata/* to assist + // The viewer automatically loads files in dummydata/* to assist // development without a real data source. // Define a delegate component. A component will be diff --git a/doc/src/snippets/declarative/listview/listview.qml b/doc/src/snippets/declarative/listview/listview.qml index 44f0540..1e9ccd9 100644 --- a/doc/src/snippets/declarative/listview/listview.qml +++ b/doc/src/snippets/declarative/listview/listview.qml @@ -1,49 +1,101 @@ +//![import] import Qt 4.7 +//![import] -//! [3] -Rectangle { - width: 180; height: 200; color: "white" +Item { + +//![classdocs simple] +ListView { + width: 180; height: 200 + + model: ContactModel {} + delegate: Text { + text: name + ": " + number + } +} +//![classdocs simple] - // ContactModel model is defined in dummydata/ContactModel.qml - // The launcher automatically loads files in dummydata/* to assist - // development without a real data source. +//![classdocs advanced] +Rectangle { + width: 180; height: 200 - // Define a delegate component. A component will be - // instantiated for each visible item in the list. -//! [0] Component { - id: delegate + id: contactDelegate Item { - id: wrapper width: 180; height: 40 Column { - x: 5; y: 5 Text { text: '<b>Name:</b> ' + name } Text { text: '<b>Number:</b> ' + number } } } } -//! [0] - // Define a highlight component. Just one of these will be instantiated - // by each ListView and placed behind the current item. -//! [1] - Component { - id: highlight - Rectangle { - color: "lightsteelblue" - radius: 5 - } - } -//! [1] - // The actual list -//! [2] + ListView { - width: parent.width; height: parent.height - model: ContactModel - delegate: delegate - highlight: highlight + anchors.fill: parent + model: ContactModel {} + delegate: contactDelegate + highlight: Rectangle { color: "lightsteelblue"; radius: 5 } focus: true } -//! [2] } -//! [3] +//![classdocs advanced] + +//![delayRemove] +Component { + id: delegate + Item { + ListView.onRemove: SequentialAnimation { + PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: true } + NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing.type: Easing.InOutQuad } + PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: false } + } + } +} +//![delayRemove] + +//![highlightFollowsCurrentItem] +Component { + id: highlight + Rectangle { + width: 180; height: 40 + color: "lightsteelblue"; radius: 5 + SpringFollow on y { + to: list.currentItem.y + spring: 3 + damping: 0.2 + } + } +} + +ListView { + id: list + width: 180; height: 200 + model: ContactModel {} + delegate: Text { text: name } + + highlight: highlight + highlightFollowsCurrentItem: false + focus: true +} +//![highlightFollowsCurrentItem] + +//![isCurrentItem] +ListView { + width: 180; height: 200 + + Component { + id: contactsDelegate + Text { + id: contactInfo + text: name + ": " + number + color: contactInfo.ListView.isCurrentItem ? "red" : "black" + } + } + + model: ContactModel {} + delegate: contactsDelegate + focus: true +} +//![isCurrentItem] + +} diff --git a/doc/src/tutorials/widgets-tutorial.qdoc b/doc/src/tutorials/widgets-tutorial.qdoc index 2b04035..0422e1a 100644 --- a/doc/src/tutorials/widgets-tutorial.qdoc +++ b/doc/src/tutorials/widgets-tutorial.qdoc @@ -45,84 +45,97 @@ \brief This tutorial covers basic usage of widgets and layouts, showing how they are used to build GUI applications. - \startpage {index.html}{Qt Reference Documentation} - \contentspage Tutorials - \nextpage {tutorials/widgets/toplevel}{Creating a Window} - - \section1 Introduction - Widgets are the basic building blocks of graphical user interface (GUI) - applications made with Qt. Each GUI component, such as a button, label or - text editor, is a widget and can be placed within an existing user - interface or displayed as an independent window. Each type of component - is provided by a particular subclass of QWidget, which is itself a - subclass of QObject. - - QWidget is not an abstract class; it can be used as a container for other - widgets, and can be subclassed with minimal effort to create custom - widgets. It is most often used to create windows in which other widgets - are placed. - - As with \l{QObject}s, widgets can be created with parent objects to - indicate ownership, ensuring that objects are deleted when they are no - longer used. With widgets, these parent-child relationships have an - additional meaning: each child is displayed within the screen area - occupied by its parent. This means that, when a window is deleted, all - the widgets it contains are automatically deleted. + Widgets are the basic building blocks for graphical user interface + (GUI) applications built with Qt. Each GUI component (e.g. + buttons, labels, text editor) is a \l{QWidget}{widget} that is + placed somewhere within a user interface window, or is displayed + as an independent window. Each type of widge is provided by a + subclass of QWidget, which is itself a subclass of QObject. + + QWidget is not an abstract class. It can be used as a container + for other widgets, and it can be subclassed with minimal effort to + create new, custom widgets. QWidget is often used to create a + window inside which other \l{QWidget}s are placed. + + As with \l{QObject}s, \l{QWidget}s can be created with parent + objects to indicate ownership, ensuring that objects are deleted + when they are no longer used. With widgets, these parent-child + relationships have an additional meaning: Each child widget is + displayed within the screen area occupied by its parent widget. + This means that when you delete a window widget, all the child + widgets it contains are also deleted. \section1 Writing a main Function - Many of the GUI examples in Qt follow the pattern of having a \c{main.cpp} - file containing code to initialize the application, and a number of other - source and header files containing the application logic and custom GUI - components. + Many of the GUI examples provided with Qt follow the pattern of + having a \c{main.cpp} file, which contains the standard code to + initialize the application, plus any number of other source/header + files that contain the application logic and custom GUI components. - A typical \c main() function, written in \c{main.cpp}, looks like this: + A typical \c main() function in \c{main.cpp} looks like this: \snippet doc/src/snippets/widgets-tutorial/template.cpp main.cpp body - We first construct a QApplication object which is configured using any - arguments passed in from the command line. After any widgets have been - created and shown, we call QApplication::exec() to start Qt's event loop. - Control passes to Qt until this function returns, at which point we return - the value we obtain from this function. + First, a QApplication object is constructed, which can be + configured with arguments passed in from the command line. After + the widgets have been created and shown, QApplication::exec() is + called to start Qt's event loop. Control passes to Qt until this + function returns. Finally, \c{main()} returns the value returned + by QApplication::exec(). - In each part of this tutorial, we provide an example that is written - entirely within a \c main() function. In more sophisticated examples, the - code to set up widgets and layouts is written in other parts of the - example. For example, the GUI for a main window may be set up in the - constructor of a QMainWindow subclass. + \section1 Simple widget examples + + Each of theses simple widget examples is written entirely within + the \c main() function. + + \list + \o \l {tutorials/widgets/toplevel} {Creating a window} + + \o \l {tutorials/widgets/childwidget} {Creating child widgets} + + \o \l {tutorials/widgets/windowlayout} {Using layouts} + + \o \l {tutorials/widgets/nestedlayouts} {Nested layouts} + \endlist + + \section1 Real world widget examples - The \l{Widgets examples} are a good place to look for - more complex and complete examples and applications. + In these \l{Widgets examples} {more advanced examples}, the code + that creates the widgets and layouts is stored in other files. For + example, the GUI for a main window may be created in the + constructor of a QMainWindow subclass. - \section1 Building Examples and Tutorials + \section1 Building The Examples - If you obtained a binary package of Qt or compiled it yourself, the - examples described in this tutorial should already be ready to run. - However, if you may wish to modify them and recompile them, you need to - perform the following steps: + If you installed a binary package to get Qt, or if you compiled Qt + yourself, the examples described in this tutorial should already + be built and ready to run. If you wish to modify and recompile + them, follow these steps: \list 1 - \o At the command line, enter the directory containing the example you - wish to recompile. - \o Type \c qmake and press \key{Return}. If this doesn't work, make sure - that the executable is on your path, or enter its full location. - \o On Linux/Unix and Mac OS X, type \c make and press \key{Return}; - on Windows with Visual Studio, type \c nmake and press \key{Return}. + + \o From a command prompt, enter the directory containing the + example you have modified. + + \o Type \c qmake and press \key{Return}. If this doesn't work, + make sure that the executable is on your path, or enter its + full location. + + \o On Linux/Unix and Mac OS X, type \c make and press + \key{Return}; on Windows with Visual Studio, type \c nmake and + press \key{Return}. + \endlist - An executable file should have been created within the current directory. - On Windows, this file may be located within a \c debug or \c release - subdirectory. You can run this file to see the example code at work. + An executable file is created in the current directory. On + Windows, this file may be located in a \c debug or \c release + subdirectory. You can run this executable to see the example code + at work. */ /*! - \page widgets-tutorial-toplevel.html - \contentspage {Widgets Tutorial}{Contents} - \previouspage {Widgets Tutorial} - \nextpage {Widgets Tutorial - Child Widgets} \example tutorials/widgets/toplevel \title Widgets Tutorial - Creating a Window @@ -151,13 +164,10 @@ 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 demonstrate in the next part of this tutorial. + */ /*! - \page widgets-tutorial-childwidget.html - \contentspage {Widgets Tutorial}{Contents} - \previouspage {Widgets Tutorial - Creating a Window} - \nextpage {Widgets Tutorial - Using Layouts} \example tutorials/widgets/childwidget \title Widgets Tutorial - Child Widgets @@ -185,10 +195,6 @@ */ /*! - \page widgets-tutorial-windowlayout.html - \contentspage {Widgets Tutorial}{Contents} - \previouspage {Widgets Tutorial - Child Widgets} - \nextpage {Widgets Tutorial - Nested Layouts} \example tutorials/widgets/windowlayout \title Widgets Tutorial - Using Layouts @@ -228,9 +234,6 @@ */ /*! - \page widgets-tutorial-nestedlayouts.html - \contentspage {Widgets Tutorial}{Contents} - \previouspage {Widgets Tutorial - Using Layouts} \example tutorials/widgets/nestedlayouts \title Widgets Tutorial - Nested Layouts |