From a2a5a8c5e203fe9d55f9addba1533a30c6f2ba19 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Thu, 10 Jun 2010 18:54:11 +0200 Subject: Doc: Started organizing Symbian platform deployment information. Reviewed-by: Trust Me --- doc/src/deployment/deployment.qdoc | 27 ++++++++-- doc/src/external-resources.qdoc | 10 ++++ doc/src/platforms/symbian-introduction.qdoc | 76 +++++++++++++++++------------ 3 files changed, 78 insertions(+), 35 deletions(-) diff --git a/doc/src/deployment/deployment.qdoc b/doc/src/deployment/deployment.qdoc index 51974af..286c080 100644 --- a/doc/src/deployment/deployment.qdoc +++ b/doc/src/deployment/deployment.qdoc @@ -1472,8 +1472,10 @@ /*! \page deployment-symbian.html \contentspage Deploying Qt Applications + \ingroup qtsymbian + \title Deploying an Application on the Symbian Platform - \title Deploying an Application on the Symbian platform + \section1 Overview Applications are deployed to Symbian devices in signed \c .sis package files. The \c .sis file content is controlled with \c .pkg files. The \c .pkg file contains a set @@ -1483,10 +1485,17 @@ to end-users some changes are needed. This document describes what changes are typically needed and how to implement them. + \section1 Requirements + + Download the latest release of the Smart Installer from + \l{http://get.qt.nokia.com/nokiasmartinstaller/}, and install it on top + of the Qt package. + \section1 Static Linking - Qt for the Symbian platform does currently not support static linking of - Qt libraries. + Qt for the Symbian platform does not currently support static linking of + Qt libraries with application binaries. You will need to build shared + libraries as described below and link your application with them. \section1 Shared Libraries @@ -1532,7 +1541,7 @@ S60 3rd edition FP1, S60 3rd edition FP2 and S60 5th edition devices. Now we are ready to compile the application and create the application - deployment file. Run \c qmake to create Symbian specific makefiles, resources (\.rss) + deployment file. Run \c qmake to create Symbian specific makefiles, resources (\c .rss) and deployment packaging files (\c .pkg). And do build to create the application binaries and resources. @@ -1562,4 +1571,14 @@ For more information about creating a \c .sis file and installing it to device see also \l {The Symbian platform - Introduction to Qt#Installing your own applications}{here}. + \section1 Further Reading + + This document aims to cover the common case for developers who want to + deploy Qt applications on devices using the Smart Installer. It does not + aim to cover every possible way of installing applications, Qt and other + dependencies on a device. + + A wider selection of deployment methods is described in the + \l{Deploying a Qt Application article} on the Symbian Foundation + Developer Wiki. */ diff --git a/doc/src/external-resources.qdoc b/doc/src/external-resources.qdoc index 249c10a1..6f22f00 100644 --- a/doc/src/external-resources.qdoc +++ b/doc/src/external-resources.qdoc @@ -427,3 +427,13 @@ \externalpage http://opensource.org/licenses/bsd-license.php \title New and Modified BSD Licenses */ + +/*! + \externalpage http://developer.symbian.org/wiki/index.php/Platform_Security_%28Fundamentals_of_Symbian_C%2B%2B%29#Self-Signed_Applications + \title Symbian Platform Security +*/ + +/*! + \externalpage http://developer.symbian.org/wiki/index.php/Deploying_a_Qt_Application + \title Deploying a Qt Application article +*/ diff --git a/doc/src/platforms/symbian-introduction.qdoc b/doc/src/platforms/symbian-introduction.qdoc index 6ffc568..9563a8e 100644 --- a/doc/src/platforms/symbian-introduction.qdoc +++ b/doc/src/platforms/symbian-introduction.qdoc @@ -83,12 +83,12 @@ \tableofcontents - \section1 Required tools + \section1 Required Tools See \l{Qt for the Symbian platform Requirements} to see what tools are required to use Qt for the Symbian platform. - \section1 Installing Qt and running demos + \section1 Installing Qt and Running Demos Follow the instructions found in \l{Installing Qt on the Symbian platform from a Binary Package} to learn how to install Qt using a binary package and how to build and run Qt demos. @@ -96,7 +96,7 @@ Follow the instructions found in \l{Installing Qt on the Symbian platform} to learn how to install Qt using using source package and how to build and run the Qt demos. - \section1 Building your own applications + \section1 Building Your Own Applications If you are new to Qt development, have a look at \l{How to Learn Qt}. In general, the difference between developing a @@ -109,12 +109,19 @@ \snippet doc/src/snippets/code/doc_src_symbian-introduction.qdoc 0 For more information on how to use qmake have a look at the \l - {qmake Tutorial}. + {qmake Tutorial}. In particular, see the + \l{qmake Platform Notes#Symbian platform}{qmake Platform Notes} for + details of Symbian-specific build settings. Now you can build the Qt for the Symbian platform application with - standard build tools. By default, running \c make will produce binaries for - the emulator. However, the Symbian platform comes with several alternative - build targets, as shown in the table below: + standard build tools. + + \section2 Alternative Build Targets + + By default, running \c make will produce binaries for the emulator. + However, the Symbian platform comes with several alternative + build targets that can be used to create binaries for target hardware + and deploy them on devices, as shown in the table below: \table \row \o \c debug-winscw \o Build debug binaries for the emulator (default). @@ -144,19 +151,30 @@ To work on your project in Carbide, simply import the \c .pro file by right clicking on the project explorer and executing "Import...". - \section2 Smart Installer + \section1 Running Applications from the Command Line - The Smart Installer makes sure that deployed applications have all the Qt dependencies - they need to run on a device. + The application can be launched on the emulator using \c{make run} command. - Download the latest release of the Smart Installer from \l{http://get.qt.nokia.com/nokiasmartinstaller/}, - and install it on top of the Qt package. + The application can be launched on a device using \c{make runonphone} command. + When this command is invoked, a \c .sis file is first created as if \c{make sis} + command was invoked (see above for details). + \bold{Note:} Running the application on a device using this command requires + \c TRK application to be running on the device. - \section1 Installing your own applications + Additional environment variables that can be utilized with these commands are: + \table + \row \o \c QT_RUN_OPTIONS \o Any command line parameters you wish to pass + to your application. + \row \o \c QT_RUN_ON_PHONE_OPTIONS \o Options for runonphone application. + Execute \c runonphone from command line for + more information about available options. + \c{make runonphone} only. + \endtable + + \section1 Installing Your Own Applications To install your own applications on hardware, you need a signed \c .sis file. - (Refer to the \l{http://developer.symbian.org/wiki/index.php/Platform_Security_%28Fundamentals_of_Symbian_C%2B%2B%29#Self-Signed_Applications} - {Platform Security Article} for more informations about self-signing.) + (Refer to the \l{Symbian Platform Security} article for more informations about self-signing.) The signed \c .sis file can be created with \c make \c sis target. \c sis target is only supported for executables or projects with \c DEPLOYMENT statements. By default the \c sis target will create signed \c .sis file for last build @@ -214,23 +232,19 @@ \snippet doc/src/snippets/code/doc_src_symbian-introduction.qdoc 5 - \section1 Running applications from command line + \section1 Deployment and the Smart Installer - The application can be launched on the emulator using \c{make run} command. + Although some Symbian devices may already have a version of Qt installed + on them, there needs to be a way to ensure that an appropriate version + of Qt is available for your application to use. Rather than deploy the + required Qt libraries with your application, the preferred way to + package Qt applications for deployment is to download and use the Smart + Installer. - The application can be launched on a device using \c{make runonphone} command. - When this command is invoked, a \c .sis file is first created as if \c{make sis} - command was invoked (see above for details). - \bold{Note:} Running the application on a device using this command requires - \c TRK application to be running on the device. + The Smart Installer makes sure that deployed applications have all the + Qt dependencies they need to run on a device, performing the necessary + updates when the user installs the application. - Additional environment variables that can be utilized with these commands are: - \table - \row \o \c QT_RUN_OPTIONS \o Any command line parameters you wish to pass - to your application. - \row \o \c QT_RUN_ON_PHONE_OPTIONS \o Options for runonphone application. - Execute \c runonphone from command line for - more information about available options. - \c{make runonphone} only. - \endtable + More information about deployment can be found in the + \l{Deploying an Application on the Symbian Platform} document. */ -- cgit v0.12 From 4aab0b33e7c34677b530553bb0a5493aca6547a5 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Mon, 28 Jun 2010 18:42:41 +0200 Subject: Doc: Synchronize HTML templates for each language. Reviewed-by: Trust Me --- tools/qdoc3/test/qt-html-templates.qdocconf | 2 +- tools/qdoc3/test/qt-html-templates_ja_JP.qdocconf | 14 +- tools/qdoc3/test/qt-html-templates_zh_CN.qdocconf | 191 +++++++++++++++++++--- 3 files changed, 170 insertions(+), 37 deletions(-) diff --git a/tools/qdoc3/test/qt-html-templates.qdocconf b/tools/qdoc3/test/qt-html-templates.qdocconf index 1fb000b..8708f1b 100644 --- a/tools/qdoc3/test/qt-html-templates.qdocconf +++ b/tools/qdoc3/test/qt-html-templates.qdocconf @@ -160,7 +160,7 @@ HTML.footer = " \n" \ "
\n" \ "
X
\n" \ "
\n" \ - "

\n" \ + "

\n" \ "

\n" \ "
\n" \ "
\n" \ diff --git a/tools/qdoc3/test/qt-html-templates_ja_JP.qdocconf b/tools/qdoc3/test/qt-html-templates_ja_JP.qdocconf index 027548e..e2abd2a 100644 --- a/tools/qdoc3/test/qt-html-templates_ja_JP.qdocconf +++ b/tools/qdoc3/test/qt-html-templates_ja_JP.qdocconf @@ -160,19 +160,9 @@ HTML.footer = " \n" \ "
\n" \ "
X
\n" \ "
\n" \ - "

\n" \ + "

\n" \ "

\n" \ "
\n" \ "
\n" \ "
\n" \ - "
\n" \ - "\n" + " \n" diff --git a/tools/qdoc3/test/qt-html-templates_zh_CN.qdocconf b/tools/qdoc3/test/qt-html-templates_zh_CN.qdocconf index 5fb68cf..e00bef9 100644 --- a/tools/qdoc3/test/qt-html-templates_zh_CN.qdocconf +++ b/tools/qdoc3/test/qt-html-templates_zh_CN.qdocconf @@ -1,25 +1,168 @@ -HTML.stylesheets = classic.css -HTML.postheader = "\n" \ - "\n" \ - "\n" \ - "" \ - "" \ - "
" \ - "" \ - "  " \ - "" \ - "主页 ·" \ - " " \ - "所有类 ·" \ - " " \ - "所有函数 ·" \ - " " \ - "简介" \ - "
" +HTML.stylesheets = style/style.css \ + style/OfflineStyle.css \ + style/style_ie7.css \ + style/style_ie8.css \ + style/style_ie6.css -HTML.footer = "


\n" \ - "\n" \ - "\n" \ - "\n" \ - "\n" \ - "
版权所有 © 2010 诺基亚公司和/或其子公司商标
Qt \\version
" +HTML.postheader = "
\n" \ + "
\n" \ + "
\n" \ + " Home
\n" \ + " Qt Reference Documentation\n" \ + "
\n" \ + "
\n" \ + " \n" \ + "
\n" \ + "
\n" \ + "
\n" \ + " \n" \ + "
\n" \ + "
\n" \ + " \n" \ + "
\n" \ + " \n" \ + "
\n" \ + "
\n" \ + "
\n" \ + "
\n" \ + " \n" \ + "
\n" \ + "
\n" \ + "
\n" \ + "
\n" \ + " Search index:
\n" \ + "
\n" \ + "
\n" \ + "
\n" \ + " \n" \ + "
\n" \ + "
\n" \ + "
\n" \ + "
\n" \ + "

\n" \ + " API Lookup

\n" \ + "
\n" \ + " \n" \ + "
\n" \ + "
\n" \ + "
\n" \ + "

\n" \ + " Qt Topics

\n" \ + "
\n" \ + " \n" \ + "
\n" \ + "
\n" \ + "
\n" \ + "

\n" \ + " Examples

\n" \ + "
\n" \ + " \n" \ + "
\n" \ + "
\n" \ + "
\n" \ + "
\n" \ + "
\n" \ + "
\n" \ + "
    \n" \ + "
  • Home
  • \n" \ + " \n" + +HTML.postpostheader = "
\n" \ + "
\n" \ + "
\n" \ + " \n" \ + "
\n" \ + "
\n" \ + "
\n" + +HTML.footer = " \n" \ + "
\n" \ + " [+] Documentation Feedback
\n" \ + "
\n" \ + "
\n" \ + "
\n" \ + " \n" \ + "
\n" \ + "
\n" \ + "
\n" \ + "

\n" \ + " © 2008-2010 Nokia Corporation and/or its\n" \ + " subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation \n" \ + " in Finland and/or other countries worldwide.

\n" \ + "

\n" \ + " All other trademarks are property of their respective owners. Privacy Policy

\n" \ + "
\n" \ + "
\n" \ + "
X
\n" \ + "
\n" \ + "

\n" \ + "

\n" \ + "
\n" \ + "
\n" \ + "
\n" \ + "
\n" -- cgit v0.12 From 08478207ee9a6563ae63ebcef833925db6426bd8 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Wed, 30 Jun 2010 19:03:53 +0200 Subject: Doc: Made the Gestures Programming document more visible. Reviewed-by: Trust Me --- src/gui/kernel/qevent.cpp | 5 +++++ src/gui/kernel/qgesture.cpp | 28 +++++++++++++++++++++++----- src/gui/kernel/qgesturerecognizer.cpp | 3 +++ 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index 92eed33..0c0eabb 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -4281,6 +4281,11 @@ QTouchEvent::TouchPoint &QTouchEvent::TouchPoint::operator=(const QTouchEvent::T QGestureEvent::accept() for each of them, or an event filter consumes the event. + \section1 Further Reading + + For an overview of gesture handling in Qt and information on using gestures + in your applications, see the \l{Gestures Programming} document. + \sa QGesture, QGestureRecognizer, QWidget::grabGesture(), QGraphicsObject::grabGesture() */ diff --git a/src/gui/kernel/qgesture.cpp b/src/gui/kernel/qgesture.cpp index f5688f4..8264422 100644 --- a/src/gui/kernel/qgesture.cpp +++ b/src/gui/kernel/qgesture.cpp @@ -58,6 +58,9 @@ QT_BEGIN_NAMESPACE the QGestureRecognizer object that is registered with the application; see QGestureRecognizer::registerRecognizer(). + For an overview of gesture handling in Qt and information on using gestures + in your applications, see the \l{Gestures Programming} document. + \section1 Gesture Properties The class has a list of properties that can be queried by the user to get @@ -218,7 +221,10 @@ QGesture::GestureCancelPolicy QGesture::gestureCancelPolicy() const \image pangesture.png - \sa {Gestures Programming}, QPinchGesture, QSwipeGesture + For an overview of gesture handling in Qt and information on using gestures + in your applications, see the \l{Gestures Programming} document. + + \sa QPinchGesture, QSwipeGesture */ /*! @@ -313,6 +319,9 @@ void QPanGesture::setAcceleration(qreal value) them closer together or further apart to change the scale factor, zoom, or level of detail of the user interface. + For an overview of gesture handling in Qt and information on using gestures + in your applications, see the \l{Gestures Programming} document. + \image pinchgesture.png Instead of repeatedly applying the same pinching gesture, the user may @@ -321,7 +330,7 @@ void QPanGesture::setAcceleration(qreal value) will continue to be delivered to the target object, containing an instance of QPinchGesture in the Qt::GestureUpdated state. - \sa {Gestures Programming}, QPanGesture, QSwipeGesture + \sa QPanGesture, QSwipeGesture */ /*! @@ -571,7 +580,10 @@ void QPinchGesture::setRotationAngle(qreal value) \image swipegesture.png - \sa {Gestures Programming}, QPanGesture, QPinchGesture + For an overview of gesture handling in Qt and information on using gestures + in your applications, see the \l{Gestures Programming} document. + + \sa QPanGesture, QPinchGesture */ /*! @@ -666,7 +678,10 @@ void QSwipeGesture::setSwipeAngle(qreal value) \brief The QTapGesture class describes a tap gesture made by the user. \ingroup gestures - \sa {Gestures Programming}, QPanGesture, QPinchGesture + For an overview of gesture handling in Qt and information on using gestures + in your applications, see the \l{Gestures Programming} document. + + \sa QPanGesture, QPinchGesture */ /*! @@ -699,7 +714,10 @@ void QTapGesture::setPosition(const QPointF &value) gesture made by the user. \ingroup gestures - \sa {Gestures Programming}, QPanGesture, QPinchGesture + For an overview of gesture handling in Qt and information on using gestures + in your applications, see the \l{Gestures Programming} document. + + \sa QPanGesture, QPinchGesture */ /*! diff --git a/src/gui/kernel/qgesturerecognizer.cpp b/src/gui/kernel/qgesturerecognizer.cpp index 3e23bbf..e0e7784 100644 --- a/src/gui/kernel/qgesturerecognizer.cpp +++ b/src/gui/kernel/qgesturerecognizer.cpp @@ -62,6 +62,9 @@ QT_BEGIN_NAMESPACE need to use this class directly. Instances will be created behind the scenes by the framework. + For an overview of gesture handling in Qt and information on using gestures + in your applications, see the \l{Gestures Programming} document. + \section1 Recognizing Gestures The process of recognizing gestures involves filtering input events sent to specific -- cgit v0.12 From bbc7aa139308ff304f2e4c2611ed57d855d00d80 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Fri, 16 Jul 2010 14:04:08 +0200 Subject: Doc: Fixed name clash. Reviewed-by: Trust Me --- doc/src/examples/qml-examples.qdoc | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/src/examples/qml-examples.qdoc b/doc/src/examples/qml-examples.qdoc index ce53677..db6e657 100644 --- a/doc/src/examples/qml-examples.qdoc +++ b/doc/src/examples/qml-examples.qdoc @@ -165,7 +165,6 @@ \image qml-layoutitem-example.png */ /*! - \title QGraphicsGridLayout \example declarative/cppextensions/qgraphicslayouts/qgraphicsgridlayout This example shows how to use QGraphicsGridLayout to lay out QML items. This is -- cgit v0.12 From 4ed51b7160471ae3a7db1fbb12a8f265ff7c3239 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Fri, 16 Jul 2010 14:06:50 +0200 Subject: Doc: Merged in some of Thomas Zander's suggestions. Reviewed-by: Trust Me --- doc/src/frameworks-technologies/gestures.qdoc | 49 +++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/doc/src/frameworks-technologies/gestures.qdoc b/doc/src/frameworks-technologies/gestures.qdoc index 927df22..f7c8312 100644 --- a/doc/src/frameworks-technologies/gestures.qdoc +++ b/doc/src/frameworks-technologies/gestures.qdoc @@ -60,7 +60,8 @@ \section1 Using Standard Gestures with Widgets Gestures can be enabled for instances of QWidget and QGraphicsObject subclasses. - An object that accepts gesture input is referred to as a \e{target object}. + An object that accepts gesture input is referred to throughout the documentation + as a \e{target object}. To enable a gesture for a target object, call its QWidget::grabGesture() or QGraphicsObject::grabGesture() function with an argument describing the @@ -69,13 +70,57 @@ \snippet examples/gestures/imagegestures/imagewidget.cpp enable gestures - In the above code, the gesture is set up in the constructor of the target object + In the above code, the gestures are set up in the constructor of the target object itself. + \section1 Handling Events + When the user performs a gesture, QGestureEvent events will be delivered to the target object, and these can be handled by reimplementing the QWidget::event() handler function for widgets or QGraphicsItem::sceneEvent() for graphics objects. + As one target object can subscribe to more than one gesture type, the QGestureEvent + can contain more than one QGesture, indicating several possible gestures are active + at the same time. It is then up to the widget to determine how to handle those + multiple gestures and choose if some should be canceled in favor of others. + + Each QGesture contained within a QGestureEvent object can be accepted() or ignored() + individually, or all together. Additionally, you can query the individual QGesture + data objects (the state) using several getters. + + \section2 Standard Procedure for Event Handling + + A QGesture is by default accepted when it arrives at your widget. However, it is good + practice to always explicitly accept or reject a gesture. The general rule is that, if + you accept a gesture, you are using it. If you are ignoring it you are not interested + in it. Ignoring a gesture may mean it gets offered to another target object, or it will + get canceled. + + Each QGesture has several states it goes through; there is a well defined way to change + the state, typically the user input is the cause of state changes (by starting and + stopping interaction, for instance) but the widget can also cause state changes. + + The first time a particular QGesture is delivered to a widget or graphics item, it will + be in the Qt::GestureStarted state. The way you handle the gesture at this point + influences whether you can interact with it later. + + \list + \o Accepting the gesture means the widget acts on the gesture and there will follow + gestures with the Qt::GestureUpdatedstate. + \o Ignoring the gesture will mean the gesture will never be offered to you again. + It will be offered to a parent widget or item as well. + \o Calling setGestureCancelPolicy() on the gesture when it is in its starting state, + and is also accepted can cause other gestures to be canceled. + \endlist + + Using QGesture::CancelAllInContext to cancel a gesture will cause all gestures, in any + state, to be canceled unless they are explicitly accepted. This means that active + gestures on children will get canceled. It also means that gestures delivered in the + same QGestureEvent will get canceled if the widget ignores them. This can be a useful + way to filter out all gestures except the one you are interested in. + + \section2 Example Event Handling + For convenience, the \l{Image Gestures Example} reimplements the general \l{QWidget::}{event()} handler function and delegates gesture events to a specialized gestureEvent() function: -- cgit v0.12 From d59380458cce6fc52b6de91d8380b31d46c3f83f Mon Sep 17 00:00:00 2001 From: David Boddie Date: Fri, 16 Jul 2010 14:09:11 +0200 Subject: Doc: Fixed QML documentation errors. Reviewed-by: Trust Me --- src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp | 2 +- src/declarative/graphicsitems/qdeclarativepathview.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp b/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp index 0342c9f..9dcba60 100644 --- a/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp +++ b/src/3rdparty/webkit/WebKit/qt/declarative/qdeclarativewebview.cpp @@ -612,7 +612,7 @@ QAction* QDeclarativeWebView::stopAction() const #endif // QT_NO_ACTION /*! - \qmlproperty real WebView::title + \qmlproperty string WebView::title This property holds the title of the web page currently viewed By default, this property contains an empty string. diff --git a/src/declarative/graphicsitems/qdeclarativepathview.cpp b/src/declarative/graphicsitems/qdeclarativepathview.cpp index f4ebd13..1224c73 100644 --- a/src/declarative/graphicsitems/qdeclarativepathview.cpp +++ b/src/declarative/graphicsitems/qdeclarativepathview.cpp @@ -403,7 +403,7 @@ QDeclarativePathView::~QDeclarativePathView() The model provides a set of data that is used to create the items for the view. For large or dynamic datasets the model is usually provided by a C++ model object. - Models can also be created directly in XML, using the ListModel element. + Models can also be created directly in QML, using the ListModel element. \sa {qmlmodels}{Data Models} */ @@ -627,8 +627,8 @@ void QDeclarativePathViewPrivate::setOffset(qreal o) so as to stay with the current item. The below example demonstrates how to make a simple highlight. Note the use - of the PathView.onPath property to ensure that the highlight is hidden - when flicked off of the path. + of the \l{PathView::onPath}{PathView.onPath} attached property to ensure that + the highlight is hidden when flicked away from the path. \code Component { -- cgit v0.12 From e2fb9c4df301678719cb0cff78838b35435c3b38 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Fri, 16 Jul 2010 14:09:59 +0200 Subject: Doc: Fixed typo. Reviewed-by: Trust Me --- src/xmlpatterns/api/qabstractxmlnodemodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/xmlpatterns/api/qabstractxmlnodemodel.cpp b/src/xmlpatterns/api/qabstractxmlnodemodel.cpp index 7f2ad9f..0f9760d 100644 --- a/src/xmlpatterns/api/qabstractxmlnodemodel.cpp +++ b/src/xmlpatterns/api/qabstractxmlnodemodel.cpp @@ -1355,7 +1355,7 @@ bool QXmlItem::isNull() const QAbstractXmlNodeModel for its existence, the only way you can create an instance of QXmlNodeModelIndex is by asking the node model to create one for you with QAbstractXmlNodeModel::createIndex(). Since - that function is protected, it is usually a good ide to write a + that function is protected, it is usually a good idea to write a public function that creates a QXmlNodeModelIndex from arguments that are appropriate for your particular node model. -- cgit v0.12 From 637d207e397c13c09a8dcbd718ee85bce2548e90 Mon Sep 17 00:00:00 2001 From: Frank Osterfeld Date: Thu, 5 Aug 2010 13:42:58 +0200 Subject: QDom: Do not crash on "text" "a:" is not a valid tagname. The function creating the element node notices that and returns 0, but the parser ignores it and continues, and then crashes later when processing the "text". This patch aborts the parsing immediately when creating the element node failed and fixes the crash. Merge-request: 2431 Reviewed-by: Olivier Goffart --- src/xml/dom/qdom.cpp | 6 ++++-- tests/auto/qdom/tst_qdom.cpp | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/xml/dom/qdom.cpp b/src/xml/dom/qdom.cpp index 1267e7e..662c796 100644 --- a/src/xml/dom/qdom.cpp +++ b/src/xml/dom/qdom.cpp @@ -7418,8 +7418,10 @@ bool QDomHandler::startElement(const QString& nsURI, const QString&, const QStri n = doc->createElement(qName); } - if (n) - n->setLocation(locator->lineNumber(), locator->columnNumber()); + if (!n) + return false; + + n->setLocation(locator->lineNumber(), locator->columnNumber()); node->appendChild(n); node = n; diff --git a/tests/auto/qdom/tst_qdom.cpp b/tests/auto/qdom/tst_qdom.cpp index 0f6cdaa..8bf7620 100644 --- a/tests/auto/qdom/tst_qdom.cpp +++ b/tests/auto/qdom/tst_qdom.cpp @@ -1776,6 +1776,7 @@ void tst_QDom::crashInSetContent() const QDomImplementation::setInvalidDataPolicy(QDomImplementation::ReturnNullNode); QDomDocument docImport; + QCOMPARE(docImport.setContent(QLatin1String("text"), true), false); QVERIFY(docImport.setContent(QLatin1String(""))); } -- cgit v0.12 From 15505360dc8e8b8f1343bba6fd3e5a9c95718d30 Mon Sep 17 00:00:00 2001 From: Benjamin Poulain Date: Thu, 5 Aug 2010 13:43:19 +0200 Subject: Replace the SSE prologues by a macro Replace the code of the SSE prologue by a macro to avoid copying the prologue everywhere. Reviewed-by: Andreas Kling --- src/corelib/tools/qsimd_p.h | 4 +++- src/gui/painting/qdrawhelper_sse2.cpp | 14 ++++---------- src/gui/painting/qdrawingprimitive_sse2_p.h | 8 ++------ 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/corelib/tools/qsimd_p.h b/src/corelib/tools/qsimd_p.h index 5ff0f97..a3148fb 100644 --- a/src/corelib/tools/qsimd_p.h +++ b/src/corelib/tools/qsimd_p.h @@ -150,7 +150,9 @@ enum CPUFeatures { Q_CORE_EXPORT uint qDetectCPUFeatures(); -Q_CORE_EXPORT uint qDetectCPUFeatures(); + +#define ALIGNMENT_PROLOGUE_16BYTES(ptr, i, length) \ + for (; i < static_cast(qMin(static_cast(length), ((4 - ((reinterpret_cast(ptr) >> 2) & 0x3)) & 0x3))); ++i) QT_END_NAMESPACE diff --git a/src/gui/painting/qdrawhelper_sse2.cpp b/src/gui/painting/qdrawhelper_sse2.cpp index 7ab9eda..22c0384 100644 --- a/src/gui/painting/qdrawhelper_sse2.cpp +++ b/src/gui/painting/qdrawhelper_sse2.cpp @@ -112,9 +112,7 @@ void qt_blend_rgb32_on_rgb32_sse2(uchar *destPixels, int dbpl, int x = 0; // First, align dest to 16 bytes: - const int offsetToAlignOn16Bytes = (4 - ((reinterpret_cast(dst) >> 2) & 0x3)) & 0x3; - const int prologLength = qMin(w, offsetToAlignOn16Bytes); - for (; x < prologLength; ++x) { + ALIGNMENT_PROLOGUE_16BYTES(dst, x, w) { quint32 s = src[x]; s = BYTE_MUL(s, const_alpha); dst[x] = INTERPOLATE_PIXEL_255(src[x], const_alpha, dst[x], one_minus_const_alpha); @@ -182,12 +180,10 @@ inline int comp_func_Plus_one_pixel(uint d, const uint s) void QT_FASTCALL comp_func_Plus_sse2(uint *dst, const uint *src, int length, uint const_alpha) { int x = 0; - const int offsetToAlignOn16Bytes = (4 - ((reinterpret_cast(dst) >> 2) & 0x3)) & 0x3; - const int prologLength = qMin(length, offsetToAlignOn16Bytes); if (const_alpha == 255) { // 1) Prologue: align destination on 16 bytes - for (; x < prologLength; ++x) + ALIGNMENT_PROLOGUE_16BYTES(dst, x, length) dst[x] = comp_func_Plus_one_pixel(dst[x], src[x]); // 2) composition with SSE2 @@ -208,7 +204,7 @@ void QT_FASTCALL comp_func_Plus_sse2(uint *dst, const uint *src, int length, uin const __m128i oneMinusConstAlpha = _mm_set1_epi16(one_minus_const_alpha); // 1) Prologue: align destination on 16 bytes - for (; x < prologLength; ++x) + ALIGNMENT_PROLOGUE_16BYTES(dst, x, length) dst[x] = comp_func_Plus_one_pixel_const_alpha(dst[x], src[x], const_alpha, one_minus_const_alpha); const __m128i half = _mm_set1_epi16(0x80); @@ -239,9 +235,7 @@ void QT_FASTCALL comp_func_Source_sse2(uint *dst, const uint *src, int length, u int x = 0; // 1) prologue, align on 16 bytes - const int offsetToAlignOn16Bytes = (4 - ((reinterpret_cast(dst) >> 2) & 0x3)) & 0x3; - const int prologLength = qMin(length, offsetToAlignOn16Bytes); - for (; x < prologLength; ++x) + ALIGNMENT_PROLOGUE_16BYTES(dst, x, length) dst[x] = INTERPOLATE_PIXEL_255(src[x], const_alpha, dst[x], ialpha); // 2) interpolate pixels with SSE2 diff --git a/src/gui/painting/qdrawingprimitive_sse2_p.h b/src/gui/painting/qdrawingprimitive_sse2_p.h index 18355c2..d8f6bf5 100644 --- a/src/gui/painting/qdrawingprimitive_sse2_p.h +++ b/src/gui/painting/qdrawingprimitive_sse2_p.h @@ -143,9 +143,7 @@ QT_BEGIN_NAMESPACE int x = 0; \ \ /* First, get dst aligned. */ \ - const int offsetToAlignOn16Bytes = (4 - ((reinterpret_cast(dst) >> 2) & 0x3)) & 0x3;\ - const int prologLength = qMin(length, offsetToAlignOn16Bytes);\ - for (; x < prologLength; ++x) { \ + ALIGNMENT_PROLOGUE_16BYTES(dst, x, length) { \ uint s = src[x]; \ if (s >= 0xff000000) \ dst[x] = s; \ @@ -202,9 +200,7 @@ QT_BEGIN_NAMESPACE { \ int x = 0; \ \ - const int offsetToAlignOn16Bytes = (4 - ((reinterpret_cast(dst) >> 2) & 0x3)) & 0x3;\ - const int prologLength = qMin(length, offsetToAlignOn16Bytes);\ - for (; x < prologLength; ++x) { \ + ALIGNMENT_PROLOGUE_16BYTES(dst, x, length) { \ quint32 s = src[x]; \ if (s != 0) { \ s = BYTE_MUL(s, const_alpha); \ -- cgit v0.12 From 05bb249c2ad3ee15eb205a806f8546c105683096 Mon Sep 17 00:00:00 2001 From: Jiang Jiang Date: Thu, 5 Aug 2010 11:21:03 +0200 Subject: Fix QTextEngine overflow caused by extremely long text Internally, QTextEngine use int to calculate most of the layout data required. If a string longer than 2^24 is passed into either QTextEngine or classes using it (QStackTextEngine, QPainter, QFontMetrics, etc.), overflow will happen because the memory size required to allocate for layout will become too large for int to handle. This patch will prevent these cases and add error handling mechanism for relevant code. Task-number: QT-3658 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/gui/text/qtextengine.cpp | 87 ++++++++++++++++++++++++++++++++------------ src/gui/text/qtextengine_p.h | 14 +++++-- src/gui/text/qtextlayout.cpp | 19 +++++++--- 3 files changed, 87 insertions(+), 33 deletions(-) diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 439f2a4..5670e29 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -923,6 +923,13 @@ void QTextEngine::shapeText(int item) const si.width += glyphs.advances_x[i]; } +static inline bool hasCaseChange(const QScriptItem &si) +{ + return si.analysis.flags == QScriptAnalysis::SmallCaps || + si.analysis.flags == QScriptAnalysis::Uppercase || + si.analysis.flags == QScriptAnalysis::Lowercase; +} + #if defined(Q_WS_WINCE) //TODO // set the glyph attributes heuristically. Assumes a 1 to 1 relationship between chars and glyphs // and no reordering. @@ -1050,14 +1057,15 @@ void QTextEngine::shapeTextWithCE(int item) const if (option.useDesignMetrics()) flags |= DesignMetrics; - attributes(); // pre-initialize char attributes + // pre-initialize char attributes + if (! attributes()) + return; const int len = length(item); int num_glyphs = length(item); const QChar *str = layoutData->string.unicode() + si.position; ushort upperCased[256]; - if (si.analysis.flags == QScriptAnalysis::SmallCaps || si.analysis.flags == QScriptAnalysis::Uppercase - || si.analysis.flags == QScriptAnalysis::Lowercase) { + if (hasCaseChange(si)) { ushort *uc = upperCased; if (len > 256) uc = new ushort[len]; @@ -1071,7 +1079,14 @@ void QTextEngine::shapeTextWithCE(int item) const } while (true) { - ensureSpace(num_glyphs); + if (! ensureSpace(num_glyphs)) { + // If str is converted to uppercase/lowercase form with a new buffer, + // we need to delete that buffer before return for error + const ushort *uc = reinterpret_cast(str); + if (hasCaseChange(si) && uc != upperCased) + delete [] uc; + return; + } num_glyphs = layoutData->glyphLayout.numGlyphs - layoutData->used; QGlyphLayout g = availableGlyphs(&si); @@ -1092,9 +1107,7 @@ void QTextEngine::shapeTextWithCE(int item) const layoutData->used += si.num_glyphs; const ushort *uc = reinterpret_cast(str); - if ((si.analysis.flags == QScriptAnalysis::SmallCaps || si.analysis.flags == QScriptAnalysis::Uppercase - || si.analysis.flags == QScriptAnalysis::Lowercase) - && uc != upperCased) + if (hasCaseChange(si) && uc != upperCased) delete [] uc; } #endif @@ -1133,8 +1146,7 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const entire_shaper_item.item.bidiLevel = si.analysis.bidiLevel; HB_UChar16 upperCased[256]; // XXX what about making this 4096, so we don't have to extend it ever. - if (si.analysis.flags == QScriptAnalysis::SmallCaps || si.analysis.flags == QScriptAnalysis::Uppercase - || si.analysis.flags == QScriptAnalysis::Lowercase) { + if (hasCaseChange(si)) { HB_UChar16 *uc = upperCased; if (entire_shaper_item.item.length > 256) uc = new HB_UChar16[entire_shaper_item.item.length]; @@ -1156,17 +1168,24 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const entire_shaper_item.shaperFlags |= HB_ShaperFlag_UseDesignMetrics; entire_shaper_item.num_glyphs = qMax(layoutData->glyphLayout.numGlyphs - layoutData->used, int(entire_shaper_item.item.length)); - ensureSpace(entire_shaper_item.num_glyphs); + if (! ensureSpace(entire_shaper_item.num_glyphs)) { + if (hasCaseChange(si)) + delete [] const_cast(entire_shaper_item.string); + return; + } QGlyphLayout initialGlyphs = availableGlyphs(&si).mid(0, entire_shaper_item.num_glyphs); if (!stringToGlyphs(&entire_shaper_item, &initialGlyphs, font)) { - ensureSpace(entire_shaper_item.num_glyphs); + if (! ensureSpace(entire_shaper_item.num_glyphs)) { + if (hasCaseChange(si)) + delete [] const_cast(entire_shaper_item.string); + return; + } initialGlyphs = availableGlyphs(&si).mid(0, entire_shaper_item.num_glyphs); if (!stringToGlyphs(&entire_shaper_item, &initialGlyphs, font)) { // ############ if this happens there's a bug in the fontengine - if ((si.analysis.flags == QScriptAnalysis::SmallCaps || si.analysis.flags == QScriptAnalysis::Uppercase - || si.analysis.flags == QScriptAnalysis::Lowercase) && entire_shaper_item.string != upperCased) + if (hasCaseChange(si) && entire_shaper_item.string != upperCased) delete [] const_cast(entire_shaper_item.string); return; } @@ -1231,7 +1250,11 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const remaining_glyphs -= shaper_item.initialGlyphCount; do { - ensureSpace(glyph_pos + shaper_item.num_glyphs + remaining_glyphs); + if (! ensureSpace(glyph_pos + shaper_item.num_glyphs + remaining_glyphs)) { + if (hasCaseChange(si)) + delete [] const_cast(entire_shaper_item.string); + return; + } const QGlyphLayout g = availableGlyphs(&si).mid(glyph_pos); moveGlyphData(g.mid(shaper_item.num_glyphs), g.mid(shaper_item.initialGlyphCount), remaining_glyphs); @@ -1271,8 +1294,7 @@ void QTextEngine::shapeTextWithHarfbuzz(int item) const layoutData->used += si.num_glyphs; - if ((si.analysis.flags == QScriptAnalysis::SmallCaps || si.analysis.flags == QScriptAnalysis::Uppercase) - && entire_shaper_item.string != upperCased) + if (hasCaseChange(si) && entire_shaper_item.string != upperCased) delete [] const_cast(entire_shaper_item.string); } @@ -1317,7 +1339,8 @@ const HB_CharAttributes *QTextEngine::attributes() const return (HB_CharAttributes *) layoutData->memory; itemize(); - ensureSpace(layoutData->string.length()); + if (! ensureSpace(layoutData->string.length())) + return NULL; QVarLengthArray hbScriptItems(layoutData->items.size()); @@ -1864,7 +1887,10 @@ void QTextEngine::justify(const QScriptLine &line) // don't include trailing white spaces when doing justification int line_length = line.length; - const HB_CharAttributes *a = attributes()+line.from; + const HB_CharAttributes *a = attributes(); + if (! a) + return; + a += line.from; while (line_length && a[line_length-1].whiteSpace) --line_length; // subtract one char more, as we can't justfy after the last character @@ -2045,7 +2071,7 @@ QTextEngine::LayoutData::LayoutData() memory_on_stack = false; used = 0; hasBidi = false; - inLayout = false; + layoutState = LayoutEmpty; haveCharAttributes = false; logClustersPtr = 0; available_glyphs = 0; @@ -2079,7 +2105,7 @@ QTextEngine::LayoutData::LayoutData(const QString &str, void **stack_memory, int } used = 0; hasBidi = false; - inLayout = false; + layoutState = LayoutEmpty; haveCharAttributes = false; } @@ -2090,12 +2116,12 @@ QTextEngine::LayoutData::~LayoutData() memory = 0; } -void QTextEngine::LayoutData::reallocate(int totalGlyphs) +bool QTextEngine::LayoutData::reallocate(int totalGlyphs) { Q_ASSERT(totalGlyphs >= glyphLayout.numGlyphs); if (memory_on_stack && available_glyphs >= totalGlyphs) { glyphLayout.grow(glyphLayout.data(), totalGlyphs); - return; + return true; } int space_charAttributes = sizeof(HB_CharAttributes)*string.length()/sizeof(void*) + 1; @@ -2103,7 +2129,14 @@ void QTextEngine::LayoutData::reallocate(int totalGlyphs) int space_glyphs = QGlyphLayout::spaceNeededForGlyphLayout(totalGlyphs)/sizeof(void*) + 2; int newAllocated = space_charAttributes + space_glyphs + space_logClusters; - Q_ASSERT(newAllocated >= allocated); + // These values can be negative if the length of string/glyphs causes overflow, + // we can't layout such a long string all at once, so return false here to + // indicate there is a failure + if (space_charAttributes < 0 || space_logClusters < 0 || space_glyphs < 0 || newAllocated < allocated) { + layoutState = LayoutFailed; + return false; + } + void **newMem = memory; newMem = (void **)::realloc(memory_on_stack ? 0 : memory, newAllocated*sizeof(void *)); Q_CHECK_PTR(newMem); @@ -2124,6 +2157,7 @@ void QTextEngine::LayoutData::reallocate(int totalGlyphs) glyphLayout.grow(reinterpret_cast(m), totalGlyphs); allocated = newAllocated; + return true; } // grow to the new size, copying the existing data to the new layout @@ -2155,7 +2189,7 @@ void QTextEngine::freeMemory() } else { layoutData->used = 0; layoutData->hasBidi = false; - layoutData->inLayout = false; + layoutData->layoutState = LayoutEmpty; layoutData->haveCharAttributes = false; } for (int i = 0; i < lines.size(); ++i) { @@ -2314,6 +2348,9 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int shape(i); HB_CharAttributes *attributes = const_cast(this->attributes()); + if (!attributes) + return QString(); + unsigned short *logClusters = this->logClusters(&si); QGlyphLayout glyphs = shapedGlyphs(&si); @@ -2385,6 +2422,8 @@ QString QTextEngine::elidedText(Qt::TextElideMode mode, const QFixed &width, int return QString(); const HB_CharAttributes *attributes = this->attributes(); + if (!attributes) + return QString(); if (mode == Qt::ElideRight) { QFixed currentWidth; diff --git a/src/gui/text/qtextengine_p.h b/src/gui/text/qtextengine_p.h index e623fa5..4cbe81f 100644 --- a/src/gui/text/qtextengine_p.h +++ b/src/gui/text/qtextengine_p.h @@ -416,6 +416,11 @@ class QTextFormatCollection; class Q_GUI_EXPORT QTextEngine { public: + enum LayoutState { + LayoutEmpty, + InLayout, + LayoutFailed, + }; struct LayoutData { LayoutData(const QString &str, void **stack_memory, int mem_size); LayoutData(); @@ -428,11 +433,11 @@ public: QGlyphLayout glyphLayout; mutable int used; uint hasBidi : 1; - uint inLayout : 1; + uint layoutState : 2; uint memory_on_stack : 1; bool haveCharAttributes; QString string; - void reallocate(int totalGlyphs); + bool reallocate(int totalGlyphs); }; QTextEngine(LayoutData *data); @@ -520,9 +525,10 @@ public: return layoutData->glyphLayout.mid(si->glyph_data_offset, si->num_glyphs); } - inline void ensureSpace(int nGlyphs) const { + inline bool ensureSpace(int nGlyphs) const { if (layoutData->glyphLayout.numGlyphs - layoutData->used < nGlyphs) - layoutData->reallocate((((layoutData->used + nGlyphs)*3/2 + 15) >> 4) << 4); + return layoutData->reallocate((((layoutData->used + nGlyphs)*3/2 + 15) >> 4) << 4); + return true; } void freeMemory(); diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 674064e..5a11c87 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -74,6 +74,8 @@ static inline QFixed leadingSpaceWidth(QTextEngine *eng, const QScriptLine &line int pos = line.length; const HB_CharAttributes *attributes = eng->attributes(); + if (!attributes) + return QFixed(); while (pos > 0 && attributes[line.from + pos - 1].whiteSpace) --pos; return eng->width(line.from + pos, line.length - pos); @@ -601,7 +603,7 @@ bool QTextLayout::cacheEnabled() const void QTextLayout::beginLayout() { #ifndef QT_NO_DEBUG - if (d->layoutData && d->layoutData->inLayout) { + if (d->layoutData && d->layoutData->layoutState == QTextEngine::InLayout) { qWarning("QTextLayout::beginLayout: Called while already doing layout"); return; } @@ -609,7 +611,7 @@ void QTextLayout::beginLayout() d->invalidate(); d->clearLineData(); d->itemize(); - d->layoutData->inLayout = true; + d->layoutData->layoutState = QTextEngine::InLayout; } /*! @@ -618,7 +620,7 @@ void QTextLayout::beginLayout() void QTextLayout::endLayout() { #ifndef QT_NO_DEBUG - if (!d->layoutData || !d->layoutData->inLayout) { + if (!d->layoutData || d->layoutData->layoutState == QTextEngine::LayoutEmpty) { qWarning("QTextLayout::endLayout: Called without beginLayout()"); return; } @@ -627,7 +629,7 @@ void QTextLayout::endLayout() if (l && d->lines.at(l-1).length < 0) { QTextLine(l-1, d).setNumColumns(INT_MAX); } - d->layoutData->inLayout = false; + d->layoutData->layoutState = QTextEngine::LayoutEmpty; if (!d->cacheGlyphs) d->freeMemory(); } @@ -757,11 +759,14 @@ bool QTextLayout::isValidCursorPosition(int pos) const QTextLine QTextLayout::createLine() { #ifndef QT_NO_DEBUG - if (!d->layoutData || !d->layoutData->inLayout) { + if (!d->layoutData || d->layoutData->layoutState == QTextEngine::LayoutEmpty) { qWarning("QTextLayout::createLine: Called without layouting"); return QTextLine(); } #endif + if (d->layoutData->layoutState == QTextEngine::LayoutFailed) + return QTextLine(); + int l = d->lines.size(); if (l && d->lines.at(l-1).length < 0) { QTextLine(l-1, d).setNumColumns(INT_MAX); @@ -1801,6 +1806,8 @@ void QTextLine::layout_helper(int maxGlyphs) Qt::Alignment alignment = eng->option.alignment(); const HB_CharAttributes *attributes = eng->attributes(); + if (!attributes) + return; lbh.currentPosition = line.from; int end = 0; lbh.logClusters = eng->layoutData->logClustersPtr; @@ -1814,6 +1821,8 @@ void QTextLine::layout_helper(int maxGlyphs) if (!current.num_glyphs) { eng->shape(item); attributes = eng->attributes(); + if (!attributes) + return; lbh.logClusters = eng->layoutData->logClustersPtr; } lbh.currentPosition = qMax(line.from, current.position); -- cgit v0.12 From cb086eb5340c4c41efaf45373aa05c37e8aa974a Mon Sep 17 00:00:00 2001 From: David Boddie Date: Thu, 5 Aug 2010 17:19:48 +0200 Subject: Doc: Fixed qdoc warnings. Reviewed-by: Trust Me --- doc/src/declarative/declarativeui.qdoc | 2 +- doc/src/declarative/qtdeclarative.qdoc | 2 +- doc/src/examples/qml-examples.qdoc | 2 +- doc/src/examples/simpletreemodel.qdoc | 4 +- doc/src/examples/spinboxdelegate.qdoc | 4 +- doc/src/external-resources.qdoc | 2 +- doc/src/index.qdoc | 10 ++--- doc/src/modules.qdoc | 1 - doc/src/overviews.qdoc | 3 +- doc/src/qt-webpages.qdoc | 5 +++ src/dbus/qdbusconnection.cpp | 4 ++ src/declarative/qml/qdeclarativeimageprovider.cpp | 8 ++-- src/declarative/util/qdeclarativeanimation.cpp | 2 +- src/declarative/util/qdeclarativetransition.cpp | 4 +- src/gui/graphicsview/qgraphicsitem.cpp | 18 +++++++++ src/gui/graphicsview/qgraphicstransform.cpp | 21 +++++++++++ src/gui/s60framework/qs60mainapplication.cpp | 6 +++ src/gui/s60framework/qs60mainappui.cpp | 45 +++++++++++++++++++++++ src/network/access/qnetworkrequest.cpp | 20 +++++----- tools/qdoc3/test/qt-html-templates.qdocconf | 7 +--- 20 files changed, 130 insertions(+), 40 deletions(-) diff --git a/doc/src/declarative/declarativeui.qdoc b/doc/src/declarative/declarativeui.qdoc index 217e372..42189c0 100644 --- a/doc/src/declarative/declarativeui.qdoc +++ b/doc/src/declarative/declarativeui.qdoc @@ -27,7 +27,7 @@ /*! \title Qt Quick -\page declarativeui.html +\page qtquick.html \brief Qt Quick provides a declarative framework for building highly dynamic, custom user interfaces. diff --git a/doc/src/declarative/qtdeclarative.qdoc b/doc/src/declarative/qtdeclarative.qdoc index 413eb59..b4f4c83 100644 --- a/doc/src/declarative/qtdeclarative.qdoc +++ b/doc/src/declarative/qtdeclarative.qdoc @@ -48,7 +48,7 @@ \endcode For more information on the Qt Declarative module, see the - \l{declarativeui.html}{Qt Quick} documentation. + \l{Qt Quick} documentation. */ diff --git a/doc/src/examples/qml-examples.qdoc b/doc/src/examples/qml-examples.qdoc index 8d3aa25..0d191c9 100644 --- a/doc/src/examples/qml-examples.qdoc +++ b/doc/src/examples/qml-examples.qdoc @@ -562,7 +562,7 @@ \example declarative/ui-components/dialcontrol This example shows how to create a dial-type control. It combines - \l Image elements with \l Rotation transforms and \l SpringAnimatino behaviors + \l Image elements with \l Rotation transforms and \l SpringAnimation behaviors to produce an interactive speedometer-type dial. \image qml-dialcontrol-example.png diff --git a/doc/src/examples/simpletreemodel.qdoc b/doc/src/examples/simpletreemodel.qdoc index c34f4af..790d5fa 100644 --- a/doc/src/examples/simpletreemodel.qdoc +++ b/doc/src/examples/simpletreemodel.qdoc @@ -32,7 +32,7 @@ The Simple Tree Model example shows how to create a basic, read-only hierarchical model to use with Qt's standard view classes. For a description of simple non-hierarchical list and table models, see the - \l{model-view-programming.html}{Model/View Programming} overview. + \l{Model/View Programming} overview. \image simpletreemodel-example.png @@ -40,7 +40,7 @@ information in a data source, using an abstract model of the data to simplify and standardize the way it is accessed. Simple models represent data as a table of items, and allow views to access this data via an - \l{model-view-model.html}{index-based} system. More generally, models can + \l{Model/View Programming#Models}{index-based} system. More generally, models can be used to represent data in the form of a tree structure by allowing each item to act as a parent to a table of child items. diff --git a/doc/src/examples/spinboxdelegate.qdoc b/doc/src/examples/spinboxdelegate.qdoc index 49e3295..48e4bfa 100644 --- a/doc/src/examples/spinboxdelegate.qdoc +++ b/doc/src/examples/spinboxdelegate.qdoc @@ -42,8 +42,8 @@ \image spinboxdelegate-example.png This concepts behind this example are covered in the - \l{model-view-delegate.html}{Delegate Classes} chapter of the - \l{model-view-programming.html}{Model/View Programming} overview. + \l{Model/View Programming#Delegate Classes}{Delegate Classes} chapter of the + \l{Model/View Programming} overview. \section1 SpinBoxDelegate Class Definition diff --git a/doc/src/external-resources.qdoc b/doc/src/external-resources.qdoc index 5c6108a..e901124c 100644 --- a/doc/src/external-resources.qdoc +++ b/doc/src/external-resources.qdoc @@ -416,7 +416,7 @@ /*! \externalpage http://opensource.org/licenses/bsd-license.php - \title BSD License + \title New and Modified BSD Licenses */ /*! diff --git a/doc/src/index.qdoc b/doc/src/index.qdoc index 7efd1e6..499667c 100644 --- a/doc/src/index.qdoc +++ b/doc/src/index.qdoc @@ -65,7 +65,6 @@
@@ -94,12 +92,12 @@
diff --git a/doc/src/modules.qdoc b/doc/src/modules.qdoc index a81bfb2..c51fcad 100644 --- a/doc/src/modules.qdoc +++ b/doc/src/modules.qdoc @@ -116,7 +116,6 @@ /*! \module QtMultimedia - \page qtmultimedia-module.html \title QtMultimedia Module \contentspage All Modules \previouspage QtCore diff --git a/doc/src/overviews.qdoc b/doc/src/overviews.qdoc index a1773a3..c7b88cf 100644 --- a/doc/src/overviews.qdoc +++ b/doc/src/overviews.qdoc @@ -55,8 +55,7 @@ These pages are about Qt's traditional set of GUI components for building both native look ^ feel and custom UI's for the desktop - environment. Use \l {declarativeui.html} {Qt Quick} for building - UI's for mobile devices. + environment. Use \l{Qt Quick} for building UI's for mobile devices. \generatelist {related} */ diff --git a/doc/src/qt-webpages.qdoc b/doc/src/qt-webpages.qdoc index 0c61285..5d9b41b 100644 --- a/doc/src/qt-webpages.qdoc +++ b/doc/src/qt-webpages.qdoc @@ -234,3 +234,8 @@ \externalpage http://qt.gitorious.org \title Public Qt Repository */ + +/*! + \externalpage http://get.qt.nokia.com/nokiasmartinstaller/ + \title Smart Installer +*/ diff --git a/src/dbus/qdbusconnection.cpp b/src/dbus/qdbusconnection.cpp index 5cbb8ca..87ee3d1 100644 --- a/src/dbus/qdbusconnection.cpp +++ b/src/dbus/qdbusconnection.cpp @@ -227,6 +227,10 @@ void QDBusConnectionManager::setConnection(const QString &name, QDBusConnectionP \value ExportChildObjects export this object's child objects + \value ExportScriptableInvokables export this object's scriptable methods + \value ExportNonScriptableInvokables export this object's non-scriptable methods + \value ExportAllInvokables export all of this object's methods + \sa registerObject(), QDBusAbstractAdaptor, {usingadaptors.html}{Using adaptors} */ diff --git a/src/declarative/qml/qdeclarativeimageprovider.cpp b/src/declarative/qml/qdeclarativeimageprovider.cpp index 241df87..4743a1b 100644 --- a/src/declarative/qml/qdeclarativeimageprovider.cpp +++ b/src/declarative/qml/qdeclarativeimageprovider.cpp @@ -59,13 +59,13 @@ public: \list \o Loaded using QPixmaps rather than actual image files - \o Loaded asynchronously in a separate thread, if imageType() is \l ImageType::Image + \o Loaded asynchronously in a separate thread, if imageType() is \l{QDeclarativeImageProvider::ImageType}{ImageType::Image} \endlist To specify that an image should be loaded by an image provider, use the \bold {"image:"} scheme for the URL source of the image, followed by the identifiers of the image provider and the requested image. For example: - + \qml Image { source: "image://myimageprovider/image.png" } \endqml @@ -83,7 +83,7 @@ public: and "red", respectively: \snippet examples/declarative/cppextensions/imageprovider/imageprovider-example.qml 0 - + When these images are loaded by QML, it looks for a matching image provider and calls its requestImage() or requestPixmap() method (depending on its imageType()) to load the image. The method is called with the \c id @@ -136,7 +136,7 @@ public: main thread. In this case, if \l {Image::}{asynchronous} is set to \c true, the value is ignored and the image is loaded synchronously. - + \sa QDeclarativeEngine::addImageProvider() */ diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp index 6a9cf95..cda7623 100644 --- a/src/declarative/util/qdeclarativeanimation.cpp +++ b/src/declarative/util/qdeclarativeanimation.cpp @@ -1323,7 +1323,7 @@ void QDeclarativeVector3dAnimation::setTo(QVector3D t) \snippet doc/src/snippets/declarative/rotationanimation.qml 0 - Notice the RotationAnimation did not need to set a \l {RotationAnimation::}{target} + Notice the RotationAnimation did not need to set a \l target value. As a convenience, when used in a transition, RotationAnimation will rotate all properties named "rotation" or "angle". You can override this by providing your own properties via \l {PropertyAnimation::properties}{properties} or diff --git a/src/declarative/util/qdeclarativetransition.cpp b/src/declarative/util/qdeclarativetransition.cpp index 582191b..8de6b23 100644 --- a/src/declarative/util/qdeclarativetransition.cpp +++ b/src/declarative/util/qdeclarativetransition.cpp @@ -60,10 +60,10 @@ QT_BEGIN_NAMESPACE For example, the following \l Rectangle has two states: the default state, and an added "moved" state. In the "moved state, the rectangle's position changes - to (50, 50). The added \l Transition specifies that when the rectangle + to (50, 50). The added Transition specifies that when the rectangle changes between the default and the "moved" state, any changes to the \c x and \c y properties should be animated, using an \c Easing.InOutQuad. - + \snippet doc/src/snippets/declarative/transition.qml 0 To define multiple transitions, specify \l Item::transitions as a list: diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 1626d83..2856699 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -7965,6 +7965,24 @@ void QGraphicsItemPrivate::resetHeight() */ /*! + \property QGraphicsObject::children + \since 4.7 + \internal +*/ + +/*! + \property QGraphicsObject::width + \since 4.7 + \internal +*/ + +/*! + \property QGraphicsObject::height + \since 4.7 + \internal +*/ + +/*! \class QAbstractGraphicsShapeItem \brief The QAbstractGraphicsShapeItem class provides a common base for all path items. diff --git a/src/gui/graphicsview/qgraphicstransform.cpp b/src/gui/graphicsview/qgraphicstransform.cpp index 986bee6..27dceb8 100644 --- a/src/gui/graphicsview/qgraphicstransform.cpp +++ b/src/gui/graphicsview/qgraphicstransform.cpp @@ -565,6 +565,27 @@ void QGraphicsRotation::applyTo(QMatrix4x4 *matrix) const \sa QGraphicsRotation::axis */ +/*! + \fn QGraphicsScale::xScaleChanged() + \since 4.7 + + This signal is emitted whenever the \l xScale property changes. +*/ + +/*! + \fn QGraphicsScale::yScaleChanged() + \since 4.7 + + This signal is emitted whenever the \l yScale property changes. +*/ + +/*! + \fn QGraphicsScale::zScaleChanged() + \since 4.7 + + This signal is emitted whenever the \l zScale property changes. +*/ + #include "moc_qgraphicstransform.cpp" QT_END_NAMESPACE diff --git a/src/gui/s60framework/qs60mainapplication.cpp b/src/gui/s60framework/qs60mainapplication.cpp index 0f9367e..185c06f 100644 --- a/src/gui/s60framework/qs60mainapplication.cpp +++ b/src/gui/s60framework/qs60mainapplication.cpp @@ -141,11 +141,17 @@ void QS60MainApplication::PreDocConstructL() QS60MainApplicationBase::PreDocConstructL(); } +/*! + \internal +*/ CDictionaryStore *QS60MainApplication::OpenIniFileLC(RFs &aFs) const { return QS60MainApplicationBase::OpenIniFileLC(aFs); } +/*! + \internal +*/ void QS60MainApplication::NewAppServerL(CApaAppServer *&aAppServer) { QS60MainApplicationBase::NewAppServerL(aAppServer); diff --git a/src/gui/s60framework/qs60mainappui.cpp b/src/gui/s60framework/qs60mainappui.cpp index 40c2d03..72cf577 100644 --- a/src/gui/s60framework/qs60mainappui.cpp +++ b/src/gui/s60framework/qs60mainappui.cpp @@ -281,76 +281,121 @@ void QS60MainAppUi::RestoreMenuL(CCoeControl *menuWindow, TInt resourceId, TMenu } } +/*! + \internal +*/ void QS60MainAppUi::Exit() { QS60MainAppUiBase::Exit(); } +/*! + \internal +*/ void QS60MainAppUi::SetFadedL(TBool aFaded) { QS60MainAppUiBase::SetFadedL(aFaded); } +/*! + \internal +*/ TRect QS60MainAppUi::ApplicationRect() const { return QS60MainAppUiBase::ApplicationRect(); } +/*! + \internal +*/ void QS60MainAppUi::HandleScreenDeviceChangedL() { QS60MainAppUiBase::HandleScreenDeviceChangedL(); } +/*! + \internal +*/ void QS60MainAppUi::HandleApplicationSpecificEventL(TInt aType, const TWsEvent &aEvent) { QS60MainAppUiBase::HandleApplicationSpecificEventL(aType, aEvent); } +/*! + \internal +*/ TTypeUid::Ptr QS60MainAppUi::MopSupplyObject(TTypeUid aId) { return QS60MainAppUiBase::MopSupplyObject(aId); } +/*! + \internal +*/ void QS60MainAppUi::ProcessCommandL(TInt aCommand) { QS60MainAppUiBase::ProcessCommandL(aCommand); } +/*! + \internal +*/ TErrorHandlerResponse QS60MainAppUi::HandleError (TInt aError, const SExtendedError &aExtErr, TDes &aErrorText, TDes &aContextText) { return QS60MainAppUiBase::HandleError(aError, aExtErr, aErrorText, aContextText); } +/*! + \internal +*/ void QS60MainAppUi::HandleViewDeactivation(const TVwsViewId &aViewIdToBeDeactivated, const TVwsViewId &aNewlyActivatedViewId) { QS60MainAppUiBase::HandleViewDeactivation(aViewIdToBeDeactivated, aNewlyActivatedViewId); } +/*! + \internal +*/ void QS60MainAppUi::PrepareToExit() { QS60MainAppUiBase::PrepareToExit(); } +/*! + \internal +*/ void QS60MainAppUi::HandleTouchPaneSizeChange() { QS60MainAppUiBase::HandleTouchPaneSizeChange(); } +/*! + \internal +*/ void QS60MainAppUi::HandleSystemEventL(const TWsEvent &aEvent) { QS60MainAppUiBase::HandleSystemEventL(aEvent); } +/*! + \internal +*/ void QS60MainAppUi::Reserved_MtsmPosition() { QS60MainAppUiBase::Reserved_MtsmPosition(); } +/*! + \internal +*/ void QS60MainAppUi::Reserved_MtsmObject() { QS60MainAppUiBase::Reserved_MtsmObject(); } +/*! + \internal +*/ void QS60MainAppUi::HandleForegroundEventL(TBool aForeground) { QS60MainAppUiBase::HandleForegroundEventL(aForeground); diff --git a/src/network/access/qnetworkrequest.cpp b/src/network/access/qnetworkrequest.cpp index fa592c2..8710cb6 100644 --- a/src/network/access/qnetworkrequest.cpp +++ b/src/network/access/qnetworkrequest.cpp @@ -174,12 +174,12 @@ QT_BEGIN_NAMESPACE When using this flag with sequential upload data, the ContentLengthHeader header must be set. - \value HttpPipeliningAllowedAttribute + \value HttpPipeliningAllowedAttribute Requests only, type: QVariant::Bool (default: false) Indicates whether the QNetworkAccessManager code is allowed to use HTTP pipelining with this request. - \value HttpPipeliningWasUsedAttribute + \value HttpPipeliningWasUsedAttribute Replies only, type: QVariant::Bool Indicates whether the HTTP pipelining was used for receiving this reply. @@ -200,9 +200,9 @@ QT_BEGIN_NAMESPACE See http://www.w3.org/TR/XMLHttpRequest2/#credentials-flag for more information. - \since 4.7 + (This value was introduced in 4.7.) - \value CookieSaveControlAttribute + \value CookieSaveControlAttribute Requests only, type: QVariant::Int (default: QNetworkRequest::Automatic) Indicates whether to save 'Cookie' headers received from the server in reply to the request. @@ -213,9 +213,9 @@ QT_BEGIN_NAMESPACE See http://www.w3.org/TR/XMLHttpRequest2/#credentials-flag for more information. - \since 4.7 + (This value was introduced in 4.7.) - \value AuthenticationReuseAttribute + \value AuthenticationReuseAttribute Requests only, type: QVariant::Int (default: QNetworkRequest::Automatic) Indicates whether to use cached authorization credentials in the request, if available. If this is set to QNetworkRequest::Manual and the authentication @@ -228,15 +228,13 @@ QT_BEGIN_NAMESPACE See http://www.w3.org/TR/XMLHttpRequest2/#credentials-flag for more information. - \since 4.7 + (This value was introduced in 4.7.) \omitvalue MaximumDownloadBufferSizeAttribute - \since 4.7 - \internal + (This value was introduced in 4.7.) \omitvalue DownloadBufferAttribute - \since 4.7 - \internal + (This value was introduced in 4.7.) \value User Special type. Additional information can be passed in diff --git a/tools/qdoc3/test/qt-html-templates.qdocconf b/tools/qdoc3/test/qt-html-templates.qdocconf index cf15628..089b11f 100644 --- a/tools/qdoc3/test/qt-html-templates.qdocconf +++ b/tools/qdoc3/test/qt-html-templates.qdocconf @@ -4,9 +4,6 @@ HTML.stylesheets = style/style.css \ style/style_ie8.css \ style/style_ie6.css -HTML.creatorpostheader = "**\n" -HTML.creatorpostpostheader = "***\n" - HTML.postheader = "
\n" \ "
\n" \ "
\n" \ @@ -48,7 +45,7 @@ HTML.postheader = "
\n" \ "
  • Qt Topics \n" \ "
      \n" \ "
    • Basic Qt architecture
    • \n" \ - "
    • Device UI's & Qt Quick
    • \n" \ + "
    • Device UI's & Qt Quick
    • \n" \ "
    • Desktop UI components
    • \n" \ "
    • Platform-specific info
    • \n" \ "
    • How-To's and Best Practices
    • \n" \ @@ -100,7 +97,7 @@ HTML.postheader = "
      \n" \ "
      \n" \ " \n" \ -- cgit v0.12 From a49f2700c6b5c0f5851f9cfab38b5554e9530577 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Thu, 5 Aug 2010 17:22:38 +0200 Subject: QStyleSheet documentation: QMenu's tear-off is styled with ::tearoff Task-number: QTBUG-12553 Reviewed-by: Carlos Duclos --- doc/src/widgets-and-layouts/stylesheet.qdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/src/widgets-and-layouts/stylesheet.qdoc b/doc/src/widgets-and-layouts/stylesheet.qdoc index 1390376..977f641 100644 --- a/doc/src/widgets-and-layouts/stylesheet.qdoc +++ b/doc/src/widgets-and-layouts/stylesheet.qdoc @@ -925,7 +925,7 @@ The scroller is styled using the \l{#scroller-sub}{::scroller}. - The tear-off is styled using the \l{#tear-off-sub}{::tear-off}. + The tear-off is styled using the \l{#tearoff-sub}{::tearoff}. See \l{Qt Style Sheets Examples#Customizing QMenu}{Customizing QMenu} for an example. @@ -3337,7 +3337,7 @@ \o The tear indicator of a QTabBar. \row - \o \c ::tear-off \target tear-off-sub + \o \c ::tearoff \target tearoff-sub \o The tear-off indicator of a QMenu. \row -- cgit v0.12 From eb6d70eeeaaafb748a5fca38f6f033136aadf148 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 6 Aug 2010 10:26:48 +0200 Subject: Test we do not have compiler warnings in our headers with more options I removed some statics because else the test could not be run several times Reviewed-by: Andreas Kling --- tests/auto/compilerwarnings/tst_compilerwarnings.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/auto/compilerwarnings/tst_compilerwarnings.cpp b/tests/auto/compilerwarnings/tst_compilerwarnings.cpp index 82c327a..8d344d8 100644 --- a/tests/auto/compilerwarnings/tst_compilerwarnings.cpp +++ b/tests/auto/compilerwarnings/tst_compilerwarnings.cpp @@ -114,6 +114,9 @@ void tst_CompilerWarnings::warnings_data() QTest::addColumn("cflags"); QTest::newRow("standard") << QStringList(); + QTest::newRow("warn deprecated, fast plus, no debug") << (QStringList() << "-DQT_DEPRECATED_WARNINGS" + << "-DQT_USE_FAST_OPERATOR_PLUS" << "-DQT_NU_DEBUG" << "-DQT_NO_DEBUG_STREAM" << "-DQT_NO_WARNING_OUTPUT"); + QTest::newRow("no deprecated, no keywords") << (QStringList() << "-DQT_NO_DEPRECATED" << "-DQT_NO_KEYWORDS"); #if 0 #ifdef Q_WS_QWS @@ -136,14 +139,14 @@ void tst_CompilerWarnings::warnings() QSKIP("gcc 3.x outputs too many bogus warnings", SkipAll); #endif - static QString tmpFile; + /*static*/ QString tmpFile; if (tmpFile.isEmpty()) { QTemporaryFile tmpQFile; tmpQFile.open(); tmpFile = tmpQFile.fileName(); tmpQFile.close(); } - static QString tmpSourceFile; + /*static*/ QString tmpSourceFile; bool openResult = true; const QString tmpBaseName("XXXXXX-test.cpp"); QString templatePath = QDir::temp().absoluteFilePath(tmpBaseName); -- cgit v0.12 From 033b53a02fb02c5aec412e3d87ad9661110c6e6e Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 6 Aug 2010 10:31:20 +0200 Subject: compilation with QT_NO_DEPRECATED Reviewed-by: Andreas Kling --- src/network/bearer/qnetworkconfiguration.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/network/bearer/qnetworkconfiguration.h b/src/network/bearer/qnetworkconfiguration.h index d9d36fd..02f9cb6 100644 --- a/src/network/bearer/qnetworkconfiguration.h +++ b/src/network/bearer/qnetworkconfiguration.h @@ -120,7 +120,9 @@ public: Purpose purpose() const; // Required to maintain source compatibility with Qt Mobility. +#ifdef QT_DEPRECATED QT_DEPRECATED inline QString bearerName() const { return bearerTypeName(); } +#endif BearerType bearerType() const; QString bearerTypeName() const; -- cgit v0.12 From 1b0f790d27cda48137c7114fadc694432a104c90 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 6 Aug 2010 17:48:28 +0200 Subject: QSharedPointer documentation: specify that it is not safe to operate on the same object in different threads Task-number: QTBUG-12700 Reviewed-by: thiago --- src/corelib/tools/qsharedpointer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp index f102598..5fac960 100644 --- a/src/corelib/tools/qsharedpointer.cpp +++ b/src/corelib/tools/qsharedpointer.cpp @@ -67,8 +67,8 @@ QSharedPointer and QWeakPointer are thread-safe and operate atomically on the pointer value. Different threads can also access - the same QSharedPointer or QWeakPointer object at the same time - without need for locking mechanisms. + the QSharedPointer or QWeakPointer pointing to the same object at + the same time without need for locking mechanisms. It should be noted that, while the pointer value can be accessed in this manner, QSharedPointer and QWeakPointer provide no -- cgit v0.12 From d81ab877bc4424d918c400af3f65509f80f22f67 Mon Sep 17 00:00:00 2001 From: Benjamin Poulain Date: Thu, 5 Aug 2010 14:45:49 +0200 Subject: Move the build of Neon file from painting.pri to gui.pro Move the build operation of files using Neon from painting.pri to gui.pro. This will make easier to add Neon files in the future. Reviewed-by: Andreas Kling --- src/gui/gui.pro | 18 ++++++++++++++++++ src/gui/painting/painting.pri | 21 +++------------------ 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/gui/gui.pro b/src/gui/gui.pro index 28440cc..89ae06f 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -77,6 +77,24 @@ symbian { DEPLOYMENT = partial_upgrade $$DEPLOYMENT } +neon: QMAKE_CXXFLAGS *= -mfpu=neon +neon:*-g++* { + HEADERS += $$NEON_HEADERS + SOURCES += $$NEON_SOURCES + + DRAWHELPER_NEON_ASM_FILES = $$NEON_ASM + + neon_compiler.commands = $$QMAKE_CXX -c + neon_compiler.commands += $(CXXFLAGS) $(INCPATH) ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT} + neon_compiler.dependency_type = TYPE_C + neon_compiler.output = ${QMAKE_VAR_OBJECTS_DIR}${QMAKE_FILE_BASE}$${first(QMAKE_EXT_OBJ)} + neon_compiler.input = DRAWHELPER_NEON_ASM_FILES + neon_compiler.variable_out = OBJECTS + neon_compiler.name = compiling[neon] ${QMAKE_FILE_IN} + silent:neon_compiler.commands = @echo compiling[neon] ${QMAKE_FILE_IN} && $$neon_compiler.commands + QMAKE_EXTRA_COMPILERS += neon_compiler +} + contains(QMAKE_MAC_XARCH, no) { DEFINES += QT_NO_MAC_XARCH } else { diff --git a/src/gui/painting/painting.pri b/src/gui/painting/painting.pri index 4023f65..dfa4a48 100644 --- a/src/gui/painting/painting.pri +++ b/src/gui/painting/painting.pri @@ -246,23 +246,8 @@ symbian { QMAKE_CXXFLAGS.ARMCC *= -O3 } -neon:*-g++* { - DEFINES += QT_HAVE_NEON - HEADERS += painting/qdrawhelper_neon_p.h - SOURCES += painting/qdrawhelper_neon.cpp - QMAKE_CXXFLAGS *= -mfpu=neon - - DRAWHELPER_NEON_ASM_FILES = ../3rdparty/pixman/pixman-arm-neon-asm.S painting/qdrawhelper_neon_asm.S - - neon_compiler.commands = $$QMAKE_CXX -c - neon_compiler.commands += $(CXXFLAGS) $(INCPATH) ${QMAKE_FILE_IN} -o ${QMAKE_FILE_OUT} - neon_compiler.dependency_type = TYPE_C - neon_compiler.output = ${QMAKE_VAR_OBJECTS_DIR}${QMAKE_FILE_BASE}$${first(QMAKE_EXT_OBJ)} - neon_compiler.input = DRAWHELPER_NEON_ASM_FILES - neon_compiler.variable_out = OBJECTS - neon_compiler.name = compiling[neon] ${QMAKE_FILE_IN} - silent:neon_compiler.commands = @echo compiling[neon] ${QMAKE_FILE_IN} && $$neon_compiler.commands - QMAKE_EXTRA_COMPILERS += neon_compiler -} +NEON_SOURCES += painting/qdrawhelper_neon.cpp +NEON_HEADERS += painting/qdrawhelper_neon_p.h +NEON_ASM += ../3rdparty/pixman/pixman-arm-neon-asm.S painting/qdrawhelper_neon_asm.S include($$PWD/../../3rdparty/zlib_dependency.pri) -- cgit v0.12 From a0f155cdaf641d92acc8b61be89b96319d16ccba Mon Sep 17 00:00:00 2001 From: Benjamin Poulain Date: Thu, 5 Aug 2010 14:47:54 +0200 Subject: Do the conversion from RGB888 to RGB32 using Neon Doing the conversion with Neon is 700% faster. Help by Thiago Macieira on vacation. Reviewed-by: Thiago Macieira --- src/gui/image/image.pri | 1 + src/gui/image/qimage.cpp | 8 +++ src/gui/image/qimage_neon.cpp | 114 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 123 insertions(+) create mode 100644 src/gui/image/qimage_neon.cpp diff --git a/src/gui/image/image.pri b/src/gui/image/image.pri index b20a04f..f89706c 100644 --- a/src/gui/image/image.pri +++ b/src/gui/image/image.pri @@ -94,5 +94,6 @@ contains(QT_CONFIG, tiff):include($$PWD/qtiffhandler.pri) contains(QT_CONFIG, gif):include($$PWD/qgifhandler.pri) # SIMD +NEON_SOURCES += image/qimage_neon.cpp SSE2_SOURCES += image/qimage_sse2.cpp SSSE3_SOURCES += image/qimage_ssse3.cpp diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index cb834c0..ac148ee 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -3769,6 +3769,14 @@ void qInitImageConversions() converter_map[QImage::Format_RGB888][QImage::Format_ARGB32_Premultiplied] = convert_RGB888_to_RGB32_ssse3; } #endif +#ifdef QT_HAVE_NEON + if (features & NEON) { + extern void convert_RGB888_to_RGB32_neon(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags); + converter_map[QImage::Format_RGB888][QImage::Format_RGB32] = convert_RGB888_to_RGB32_neon; + converter_map[QImage::Format_RGB888][QImage::Format_ARGB32] = convert_RGB888_to_RGB32_neon; + converter_map[QImage::Format_RGB888][QImage::Format_ARGB32_Premultiplied] = convert_RGB888_to_RGB32_neon; + } +#endif } /*! diff --git a/src/gui/image/qimage_neon.cpp b/src/gui/image/qimage_neon.cpp new file mode 100644 index 0000000..15bf472 --- /dev/null +++ b/src/gui/image/qimage_neon.cpp @@ -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 QtGui module 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$ +** +****************************************************************************/ + +#include +#include +#include + +#ifdef QT_HAVE_NEON + +QT_BEGIN_NAMESPACE + +Q_GUI_EXPORT void QT_FASTCALL qt_convert_rgb888_to_rgb32_neon(quint32 *dst, const uchar *src, int len) +{ + if (!len) + return; + + const quint32 *const end = dst + len; + + // align dst on 64 bits + const int offsetToAlignOn8Bytes = (reinterpret_cast(dst) >> 2) & 0x1; + for (int i = 0; i < offsetToAlignOn8Bytes; ++i) { + *dst++ = qRgb(src[0], src[1], src[2]); + src += 3; + } + + if ((len - offsetToAlignOn8Bytes) >= 8) { + const quint32 *const simdEnd = end - 7; + register uint8x8_t fullVector asm ("d3") = vdup_n_u8(0xff); + do { +#if Q_BYTE_ORDER == Q_BIG_ENDIAN + asm volatile ( + "vld3.8 { d4, d5, d6 }, [%[SRC]] !\n\t" + "vst4.8 { d3, d4, d5, d6 }, [%[DST],:64] !\n\t" + : [DST]"+r" (dst), [SRC]"+r" (src) + : "w"(fullVector) + : "memory", "d4", "d5", "d6" + ); +#else + asm volatile ( + "vld3.8 { d0, d1, d2 }, [%[SRC]] !\n\t" + "vswp d0, d2\n\t" + "vst4.8 { d0, d1, d2, d3 }, [%[DST],:64] !\n\t" + : [DST]"+r" (dst), [SRC]"+r" (src) + : "w"(fullVector) + : "memory", "d0", "d1", "d2" + ); +#endif + } while (dst < simdEnd); + } + + while (dst != end) { + *dst++ = qRgb(src[0], src[1], src[2]); + src += 3; + } +} + +void convert_RGB888_to_RGB32_neon(QImageData *dest, const QImageData *src, Qt::ImageConversionFlags) +{ + Q_ASSERT(src->format == QImage::Format_RGB888); + Q_ASSERT(dest->format == QImage::Format_RGB32 || dest->format == QImage::Format_ARGB32 || dest->format == QImage::Format_ARGB32_Premultiplied); + Q_ASSERT(src->width == dest->width); + Q_ASSERT(src->height == dest->height); + + const uchar *src_data = (uchar *) src->data; + quint32 *dest_data = (quint32 *) dest->data; + + for (int i = 0; i < src->height; ++i) { + qt_convert_rgb888_to_rgb32_neon(dest_data, src_data, src->width); + src_data += src->bytes_per_line; + dest_data = (quint32 *)((uchar*)dest_data + dest->bytes_per_line); + } +} + +QT_END_NAMESPACE + +#endif // QT_HAVE_NEON -- cgit v0.12 From 296cf92e1047409a203294e81fb388cc6a0e5c85 Mon Sep 17 00:00:00 2001 From: Benjamin Poulain Date: Fri, 6 Aug 2010 15:50:38 +0200 Subject: Use the fast Neon conversion for converting colors of jpeg images. Reviewed-by: Andreas Kling --- src/gui/image/qjpeghandler.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/gui/image/qjpeghandler.cpp b/src/gui/image/qjpeghandler.cpp index d358a5e..eda5efb 100644 --- a/src/gui/image/qjpeghandler.cpp +++ b/src/gui/image/qjpeghandler.cpp @@ -803,9 +803,16 @@ bool QJpegHandlerPrivate::read(QImage *image) QJpegHandler::QJpegHandler() : d(new QJpegHandlerPrivate(this)) { -#if defined(QT_HAVE_SSSE3) const uint features = qDetectCPUFeatures(); - + Q_UNUSED(features); +#if defined(QT_HAVE_NEON) + // from qimage_neon.cpp + Q_GUI_EXPORT void QT_FASTCALL qt_convert_rgb888_to_rgb32_neon(quint32 *dst, const uchar *src, int len); + + if (features & NEON) + rgb888ToRgb32ConverterPtr = qt_convert_rgb888_to_rgb32_neon; +#endif // QT_HAVE_NEON +#if defined(QT_HAVE_SSSE3) // from qimage_ssse3.cpp Q_GUI_EXPORT void QT_FASTCALL qt_convert_rgb888_to_rgb32_ssse3(quint32 *dst, const uchar *src, int len); -- cgit v0.12 From c45516f1f3781dcb504158f730b98897c7f2f2a1 Mon Sep 17 00:00:00 2001 From: Benjamin Poulain Date: Fri, 6 Aug 2010 15:52:37 +0200 Subject: Remove the definition of QT_HAVE_NEON from qt.prf Since we cannot use NEON and VFP concurrently, it is better not to force neon all over the place :) Reviewed-by: Andreas Kling Reviewed-by: Thiago Macieira --- mkspecs/features/qt.prf | 1 - src/corelib/corelib.pro | 5 ++++- src/gui/gui.pro | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/mkspecs/features/qt.prf b/mkspecs/features/qt.prf index aa0f06e..84010a0 100644 --- a/mkspecs/features/qt.prf +++ b/mkspecs/features/qt.prf @@ -211,7 +211,6 @@ mac { } #SIMD defines: -neon: DEFINES += QT_HAVE_NEON mmx:DEFINES += QT_HAVE_MMX 3dnow:DEFINES += QT_HAVE_3DNOW sse:DEFINES += QT_HAVE_SSE QT_HAVE_MMXEXT diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro index bc8ef9f..728bdf9 100644 --- a/src/corelib/corelib.pro +++ b/src/corelib/corelib.pro @@ -53,6 +53,9 @@ symbian: { DEPLOYMENT = partial_upgrade $$DEPLOYMENT } -neon: QMAKE_CXXFLAGS *= -mfpu=neon +neon { + DEFINES += QT_HAVE_NEON + QMAKE_CXXFLAGS *= -mfpu=neon +} diff --git a/src/gui/gui.pro b/src/gui/gui.pro index 89ae06f..3943e26 100644 --- a/src/gui/gui.pro +++ b/src/gui/gui.pro @@ -77,8 +77,9 @@ symbian { DEPLOYMENT = partial_upgrade $$DEPLOYMENT } -neon: QMAKE_CXXFLAGS *= -mfpu=neon neon:*-g++* { + DEFINES += QT_HAVE_NEON + QMAKE_CXXFLAGS *= -mfpu=neon HEADERS += $$NEON_HEADERS SOURCES += $$NEON_SOURCES -- cgit v0.12 From c5fa9eb1cb02d979502e2c9918d752c6708fb406 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 9 Aug 2010 10:31:16 +0200 Subject: Fix scrollbar randomly popping up in QPlainTextEdit When a line break was detected, we would retain the value of the right bearing for the character after the break instead of resetting it to the right bearing of the previous value. This could in some cases cause the bounding rect of the text to be wrong, and could cause unnecessary horizontal scrollbars to pop up. It was especially visible when using WrapAnywhere. Visible e.g. in the compile output in Creator. Done-by: mae Reviewed-by: Eskil Reviewed-by: Lars --- src/gui/text/qtextlayout.cpp | 21 +++++++++++++++++---- tests/auto/qtextlayout/tst_qtextlayout.cpp | 30 ++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 4 deletions(-) diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp index 5a11c87..da43913 100644 --- a/src/gui/text/qtextlayout.cpp +++ b/src/gui/text/qtextlayout.cpp @@ -1709,14 +1709,18 @@ namespace { return glyphs.glyphs[logClusters[currentPosition - 1]]; } + inline void adjustRightBearing(glyph_t glyph) + { + qreal rb; + fontEngine->getGlyphBearings(glyph, 0, &rb); + rightBearing = qMin(QFixed(), QFixed::fromReal(rb)); + } + inline void adjustRightBearing() { if (currentPosition <= 0) return; - - qreal rb; - fontEngine->getGlyphBearings(currentGlyph(), 0, &rb); - rightBearing = qMin(QFixed(), QFixed::fromReal(rb)); + adjustRightBearing(currentGlyph()); } inline void resetRightBearing() @@ -1901,6 +1905,9 @@ void QTextLine::layout_helper(int maxGlyphs) } else { lbh.whiteSpaceOrObject = false; bool sb_or_ws = false; + glyph_t previousGlyph = 0; + if (lbh.currentPosition > 0 && lbh.logClusters[lbh.currentPosition - 1] line.width) lbh.adjustRightBearing(); if (lbh.checkFullOtherwiseExtend(line)) { + // we are too wide, fix right bearing + if (rightBearing <= 0) + lbh.rightBearing = rightBearing; // take from cache + else if (previousGlyph > 0) + lbh.adjustRightBearing(previousGlyph); if (!breakany) { line.textWidth += lbh.softHyphenWidth; } diff --git a/tests/auto/qtextlayout/tst_qtextlayout.cpp b/tests/auto/qtextlayout/tst_qtextlayout.cpp index f798faf..659ba1a 100644 --- a/tests/auto/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/qtextlayout/tst_qtextlayout.cpp @@ -122,6 +122,7 @@ private slots: void smallTextLengthWrapAtWordBoundaryOrAnywhere(); void testLineBreakingAllSpaces(); void lineWidthFromBOM(); + void textWidthVsWIdth(); private: @@ -1359,5 +1360,34 @@ void tst_QTextLayout::glyphLessItems() } } +void tst_QTextLayout::textWidthVsWIdth() +{ + QTextLayout layout; + QTextOption opt; + opt.setWrapMode(QTextOption::WrapAnywhere); + layout.setTextOption(opt); + layout.setText(QString::fromLatin1( + "g++ -c -m64 -pipe -g -fvisibility=hidden -fvisibility-inlines-hidden -Wall -W -D_REENTRANT -fPIC -DCORE_LIBRARY -DIDE_LIBRARY_BASENAME=\"lib\" -DWITH_TESTS " + "-DQT_NO_CAST_TO_ASCII -DQT_USE_FAST_OPERATOR_PLUS -DQT_USE_FAST_CONCATENATION -DQT_PLUGIN -DQT_TESTLIB_LIB -DQT_SCRIPT_LIB -DQT_SVG_LIB -DQT_SQL_LIB -DQT_XM" + "L_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I../../../../qt-qml/mkspecs/linux-g++-64 -I. -I../../../../qt-qml/include/QtCore -I../../../." + "./qt-qml/include/QtNetwork -I../../../../qt-qml/include/QtGui -I../../../../qt-qml/include/QtXml -I../../../../qt-qml/include/QtSql -I../../../../qt-qml/inc" + "lude/QtSvg -I../../../../qt-qml/include/QtScript -I../../../../qt-qml/include/QtTest -I../../../../qt-qml/include -I../../../../qt-qml/include/QtHelp -I../." + "./libs -I/home/ettrich/dev/creator/tools -I../../plugins -I../../shared/scriptwrapper -I../../libs/3rdparty/botan/build -Idialogs -Iactionmanager -Ieditorma" + "nager -Iprogressmanager -Iscriptmanager -I.moc/debug-shared -I.uic -o .obj/debug-shared/sidebar.o sidebar.cpp")); + + // textWidth includes right bearing, but it should never be LARGER than width if there is space for at least one character + for (int width = 100; width < 1000; ++width) { + layout.beginLayout(); + QTextLine line = layout.createLine(); + line.setLineWidth(width); + layout.endLayout(); + + qreal textWidthIsLargerBy = qMax(qreal(0), line.naturalTextWidth() - line.width()); + qreal thisMustBeZero = 0; + QCOMPARE(textWidthIsLargerBy, thisMustBeZero); + } +} + + QTEST_MAIN(tst_QTextLayout) #include "tst_qtextlayout.moc" -- cgit v0.12 From 4f2f48caae2ae18336bff10bb1e1ab07f2dd4650 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Mon, 9 Aug 2010 11:49:43 +0200 Subject: doc: Clarify documentation of QStaticText There has been some confusion concerning what HTML tags can be used when using the rich text format with QStaticText. This patch attempts to make it clearer in the documentation that the tags have to be text related. Reviewed-by: Samuel --- src/gui/text/qstatictext.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/gui/text/qstatictext.cpp b/src/gui/text/qstatictext.cpp index 7396bcd..21c2e02 100644 --- a/src/gui/text/qstatictext.cpp +++ b/src/gui/text/qstatictext.cpp @@ -109,10 +109,18 @@ QT_BEGIN_NAMESPACE QPainter::drawStaticText() and can change from call to call with a minimal impact on performance. - QStaticText will attempt to guess the format of the input text using Qt::mightBeRichText(). - To force QStaticText to display its contents as either plain text or rich text, use the - function QStaticText::setTextFormat() and pass in, respectively, Qt::PlainText and - Qt::RichText. + For extra convenience, it is possible to apply formatting to the text using the HTML subset + supported by QTextDocument. QStaticText will attempt to guess the format of the input text using + Qt::mightBeRichText(), and interpret it as rich text if this function returns true. To force + QStaticText to display its contents as either plain text or rich text, use the function + QStaticText::setTextFormat() and pass in, respectively, Qt::PlainText and Qt::RichText. + + QStaticText can only represent text, so only HTML tags which alter the layout or appearance of + the text will be respected. Adding an image to the input HTML, for instance, will cause the + image to be included as part of the layout, affecting the positions of the text glyphs, but it + will not be displayed. The result will be an empty area the size of the image in the output. + Similarly, using tables will cause the text to be laid out in table format, but the borders + will not be drawn. If it's the first time the static text is drawn, or if the static text, or the painter's font has been altered since the last time it was drawn, the text's layout has to be -- cgit v0.12 From ddd2a54224e651ff45af834201eec1be2c56d583 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 9 Aug 2010 11:58:40 +0200 Subject: QtDeclarative: get rid of warnings in public header warning: use of old-style cast Reviewed-by: brad --- src/declarative/qml/qdeclarativelist.h | 8 ++++---- src/declarative/qml/qdeclarativeprivate.h | 4 ++-- tests/auto/compilerwarnings/test_cpp.txt | 3 +++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/declarative/qml/qdeclarativelist.h b/src/declarative/qml/qdeclarativelist.h index 399b2a1..c10bc11 100644 --- a/src/declarative/qml/qdeclarativelist.h +++ b/src/declarative/qml/qdeclarativelist.h @@ -98,16 +98,16 @@ public: private: static void qlist_append(QDeclarativeListProperty *p, T *v) { - ((QList *)p->data)->append(v); + reinterpret_cast *>(p->data)->append(v); } static int qlist_count(QDeclarativeListProperty *p) { - return ((QList *)p->data)->count(); + return reinterpret_cast *>(p->data)->count(); } static T *qlist_at(QDeclarativeListProperty *p, int idx) { - return ((QList *)p->data)->at(idx); + return reinterpret_cast *>(p->data)->at(idx); } static void qlist_clear(QDeclarativeListProperty *p) { - return ((QList *)p->data)->clear(); + return reinterpret_cast *>(p->data)->clear(); } }; #endif diff --git a/src/declarative/qml/qdeclarativeprivate.h b/src/declarative/qml/qdeclarativeprivate.h index cb916bf..d45ddbc 100644 --- a/src/declarative/qml/qdeclarativeprivate.h +++ b/src/declarative/qml/qdeclarativeprivate.h @@ -105,7 +105,7 @@ namespace QDeclarativePrivate template struct StaticCastSelectorClass { - static inline int cast() { return (int)((intptr_t)static_cast((From *)0x10000000)) - 0x10000000; } + static inline int cast() { return int(reinterpret_cast(static_cast(reinterpret_cast(0x10000000)))) - 0x10000000; } }; template @@ -119,7 +119,7 @@ namespace QDeclarativePrivate static inline int cast() { - return StaticCastSelectorClass::cast(); + return StaticCastSelectorClass(0)))>::cast(); } }; diff --git a/tests/auto/compilerwarnings/test_cpp.txt b/tests/auto/compilerwarnings/test_cpp.txt index 62b35eb..1d317b8 100644 --- a/tests/auto/compilerwarnings/test_cpp.txt +++ b/tests/auto/compilerwarnings/test_cpp.txt @@ -58,6 +58,9 @@ #include #endif +#include + + #ifndef Q_OS_MAC int main(int, char **) { -- cgit v0.12 From 720f4ca0ec3b42a101ac24b2cf74cdc87d29eac9 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 9 Aug 2010 14:11:46 +0200 Subject: Fix QString::arg: When specifying %L1, the group separator would be added even if the local specify QLocale::OmitGroupSeparator Task-number: QTBUG-9281 Reviewed-by: Denis --- src/corelib/tools/qstring.cpp | 13 ++++++++----- tests/auto/qstring/tst_qstring.cpp | 12 ++++++++++++ 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index d6ab5da..2fd9a0b 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -6645,8 +6645,9 @@ QString QString::arg(qlonglong a, int fieldWidth, int base, const QChar &fillCha QString locale_arg; if (d.locale_occurrences > 0) { QLocale locale; - locale_arg = locale.d()->longLongToString(a, -1, base, fieldWidth, - flags | QLocalePrivate::ThousandsGroup); + if (!locale.numberOptions() & QLocale::OmitGroupSeparator) + flags |= QLocalePrivate::ThousandsGroup; + locale_arg = locale.d()->longLongToString(a, -1, base, fieldWidth, flags); } return replaceArgEscapes(*this, d, fieldWidth, arg, locale_arg, fillChar); @@ -6688,8 +6689,9 @@ QString QString::arg(qulonglong a, int fieldWidth, int base, const QChar &fillCh QString locale_arg; if (d.locale_occurrences > 0) { QLocale locale; - locale_arg = locale.d()->unsLongLongToString(a, -1, base, fieldWidth, - flags | QLocalePrivate::ThousandsGroup); + if (!locale.numberOptions() & QLocale::OmitGroupSeparator) + flags |= QLocalePrivate::ThousandsGroup; + locale_arg = locale.d()->unsLongLongToString(a, -1, base, fieldWidth, flags); } return replaceArgEscapes(*this, d, fieldWidth, arg, locale_arg, fillChar); @@ -6822,7 +6824,8 @@ QString QString::arg(double a, int fieldWidth, char fmt, int prec, const QChar & if (d.locale_occurrences > 0) { QLocale locale; - flags |= QLocalePrivate::ThousandsGroup; + if (!locale.numberOptions() & QLocale::OmitGroupSeparator) + flags |= QLocalePrivate::ThousandsGroup; locale_arg = locale.d()->doubleToString(a, prec, form, fieldWidth, flags); } diff --git a/tests/auto/qstring/tst_qstring.cpp b/tests/auto/qstring/tst_qstring.cpp index c887936..ef82769 100644 --- a/tests/auto/qstring/tst_qstring.cpp +++ b/tests/auto/qstring/tst_qstring.cpp @@ -208,6 +208,7 @@ private slots: void repeated_data() const; void task262677remove(); void QTBUG10404_compareRef(); + void QTBUG9281_arg_locale(); }; typedef QList IntList; @@ -4860,6 +4861,17 @@ void tst_QString::QTBUG10404_compareRef() QVERIFY(QStringRef(&a2, 1, 2).compare(QStringRef(&a, 1, 3), Qt::CaseInsensitive) < 0); } +void tst_QString::QTBUG9281_arg_locale() +{ + QLocale l(QLocale::English, QLocale::UnitedKingdom); + l.setNumberOptions(QLocale::OmitGroupSeparator); + QLocale::setDefault(l); + QString str("*%L1*%L2*"); + str = str.arg(123456).arg(1234.56); + QCOMPARE(str, QString::fromLatin1("*123456*1234.56*")); + QLocale::setDefault(QLocale::C); +} + QTEST_APPLESS_MAIN(tst_QString) -- cgit v0.12 From f33359fb0c56fe88e0ae3c564b7847f90889eac2 Mon Sep 17 00:00:00 2001 From: David Boddie Date: Mon, 9 Aug 2010 20:50:45 +0200 Subject: Doc: Fixes to Qt Quick documentation. Reviewed-by: Trust Me To-be-verified-by: Qt Doc Team --- doc/src/declarative/declarativeui.qdoc | 99 +- doc/src/declarative/dynamicobjects.qdoc | 2 +- doc/src/declarative/elements.qdoc | 6 +- doc/src/declarative/qml-intro.qdoc | 414 +--- doc/src/declarative/qtprogrammers.qdoc | 3 +- doc/src/external-resources.qdoc | 15 + doc/src/getting-started/demos.qdoc | 18 +- doc/src/getting-started/gettingstartedqml.qdoc | 2044 ++++++++++---------- doc/src/getting-started/gettingstartedqt.qdoc | 6 +- doc/src/qt4-intro.qdoc | 8 +- .../ui-components/dialcontrol/content/Dial.qml | 2 + .../ui-components/dialcontrol/dialcontrol.qml | 4 +- src/declarative/qml/qdeclarativecomponent.cpp | 2 +- src/declarative/qml/qdeclarativeengine.cpp | 6 +- 14 files changed, 1159 insertions(+), 1470 deletions(-) diff --git a/doc/src/declarative/declarativeui.qdoc b/doc/src/declarative/declarativeui.qdoc index 42189c0..ed8b734 100644 --- a/doc/src/declarative/declarativeui.qdoc +++ b/doc/src/declarative/declarativeui.qdoc @@ -33,7 +33,7 @@ dynamic, custom user interfaces. Qt Quick provides a declarative framework for building highly dynamic, -custom user interfaces from a rich set of \l {QML Elements}{QML elements}. +custom user interfaces from a rich set of \l{QML Elements}{QML elements}. Qt Quick helps programmers and designers collaborate to build the fluid user interfaces that are becoming common in portable consumer devices, such as mobile phones, media players, set-top boxes @@ -41,73 +41,74 @@ and netbooks. Qt Quick consists of the QtDeclarative C++ module, QML, and the integration of both of these into the Qt Creator IDE. Using the QtDeclarative C++ module, you can load and interact with QML files from your Qt application. -QML is an extension to \l -{http://www.ecma-international.org/publications/standards/Ecma-262.htm} -{JavaScript}, that provides a mechanism to declaratively build an -object tree of \l {QML Elements}{QML elements}. 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. +QML is an extension to \l{About JavaScript}{JavaScript}, that provides +a mechanism to declaratively build an object tree of +\l{QML Elements}{QML elements}. 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 \l {QML Elements}{QML elements} are a sophisticated set of +The \l{QML Elements}{QML elements} are a sophisticated set of graphical and behavioral building blocks. These different elements -are combined together in \l {QML Documents}{QML documents} to build +are combined together in \l{QML Documents}{QML documents} to build components ranging in complexity from simple buttons and sliders, to -complete internet-enabled applications like a \l -{http://www.flickr.com}{Flickr} photo browser. +complete Internet-enabled applications like a photo browser for the +popular \l{http://www.flickr.com}{Flickr} photo-sharing site. -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 QtDeclarative Module. +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 QtDeclarative +Module. \section1 Getting Started \list -\o \l {Introduction to the QML language} -\o \l {QML Tutorial}{Tutorial: 'Hello World'} -\o \l {QML Advanced Tutorial}{Tutorial: 'Same Game'} -\o \l {QML Examples and Demos} -\o \l {QML for Qt programmers} +\o \l{Introduction to the QML language} +\o \l{QML Tutorial}{Tutorial: 'Hello World'} +\o \l{QML Advanced Tutorial}{Tutorial: 'Same Game'} +\o \l{QML Examples and Demos} +\o \l{QML for Qt Programmers} +\o \l{Getting Started Programming with QML} +\o \l{Beginning Qt Quick} \endlist \section1 Core QML Features \list -\o \l {QML Documents} -\o \l {Property Binding} -\o \l {Network Transparency} -\o \l {QML Scope} -\o \l {Integrating JavaScript} -\o \l {Data Models} -\o \l {anchor-layout.html}{Anchor-based Layout} -\o \l {qdeclarativestates.html}{States} -\o \l {qdeclarativeanimation.html}{Animation} -\o \l {qdeclarativefocus.html}{Keyboard Focus} -\o \l {qdeclarativemodules.html}{Modules} -\o \l {Extending types from QML} -\o \l {qdeclarativedynamicobjects.html}{Dynamic Object Creation} -\o \l {qmlruntime.html}{The Qt Declarative Runtime} +\o \l{QML Documents} +\o \l{Property Binding} +\o \l{Network Transparency} +\o \l{QML Scope} +\o \l{Integrating JavaScript} +\o \l{Data Models} +\o \l{Anchor-based Layout in QML} +\o \l{QML States} +\o \l{QML Animation} +\o \l{Keyboard Focus in QML} +\o \l{QML Modules} +\o \l{Extending types from QML} +\o \l{Dynamic Object Management in QML} +\o \l{Qt Declarative UI Runtime} \endlist \section1 Using QML with C++ \list -\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++} +\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 Global Object} -\o \l {QML Internationalization} -\o \l {QML Security} -\o \l {QtDeclarative Module} -\o \l {Debugging QML} -\o \l {QML Viewer} -\o \l {QML Performance} -\o \l {QML Coding Conventions} +\o \l{QML Elements} +\o \l{QML Global Object} +\o \l{QML Internationalization} +\o \l{QML Security} +\o \l{QtDeclarative Module} +\o \l{Debugging QML} +\o \l{QML Viewer} +\o \l{QML Performance} +\o \l{QML Coding Conventions} \endlist */ diff --git a/doc/src/declarative/dynamicobjects.qdoc b/doc/src/declarative/dynamicobjects.qdoc index 997f601..e735bce 100644 --- a/doc/src/declarative/dynamicobjects.qdoc +++ b/doc/src/declarative/dynamicobjects.qdoc @@ -27,7 +27,7 @@ /*! \page qdeclarativedynamicobjects.html -\title Dynamic Object Management +\title Dynamic Object Management in QML 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 diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc index c2930b3..55b71e1 100644 --- a/doc/src/declarative/elements.qdoc +++ b/doc/src/declarative/elements.qdoc @@ -26,11 +26,11 @@ ****************************************************************************/ /*! -\page qdeclarativeelements.html +\page qmlelements.html \target elements \title QML Elements -The following table lists the QML elements provided by the \l {QtDeclarative}{Qt Declarative} module. +The following table lists the QML elements provided by the \l{QtDeclarative} module. \table \header \o {2,1} \bold {Basic Visual Items} @@ -54,7 +54,7 @@ The following table lists the QML elements provided by the \l {QtDeclarative}{Qt \row \o \l {Flickable} \o Provides a surface that can be "flicked" \row \o \l {Flipable} \o Provides a surface that produces flipping effects \row \o \l {GestureArea} (experimental) \o Enables simple gesture handling - + \header \o {2,1} \bold {States} \row \o \l {State} \o Defines sets of configurations of objects and properties \row \o \l {PropertyChanges} \o Describes property changes within a state diff --git a/doc/src/declarative/qml-intro.qdoc b/doc/src/declarative/qml-intro.qdoc index fbab001..69dd500 100644 --- a/doc/src/declarative/qml-intro.qdoc +++ b/doc/src/declarative/qml-intro.qdoc @@ -28,14 +28,11 @@ /*! - -\page qml-intro.html +\page qml-intro.html \title Beginning 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 @@ -61,12 +58,7 @@ would be a property. The basic syntax of an \l {QML Elements}{element} is - \code - SomeElement { - id: myObject - ... some other things here ... - } - \endcode +\snippet doc/src/snippets/declarative/qml-intro/basic-syntax.qml basic syntax 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 @@ -90,61 +82,38 @@ want a rectangle that is 500 pixels by 400 pixels in the x and y directions We can implement this \l Rectangle with these properties this way - \code - import Qt 4.7 - - // This is a comment. And below myRectangle is defined. - Rectangle { - id: myRectangle - width: 500 - height: 400 - } - \endcode +\quotefile doc/src/snippets/declarative/qml-intro/rectangle.qml 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 command +myexample.qml, and on the command line run the following command: - \code - qmlviewer myexample.qml - \endcode +\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 - +\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 +\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}{text} -property to "Hello World!". So to set the text to 'Hello world' and the +\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, - \code - import Qt 4.7 - - Rectangle { - id: myRectangle - width: 500 - height: 400 - - Text { text: "Hello World!" } - - color: "lightgray" - } - \endcode +\quotefile doc/src/snippets/declarative/qml-intro/hello-world1.qml \section1 Hello World Again @@ -158,12 +127,7 @@ 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 - \code - Text { - text: "

      Hello World

      "; color: "darkgreen" - x: 100; y:100 - } - \endcode +\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 @@ -174,13 +138,7 @@ 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, - \code - Text { - text: "

      Hello world again

      " - color: "#002288" - x: 100; y: 100 - } - \endcode +\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. @@ -198,11 +156,7 @@ 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"}. - \code - Image { - source: "images/qt-logo.png" - } - \endcode +\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 @@ -213,44 +167,12 @@ 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, - \code - Image { - source: "images/qt-logo.png" - x: 100; y: 150 - width: 150; height: 150 - } - \endcode +\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. - \code - import Qt 4.7 - - Rectangle { - id: myRectangle - width: 500 - height: 400 - - // A light gray background - color: "lightgray" - - // Position and color some text - Text { - text: "

      Hello world again

      " - color: "darkgreen" - x: 100; y: 100 - } - - // Using the opportunity to resize the image. - Image { - source: "images/qt-logo.png" - x: 100; y: 150 - width: 150; height: 150 - } - - } - \endcode +\quotefile doc/src/snippets/declarative/qml-intro/hello-world5.qml The result is still quite simple @@ -281,22 +203,7 @@ 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 - \code - import Qt 4.7 - - Rectangle { - id: myWin - width: 500 - height: 400 - - Image { - id: image1 - source: "images/qt-logo.png" - width: 150; height: 150 - anchors.bottom: myWin.bottom - } - } - \endcode +\quotefile doc/src/snippets/declarative/qml-intro/anchors1.qml This places the logo at the bottom left of the window. @@ -315,25 +222,7 @@ the bottomMargin property is used. So the new actions for the script are Encoded into QML the script becomes - \code - import Qt 4.7 - - Rectangle { - id: myWin - width: 500 - height: 400 - - Image { - id: image1 - source: "images/qt-logo.png" - width: 150; height: 150 - anchors.bottom: myWin.bottom - anchors.horizontalCenter: myWin.horizontalCenter - anchors.bottomMargin: 10 - } - } - \endcode - +\quotefile doc/src/snippets/declarative/qml-intro/anchors2.qml Run this and resize the window. You will see that now the position of the image adjusts during the resize. @@ -344,14 +233,7 @@ 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 - \code - Text { - text: "

      The Qt Logo

      " - anchors.bottom: image1.top - anchors.horizontalCenter: myWin.horizontalCenter - anchors.bottomMargin: 15 - } - \endcode +\snippet doc/src/snippets/declarative/qml-intro/anchors3.qml adding some text \image qml-intro-anchors3.png @@ -359,17 +241,15 @@ above the image referencing these properties from another object we use the property directly, instead of saying: - \code - myRectangle.anchors.top // Wrong - \endcode +\qml +myRectangle.anchors.top // Wrong +\endqml we use - \code - myRectangle.top // Correct - \endcode - - +\qml +myRectangle.top // Correct +\endqml \section1 Transformations @@ -391,9 +271,9 @@ 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 - \code - myList: [ listElement1, listElement2, ... } ] - \endcode +\qml +myList: [ listElement1, listElement2, ... } ] +\endqml we can produce a list of transformations. @@ -402,46 +282,7 @@ vertically by a factor of 1.5 and by 1.2 horizontally. Using the example above as the basis for this we have, - \code - import Qt 4.7 - - Rectangle { - id: myWin - width: 500 - height: 400 - - Image { - id: image1 - source: "images/qt-logo.png" - 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 - } - - } - - Text { - text: "

      The Qt Logo -- taking it easy

      " - anchors.bottom: image1.top - anchors.horizontalCenter: myWin.horizontalCenter - anchors.bottomMargin: 15 - - transform: [ - Scale { xScale: 1.5; yScale: 1.2 } , - - Rotation { - origin.x: 75; origin.y: 75 - axis{ x: 0; y: 0; z:1 } angle: -45 - } - ] - } - } - \endcode +\quotefile doc/src/snippets/declarative/qml-intro/transformations1.qml The code block in \c image1 starting with \c transform specifies that the \l {Item::transform}{transform} property will be a Rotation through -90 @@ -479,30 +320,7 @@ 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. - \code - import Qt 4.7 - - Rectangle { - id: mainRec - width: 600 - height: 400 - - Image { - id: image1 - source: "images/qt-logo.png" - x: 200; y: 100 - width: 100; height: 100 - - // Animate a rotation - transformOrigin: Item.Center - NumberAnimation on rotation { - from: 0; to: 360 - duration: 2000 - loops: Animation.Infinite - } - } - } - \endcode +\quotefile doc/src/snippets/declarative/number-animation1.qml 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 @@ -515,32 +333,7 @@ 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. - \code - import Qt 4.7 - - Rectangle { - id: mainRec - width: 600 - height: 400 - - Image { - id: image1 - source: "images/qt-logo.png" - 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 - } - } - } - } - \endcode +\quotefile doc/src/snippets/declarative/number-animation2.qml 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 @@ -569,31 +362,7 @@ will be animating the position and the size of the image. First create two images - \code - import Qt 4.7 - - Rectangle { - id: mainRec - width: 600 - height: 400 - z: 0 - - Image { - id: image1 - source: "images/qt-logo.png" - x: 20; y: 20 ; z: 1 - width: 100; height: 100 - } - - Image { - id: image2 - source: "images/qt-logo.png" - width: 100; height: 100 - x: (mainRec.width - 100)/2; y: (mainRec.height - 100)/2 - z: 2 - } - } - \endcode +\quotefile doc/src/snippets/declarative/sequential-animation1.qml 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 @@ -606,14 +375,7 @@ 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. - \code - SequentialAnimation on x { - loops: Animation.Infinite - NumberAnimation { from: 20; to: 450; easing.type: "InOutQuad"; -duration: 2000 } - PauseAnimation { duration: 500 } - } - \endcode +\snippet doc/src/snippets/declarative/sequential-animation2.qml adding a sequential animation A similar block of code is written for the animation of the 'y' value of the position. @@ -628,54 +390,7 @@ 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 - \code - Rectangle { - id: mainRec - width: 600 - height: 400 - z: 0 - - Image { - id: image2 - source: "images/qt-logo.png" - width: 100; height: 100 - x: (mainRec.width - 100)/2; y: (mainRec.height - 100)/2 - z: 2 - } - - Image { - id: image1 - source: "images/qt-logo.png" - x: 20; y: 20 ; z: 1 - width: 100; height: 100 - - SequentialAnimation on x { - loops: Animation.Infinite - NumberAnimation { - from: 20; to: 450 - easing.type: "InOutQuad"; duration: 2000 - } - PauseAnimation { duration: 500 } - } - - SequentialAnimation on y { - loops: Animation.Infinite - NumberAnimation { - from: 20; to: 250 - easing.type: "InOutQuad"; duration: 2000 - } - PauseAnimation { duration: 500 } - } - - 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 } - } - } - } - \endcode +\quotefile doc/src/snippets/declarative/sequential-animation3.qml 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 @@ -756,60 +471,7 @@ 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 - \code - import Qt 4.7 - - Rectangle { - id: mainRectangle - width: 600 - height: 400 - color: "black" - - Rectangle { - id: sky - width: 600 - height: 200 - y: 0 - color: "lightblue" - } - - Rectangle { - id: ground - width: 600; height: 200 - y: 200 - color: "green" - } - - MouseArea { - id: mousearea - anchors.fill: mainRectangle - } - - 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" } - } - ] - - transitions: [ Transition { - from: "daylight"; to: "night" - ColorAnimation { duration: 1000 } - }, - Transition { - from: "night"; to: "daylight" - ColorAnimation { duration: 500 } - } - ] - } - \endcode +\quotefile doc/src/snippets/declarative/states1.qml 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 diff --git a/doc/src/declarative/qtprogrammers.qdoc b/doc/src/declarative/qtprogrammers.qdoc index 68d56bf..c0639db 100644 --- a/doc/src/declarative/qtprogrammers.qdoc +++ b/doc/src/declarative/qtprogrammers.qdoc @@ -26,10 +26,9 @@ ****************************************************************************/ /*! - \page qtprogrammers.html \target qtprogrammers -\title QML for Qt programmers +\title QML for Qt Programmers \section1 Overview diff --git a/doc/src/external-resources.qdoc b/doc/src/external-resources.qdoc index e901124c..61620f5 100644 --- a/doc/src/external-resources.qdoc +++ b/doc/src/external-resources.qdoc @@ -428,3 +428,18 @@ \externalpage http://developer.symbian.org/wiki/index.php/Deploying_a_Qt_Application \title Deploying a Qt Application article */ + +/*! + \externalpage http://www.ecma-international.org/publications/standards/Ecma-262.htm + \title ECMAScript Language Specification +*/ + +/*! + \externalpage https://developer.mozilla.org/en/JavaScript + \title JavaScript +*/ + +/*! + \externalpage https://developer.mozilla.org/en/JavaScript/About_JavaScript + \title About JavaScript +*/ diff --git a/doc/src/getting-started/demos.qdoc b/doc/src/getting-started/demos.qdoc index ef16224..719c861 100644 --- a/doc/src/getting-started/demos.qdoc +++ b/doc/src/getting-started/demos.qdoc @@ -46,7 +46,7 @@ \o \inlineimage qtdemo-small.png \o If you run the \l{Examples and Demos Launcher}, you'll see many of Qt's widgets in action. - + The \l{Qt Widget Gallery} also provides overviews of selected Qt widgets in each of the styles used on various supported platforms. \endtable @@ -134,15 +134,23 @@ \section1 QtWebKit \list - \o \l{Web Browser} demonstrates how Qt's \l{QtWebKit Module}{WebKit module} - can be used to implement a small Web browser. + \o \l{Web Browser} demonstrates how Qt's \l{QtWebKit} module can be used to + implement a small Web browser. + \endlist + + \section1 Multimedia + + \list + \o \l{demos/spectrum}{Spectrum Analyser} shows how the \l{QtMultimedia} + module can be used to manipulate audio as it is played. \endlist \section1 Phonon \list - \o \l{demos/qmediaplayer}{Media Player} demonstrates how the \l{Phonon Module} can be - used to implement a basic media player application. + \o \l{demos/qmediaplayer}{Media Player} demonstrates how the + \l{Phonon Module}{Phonon module} can be used to implement a basic media player + application. \endlist \note The Phonon demos are currently not available for the MinGW platform. diff --git a/doc/src/getting-started/gettingstartedqml.qdoc b/doc/src/getting-started/gettingstartedqml.qdoc index 2bfb71c..885e6ce 100644 --- a/doc/src/getting-started/gettingstartedqml.qdoc +++ b/doc/src/getting-started/gettingstartedqml.qdoc @@ -26,1025 +26,1025 @@ ****************************************************************************/ /*! - \page qml-textEditor.html - - \title Getting Started programming with QML - \ingroup gettingStarted - - Welcome to the world of QML - the declarative UI language. In this Getting - Started guide, we will create a simple text editor application using QML. - After reading this guide, you should be ready to develop your own applications - using QML and Qt C++. - - \section1 QML to Build User Interfaces - - The application we are building is a simple text editor that will load, save, - and perform some text manipulation. This guide will consist of two parts. The - first part will involve designing the application layout and behaviors using - declarative language in QML. For the second part, file loading and saving will - be implemented using Qt C++. Using - \l {The Meta-Object System}{Qt's Meta-Object System}, we can expose C++ functions - as properties that QML elements can use. Utilizing QML and Qt C++, we can - efficiently decouple the interface logic from the application logic. - - \image qml-texteditor5_editmenu.png - - To run the QML example code, merely provide the included \l{QML Viewer}{qmlviewer} - tool with the QML file as the argument. The C++ portion of this tutorial assumes - that the reader possesses basic knowledge of Qt's compilation procedures. - - Tutorial chapters: - \list 1 - \o \l {Defining a Button and a Menu}{Defining a Button and a Menu} - \o \l {Implementing a Menu Bar}{Implementing a Menu Bar} - \o \l {Building a Text Editor}{Building a Text Editor} - \o \l {Decorating the Text Editor}{Decorating the Text Editor} - \o \l {Extending QML using Qt C++}{Extending QML using Qt C++} - \endlist - - \section1 Defining a Button and a Menu - - \section2 Basic Component - a Button - - We start our text editor by building a button. Functionally, a button has a mouse - sensitive area and a label. Buttons perform actions when a user presses the button. - - In QML, the basic visual item is the \l {Rectangle}{Rectangle} element. The - \c Rectangle element has properties to control the element's appearance and location. - - \code - import Qt 4.7 - Rectangle { - id: simplebutton - color: "grey" - width: 150; height: 75 - - Text{ - id: buttonLabel - anchors.centerIn: parent - text: "button label" - } - } - \endcode - - First, the \c { import Qt 4.7 } allows the qmlviewer tool to import the QML elements - we will later use. This line must exist for every QML file. Notice that the version - of Qt modules is included in the import statement. - - This simple rectangle has a unique identifier, \c simplebutton, which is bound to the - id property. The \c Rectangle element's properties are bound to values by listing the - property, followed by a colon, then the value. In the code sample, the color \c grey - is bound to the the Rectangle's \c color property. Similarly, we bind the \c width - and \c height of the Rectangle. - - The \l {Text}{Text} element is a non-editable text field. We name this \c Text element - \c buttonLabel. To set the string content of the Text field, we bind a value to the - \c text property. The label is contained within the Rectangle and in order to center - it in the middle, we assign the \c anchors of the Text element to its parent, which - is called \c simplebutton. Anchors may bind to other items' anchors, allowing layout - assignments simpler. - - We shall save this code as \c SimpleButton.qml. Running qmlviewer with the file as the - argument will display the grey rectangle with a text label. - - \image qml-texteditor1_simplebutton.png - - To implement the button click functionality, we can use QML's event handling. QML's event - handling is very similar to \l {Signals & Slots}{Qt's signal and slot} mechanism. Signals - are emitted and the connected slot is called. - - \code - Rectangle{ - id:simplebutton - ... - - MouseArea{ - id: buttonMouseArea - - anchors.fill: parent //anchor all sides of the mouse area to the rectangle's anchors - //onClicked handles valid mouse button clicks - onClicked: console.log(buttonLabel.text + " clicked" ) - } - } - \endcode - - We include a \l{MouseArea} element in our simplebutton. \c MouseArea elements describe - the interactive area where mouse movements are detected. For our button, we anchor the - whole MouseArea to its parent, which is \c simplebutton. The \c anchors.fill syntax is - one way of accessing a specific property called \c fill inside a group of properties - called \c anchors. QML uses \l {Anchor-based Layout in QML}{anchor based layouts} where - items can anchor to another item, creating robust layouts. - - The \c MouseArea has many signal handlers that are called during mouse movements within - the specfied \c MouseArea boundaries. One of them is \c onClicked and it is called - whenever the acceptable mouse button is clicked, the left click being the default. We - can bind actions to the onClicked handler. In our example, \c console.log() outputs text - whenever the mouse area is clicked. The function \c console.log() is a useful tool for - debugging purposes and for outputting text. - - The code in \c SimpleButton.qml is sufficient to display a button on the screen and - output text whenever it is clicked with a mouse. - - \code - Rectangle { - id:Button - ... - - property color buttonColor: "lightblue" - property color onHoverColor: "gold" - property color borderColor: "white" - - signal buttonClick() - onButtonClick: { - console.log(buttonLabel.text + " clicked" ) - } - - MouseArea{ - onClicked: buttonClick() - hoverEnabled: true - onEntered: parent.border.color = onHoverColor - onExited: parent.border.color = borderColor - } - - //determines the color of the button by using the conditional operator - color: buttonMouseArea.pressed ? Qt.darker(buttonColor, 1.5) : buttonColor - } - \endcode - - A fully functioning button is in \c Button.qml. The code snippets in this article - have some code omitted, denoted by ellipses because they were either introduced - earlier in the previous sections or irrelevant to the current code discussion. - - Custom properties are declared using the \c {property type name} syntax. In the - code, the property \c buttonColor, of type \c color, is declared and bound to - the value \c{"lightblue"}. The \c buttonColor is later used in a conditional - operation to determine the buttons's fill color. Note that property value - assignment is possible using the \c= equals sign, in addition to value binding - using the \c : colon character. Custom properties allow internal items to be - accessible outside of the Rectangle's scope. There are basic - \l{QML Basic Types}{QML types} such as \c int, \c string, \c real, as well as - a type called \c variant. - - By binding the \c onEntered and \c onExited signal handlers to colors, the - button's border will turn yellow when the mouse hovers above the button and - reverts the color when the mouse exits the mouse area. - - A \c buttonClick() signal is declared in \c Button.qml by placing the \c signal - keyword in front of the signal name. All signals have their handlers automatically - created, their names starting with \c on. As a result, the \c onButtonClick is - \c buttonClick's handler. The \c onButtonClick is then assigned an action to - perform. In our button example, the \c onClicked mouse handler will simply call - \c onButtonClick, which displays a text. The \c onButtonClick enables outside - objects to access the \c {Button}'s mouse area easily. For example, items may - have more than one \c MouseArea declarations and a \c buttonClick signal can - make the distinction between the several \c MouseArea signal handlers better. - - We now have the basic knowledge to implement items in QML that can handle - basic mouse movements. We created a \c Text label inside a \c Rectangle, - customized its properties, and implemented behaviors that respond to mouse - movements. This idea of creating elements within elements is repeated - throughout the text editor application. - - This button is not useful unless used as a component to perform an action. - In the next section, we will soon create a menu containing several of these - buttons. - - \image qml-texteditor1_button.png - - \section2 Creating a Menu Page - - Up to this stage, we covered how to create elements and assign behaviors inside - a single QML file. In this section, we will cover how to import QML elements and how - to reuse some of the created components to build other components. - - Menus display the contents of a list, each item having the ability to perform an action. - In QML, we can create a menu in several ways. First, we will create a menu containing - buttons which will eventually perform different actions. The menu code is in - \c FileMenu.qml. - - \code - import Qt 4.7 \\import the main Qt QML module - import folderName \\import the contents of the folder - import Button.qml \\import a QML file - import NewButton.qml as ButtonModule \\import a QML file and give it a name - import script.js as Script \\import a Javascript file and name it as Script - \endcode - - To use the \c Button element in \c FileMenu.qml, we need to import \c Button.qml. - The syntax shown above, shows how to use the \c import keyword. However, the - \c {import Button.qml} is not necessary; qmlviewer will import all the contents - of the current directory. We can directly create a \c Button element by declaring - \c Button{}, similar to a \c Rectangle{} declaration. - - \code - In FileMenu.qml: - - Row{ - anchors.centerIn: parent - spacing: parent.width/6 - - Button{ - id: loadButton - buttonColor: "lightgrey" - label: "Load" - } - Button{ - buttonColor: "grey" - id: saveButton - label: "Save" - } - Button{ - id: exitButton - label: "Exit" - buttonColor: "darkgrey" - - onButtonClick: Qt.quit() - } - } - \endcode - - In \c FileMenu.qml, we declare three \c Button elements. They are declared - inside a \l {Row}{Row} element, a positioner that will position its children - along a vertical row. The \c Button declaration resides in Button.qml, - which is the same as the \c Button.qml we used in the previous section. - New property bindings can be declared within the newly created buttons, - effectively overwriting the properties set in \c Button.qml. The button - called \c exitButton will quit and close the window when it is clicked. - Note that the signal handler \c onButtonClick in \c Button.qml will be - called in addition to the \c onButtonClick handler in \c exitButton. - - \image qml-texteditor1_filemenu.png - - The \c Row declaration is declared in a \c Rectangle, creating a rectangle - container for the row of buttons. This additional rectangle creates an indirect - way of organizing the row of buttons inside a menu. - - The declaration of the edit menu is very similar at this stage. The menu has - buttons that have the labels: \c Copy, \c Paste, and \c {Select All}. - - \image qml-texteditor1_editmenu.png - - Armed with our knowledge of importing and customizing previously made - components, we may now combine these menu pages to create a menu bar, - consisting of buttons to select the menu, and look at how we may structure - data using QML. - - \section1 Implementing a Menu Bar - - Our text editor application will need a way to display menus using a menu bar. - The menu bar will switch the different menus and the user can choose which menu - to display. Menu switching implies that the menus need more structure than - merely displaying them in a row. QML uses models and views to structure data - and display the structured data. - - \section2 Using Data Models and Views - - QML has different \l {Data Models}{data views} that display - \l {Data Models}{data models}. Our menu bar will display the menus in a list, - with a header that displays a row of menu names. The list of menus are declared - inside a \c VisualItemModel. The \l{VisualItemModel}{\c VisualItemModel} - element contains items that already have views such as \c Rectangle elements - and imported UI elements. Other model types such as the \l{ListModel}{\c ListModel} - element need a delegate to display their data. - - We declare two visual items in the \c menuListModel, the \c FileMenu and the - \c EditMenu. We customize the two menus and display them using a - \l {ListView}{ListView}. The \c MenuBar.qml file contains the QML declarations - and a simple edit menu is defined in \c EditMenu.qml. - - \code - VisualItemModel{ - id: menuListModel - FileMenu{ - width: menuListView.width - height: menuBar.height - color: fileColor - } - EditMenu{ - color: editColor - width: menuListView.width - height: menuBar.height - } - } - \endcode - - The \l {ListView}{ListView} element will display a model according to a delegate. - The delegate may declare the model items to display in a \c Row element or display - the items in a grid. Our \c menuListModel already has visible items, therefore, - we do not need to declare a delegate. - - \code - ListView{ - id: menuListView - - //Anchors are set to react to window anchors - anchors.fill:parent - anchors.bottom: parent.bottom - width:parent.width - height: parent.height - - //the model contains the data - model: menuListModel - - //control the movement of the menu switching - snapMode: ListView.SnapOneItem - orientation: ListView.Horizontal - boundsBehavior: Flickable.StopAtBounds - flickDeceleration: 5000 - highlightFollowsCurrentItem: true - highlightMoveDuration:240 - highlightRangeMode: ListView.StrictlyEnforceRange - } - \endcode - - Additionally, \c ListView inherits from \l{Flickable}{\c Flickable}, making - the list respond to mouse drags and other gestures. The last portion of the - code above sets \c Flickable properties to create the desired flicking movement - to our view. In particular,the property \c highlightMoveDuration changes the - duration of the flick transition. A higher \c highlightMoveDuration value - results in slower menu switching. - - The \c ListView maintains the model items through an \c index and each visual - item in the model is accessible through the \c index, in the order of the - declaration. Changing the \c currentIndex effectively changes the highlighted - item in the \c ListView. The header of our menu bar exemplify this effect. - There are two buttons in a row, both changing the current menu when clicked. - The \c fileButton changes the current menu to the file menu when clicked, - the \c index being \c 0 because \c FileMenu is declared first in the - \c menuListModel. Similarly, the \c editButton will change the current - menu to the \c EditMenu when clicked. - - The \c labelList rectangle has \c z value of \c 1, denoting that it is displayed - at the front of the menu bar. Items with higher \c z values are displayed in front - of items with lower \c z values. The default \c z value is \c 0. - - \code - Rectangle{ - id: labelList - ... - z: 1 - Row{ - anchors.centerIn: parent - spacing:40 - Button{ - label: "File" - id: fileButton - ... - onButtonClick: menuListView.currentIndex = 0 - } - Button{ - id: editButton - label: "Edit" - ... - onButtonClick: menuListView.currentIndex = 1 - } - } - } - \endcode - - The menu bar we just created can be flicked to access the menus or by clicking - on the menu names at the top. Switching menu screens feel intuitive and responsive. - - \image qml-texteditor2_menubar.png - - */ - - /*! - \page qml-textEditor3.html - \title Building a Text Editor - - \section1 Declaring a TextArea - - Our text editor is not a text editor if it didn't contain an editable text area. - QML's \l {TextEdit}{TextEdit} element allows the declaration of a multi-line - editable text area. \l {TextEdit}{TextEdit} is different from a \l {Text}{Text} - element, which doesn't allow the user to directly edit the text. - - \code - TextEdit{ - id: textEditor - anchors.fill:parent - width:parent.width; height:parent.height - color:"midnightblue" - focus: true - - wrapMode: TextEdit.Wrap - - onCursorRectangleChanged: flickArea.ensureVisible(cursorRectangle) - } - \endcode - - The editor has its font color property set and set to wrap the text. The - \c TextEdit area is inside a flickable area that will scroll the text if the - text cursor is outside the visible area. The function \c ensureVisible() will - check if the cursor rectangle is outside the visible boundaries and move the - text area accordingly. QML uses Javascript syntax for its scripts, and as previously - mentioned, Javascript files can be imported and used within a QML file. - - \code - function ensureVisible(r){ - if (contentX >= r.x) - contentX = r.x; - else if (contentX+width <= r.x+r.width) - contentX = r.x+r.width-width; - if (contentY >= r.y) - contentY = r.y; - else if (contentY+height <= r.y+r.height) - contentY = r.y+r.height-height; - } - \endcode - - \section1 Combining Components for the Text Editor - - We are now ready to create the layout of our text editor using QML. The text - editor has two components, the menu bar we created and the text area. QML allows - us to reuse components, therefore making our code simpler, by importing components - and customizing when necessary. Our text editor splits the window into two; - one-third of the screen is dedicated to the menu bar and two-thirds of the screen - displays the text area. The menu bar is displayed in front of any other elements. - - \code - Rectangle{ - - id: screen - width: 1000; height: 1000 - - //the screen is partitioned into the MenuBar and TextArea. 1/3 of the screen is assigned to the MenuBar - property int partition: height/3 - - MenuBar{ - id:menuBar - height: partition - width:parent.width - z: 1 - } - - TextArea{ - id:textArea - anchors.bottom:parent.bottom - y: partition - color: "white" - height: partition*2 - width:parent.width - } - } - \endcode - - By importing reusable components, our \c TextEditor code looks much simpler. - We can then customize the main application, without worrying about properties - that already have defined behaviors. Using this approach, application layouts - and UI components can be created easily. - - \image qml-texteditor3_texteditor.png - - */ - - /*! - \page qml-textEditor4 - \title Decorating the Text Editor - \section1 Implementing a Drawer Interface - - Our text editor looks simple and we need to decorate it. Using QML, we can declare - transitions and animate our text editor. Our menu bar is occupying one-third of the - screen and it would be nice to have it only appear when we want it. - - We can add a drawer interface, that will contract or expand the menu bar when clicked. - In our implementation, we have a thin rectangle that responds to mouse clicks. The - \c drawer, as well as the application, has two sates: the "drawer is open" state and - the "drawer is closed" state. The \c drawer item is a strip of rectangle with a small - height. There is a nested \l {Image}{Image} element declaring that an arrow icon will - be centered inside the drawer. The drawer assigns a state to the whole application, - with the identifier \c screen, whenever a user clicks the mouse area. - - \code - Rectangle{ - id:drawer - height:15 - - Image{ - id: arrowIcon - source: "images/arrow.png" - anchors.horizontalCenter: parent.horizontalCenter - } - - MouseArea{ - id: drawerMouseArea - anchors.fill:parent - onClicked:{ - if (screen.state == "DRAWER_CLOSED"){ - screen.state = "DRAWER_OPEN" - } - else if (screen.state == "DRAWER_OPEN"){ - screen.state = "DRAWER_CLOSED" - } - } - ... - } - } - \endcode - - A state is simply a collection of configurations and it is declared in a - \l{State}{State} element. A list of states can be listed and bound to the - \c states property. In our application, the two states are called - \c DRAWER_CLOSED and \c DRAWER_OPEN. Item configurations are declared in - \l {PropertyChanges}{PropertyChanges} elements. In the \c DRAWER_OPEN state, - there are four items that will receive property changes. The first target, - \c menuBar, will change its \c y property to \c 0. Similarly, the \c textArea - will lower to a new position when the state is \c DRAWER_OPEN. The \c textArea, - the \c drawer, and the drawer's icon will undergo property changes to meet the - current state. - - \code - - states:[ - State{ - name: "DRAWER_OPEN" - PropertyChanges { target: menuBar; y:0} - PropertyChanges { target: textArea; y: partition + drawer.height} - PropertyChanges { target: drawer; y: partition} - PropertyChanges { target: arrowIcon; rotation: 180} - }, - State{ - name: "DRAWER_CLOSED" - PropertyChanges { target: menuBar; y:-partition} - PropertyChanges { target: textArea; y: drawer.height; height: screen.height - drawer.height} - PropertyChanges { target: drawer; y: 0} - PropertyChanges { target: arrowIcon; rotation: 0} - } - - ] - - \endcode - - State changes are abrupt and needs smoother transitions. Transitions between states - are defined using the \l {Transition}{Transition} element, which can then bind to - the item's \c transitions property. Our text editor has a state transition whenever - the state changes to either \c DRAWER_OPEN or \c DRAWER_CLOSED. Importantly, the - transition needs a \c from and a \c to state but for our transitions, we can use - the wild card \c * symbol to denote that the transition applies to all state changes. - - During transitions, we can assign animations to the property changes. Our - \c menuBar switches position from \c {y:0} to \c {y:-partition} and we can animate - this transition using the \l {NumberAnimation}{NumberAnimation} element. We declare - that the targets' properties will animate for a certain duration of time and using - a certain easing curve. An easing curve controls the animation rates and - interpolation behavior during state transitions. The easing curve we chose is - \l{PropertyAnimation::easing.type}{Easing.OutQuint}, which slows the movement near - the end of the animation. Pleae read \l {qdeclarativeanimation.html}{QML's Animation} - article. - - \code - transitions: [ - Transition{ - to: "*" - NumberAnimation { target: textArea; properties: "y, height"; duration: 100; easing.type: Easing.OutQuint } - NumberAnimation { target: menuBar; properties: "y"; duration: 100;easing.type: Easing.OutQuint } - NumberAnimation { target: drawer; properties: "y"; duration: 100;easing.type: Easing.OutQuint } - } - ] - \endcode - - Another way of animating property changes is by declaring a \l {Behavior}{Behavior} - element. A transition only works during state changes and \c Behavior can set an - animation for a general property change. In the text editor, the arrow has a - \c NumberAnimation animating its \c rotation property whenever the property changes. - - \code - In TextEditor.qml: - - Behavior{ - NumberAnimation{property: "rotation";easing.type: Easing.OutExpo } - } - \endcode - - Going back to our components with knowledge of states and animations, we can improve - the appearances of the components. In \c Button.qml, we can add \c color and \c scale - property changes when the button is clicked. Color types are animated using - \l {ColorAnimation}{ColorAnimation} and numbers are animated using - \l {NumberAnimation}{NumberAnimation}. The \c {on propertyName} syntax displayed below - is helpful when targeting a single property. - - \code - In Button.qml: - ... - - color: buttonMouseArea.pressed ? Qt.darker(buttonColor, 1.5) : buttonColor - Behavior on color { ColorAnimation{ duration: 55} } - - scale: buttonMouseArea.pressed ? 1.1 : 1.00 - Behavior on scale { NumberAnimation{ duration: 55} } - \endcode - - Additionally, we can enhance the appearances of our QML components by adding color - effects such as gradients and opacity effects. Declaring a \l {Gradient}{Gradient} - element will override the \c color property of the element. You may declare a color - in the gradient using the \l {GradientStop}{GradientStop} element. The gradient is - positioned using a scale, between \c 0.0 and \c 1.0. - - \code - In MenuBar.qml - gradient: Gradient { - GradientStop { position: 0.0; color: "#8C8F8C" } - GradientStop { position: 0.17; color: "#6A6D6A" } - GradientStop { position: 0.98;color: "#3F3F3F" } - GradientStop { position: 1.0; color: "#0e1B20" } - } - \endcode - - This gradient is used by the menu bar to display a gradient simulating depth. - The first color starts at \c 0.0 and the last color is at \c 1.0. - - - \section2 Where to Go from Here - - We are finished building the user interface of a very simple text editor. - Going forward, the user interface is complete, and we can implement the - application logic using regular Qt and C++. QML works nicely as a prototyping - tool, separating the application logic away from the UI design. - - \image qml-texteditor4_texteditor.png - - \section1 Extending QML using Qt C++ - - 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 - 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. - This way, we only need to load the QML file directly instead of running an executable. - - \section2 Exposing C++ Classes to QML - - We will be implementing file loading and saving using Qt and C++. C++ classes - and functions can be used in QML by registering them. The class also needs to be - compiled as a Qt plugin and the QML file will need to know where the plugin is located. - - For our application, we need to create the following items: - \list 1 - \o \c Directory class that will handle directory related operations - \o \c File class which is a QObject, simulating the list of files in a directory - \o plugin class that will register the class to the QML context - \o Qt project file that will compile the plugin - \o A \c qmldir file telling the qmlviewer tool where to find the plugin - \endlist - - \section2 Building a Qt Plugin - - To build a plugin, we need to set the following in a Qt project file. First, - the necessary sources, headers, and Qt modules need to be added into our - project file. All the C++ code and project files are in the \c filedialog - directory. - - \code - In cppPlugins.pro: - - TEMPLATE = lib - CONFIG += qt plugin - QT += declarative - - DESTDIR += ../plugins - OBJECTS_DIR = tmp - MOC_DIR = tmp - - TARGET = FileDialog - - HEADERS += directory.h \ - file.h \ - dialogPlugin.h - - SOURCES += directory.cpp \ - file.cpp \ - dialogPlugin.cpp - \endcode - - In particular, we compile Qt with the \c declarative module and configure it as a - \c plugin, needing a \c lib template. We shall put the compiled plugin into the - parent's \c plugins directory. - - - \section2 Registering a Class into QML - - \code - In dialogPlugin.h: - - #include - - class DialogPlugin : public QDeclarativeExtensionPlugin - { - Q_OBJECT - - public: - void registerTypes(const char *uri); - - }; - - \endcode - Our plugin class, \c DialogPlugin is a subclass of \l {QDeclarativeExtensionPlugin}{QDeclarativeExtensionPlugin}. We need to implement the inherited function, \l {QDeclarativeExtensionPlugin::registerTypes}{registerTypes}. The \c dialogPlugin.cpp file looks like this: - - \code - DialogPlugin.cpp: - - #include "dialogPlugin.h" - #include "directory.h" - #include "file.h" - #include - - void DialogPlugin::registerTypes(const char *uri){ - - qmlRegisterType(uri, 1, 0, "Directory"); - qmlRegisterType(uri, 1, 0,"File"); - } - - Q_EXPORT_PLUGIN2(FileDialog, DialogPlugin); - \endcode - - The \l {QDeclarativeExtensionPlugin::registerTypes}{registerTypes} - function registers our File and Directory classes into QML. This function - needs the class name for its template, a major version number, a minor version - number, and a name for our classes. - - We need to export the plugin using the \l {Q_EXPORT_PLUGIN2}{Q_EXPORT_PLUGIN2} - macro. Note that in our \c dialogPlugin.h file, we have the \l {Q_OBJECT}{Q_OBJECT} - macro at the top of our class. As well, we need to run \c qmake on the project - file to generate the necessary meta-object code. - - - \section2 Creating QML Properties in a C++ class - - We can create QML elements and properties using C++ and - \l {The Meta-Object System}{Qt's Meta-Object System}. We can implement - properties using slots and signals, making Qt aware of these properties. - These properties can then be used in QML. - - For the text editor, we need to be able to load and save files. Typically, - these features are contained in a file dialog. Fortunately, we can use - \l {QDir}{QDir}, \l {QFile}{QFile}, and \l {QTextStream}{QTextStream} to - implement directory reading and input/output streams. - - \code - class Directory : public QObject{ - - Q_OBJECT - - Q_PROPERTY(int filesCount READ filesCount CONSTANT) - Q_PROPERTY(QString filename READ filename WRITE setFilename NOTIFY filenameChanged) - Q_PROPERTY(QString fileContent READ fileContent WRITE setFileContent NOTIFY fileContentChanged) - Q_PROPERTY(QDeclarativeListProperty files READ files CONSTANT ) - - ... - \endcode - - The \c Directory class uses Qt's Meta-Object System to register properties it - needs to accomplish file handling. The \c Directory class is exported as a plugin - and is useable in QML as the \c Directory element. Each of the listed properties - using the \l {Q_PROPERTY()}{Q_PROPERTY} macro is a QML property. - - The \l {Q_PROPERTY()} {Q_PROPERTY} declares a property as well as its read and - write functions into Qt's Meta-Object System. For example, the \c filename - property, of type \l {QString}{QString}, is readable using the \c filename() - function and writable using the function \c setFilename(). Additionally, there - is a signal associated to the filename property called \c filenameChanged(), - which is emitted whenever the property changes. The read and write functions - are declared as \c public in the header file. - - Similarly, we have the other properties declared according to their uses. The - \c filesCount property indicates the number of files in a directory. The filename - property is set to the currently selected file's name and the loaded/saved file - content is stored in \c fileContent property. - - \code - Q_PROPERTY(QDeclarativeListProperty files READ files CONSTANT ) - \endcode - - The \c files list property is a list of all the filtered files in a directory. - The \c Directory class is implemented to filter out invalid text files; only - files with a \c .txt extension are valid. Further, \l {QLists}{QLists} can be - used in QML files by declaring them as a \c QDeclarativeListProperty in C++. - The templated object needs to inherit from a \l {QObject}{QObject}, therefore, - the \c File class must also inherit from \c QObject. In the \c Directory class, - the list of \c File objects is stored in a \c QList called \c m_fileList. - - \code - class File : public QObject{ - - Q_OBJECT - Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) - - ... - }; - \endcode - - The properties can then be used in QML as part of the \c Directory element's - properties. Note that we do not have to create an identifier \c id property - in our C++ code. - - \code - Directory{ - id: directory - - filesCount - filename - fileContent - files - - files[0].name - } - - \endcode - - Because QML uses Javascript's syntax and structure, we can iterate through - the list of files and retrieve its properties. To retrieve the first file's - name property, we can call \c { files[0].name }. - - Regular C++ functions are also accessible from QML. The file loading and saving - functions are implemented in C++ and declared using the - \l {Q_INVOKABLE}{Q_INVOKABLE} macro. Alternatively, we can declare the functions - as a \c slot and the functions will be accessible from QML. - - \code - In Directory.h: - - Q_INVOKABLE void saveFile(); - Q_INVOKABLE void loadFile(); - \endcode - - The \c Directory class also has to notify other objects whenever the directory - contents change. This feature is performed using a \c signal. As previously - mentioned, QML signals have a corresponding handler with their names prepended - with \c on. The signal is called \c directoryChanged and it is emitted whenever - there is a directory refresh. The refresh simply reloads the directory contents - and updates the list of valid files in the directory. QML items can then be - notified by attaching an action to the \c onDirectoryChanged signal handler. - - The \c list properties need to be explored further. This is because list - properties use callbacks to access and modify the list contents. The list - property is of type \c QDeclarativeListProperty. Whenever the list - is accessed, the accessor function needs to return a - \c QDeclarativeListProperty. The template type, \c File, needs to be a - \c QObject derivative. Further, to create the - \l {QDeclarativeListProperty}{QDeclarativeListProperty}, the list's accessor - and modifiers need to be passed to the consructor as function pointers. The list, - a \c QList in our case, also needs to be a list of \c File pointers. - - The constructor of \l {QDeclarativeListProperty}{QDeclarativeListProperty} - constructor and the \c Directory implementation: - \code - QDeclarativeListProperty ( QObject * object, void * data, AppendFunction append, CountFunction count = 0, AtFunction at = 0, ClearFunction clear = 0 ) - QDeclarativeListProperty( this, &m_fileList, &appendFiles, &filesSize, &fileAt, &clearFilesPtr ); - \endcode - - The constructor passes pointers to functions that will append the list, count - the list, retrieve the item using an index, and empty the list. Only the append - function is mandatory. Note that the function pointers must match the definition - of \l {QDeclarativeListProperty::AppendFunction}{AppendFunction}, - \l {QDeclarativeListProperty::CountFunction}{CountFunction}, - \l {QDeclarativeListProperty::AtFunction}{AtFunction}, or - \l {QDeclarativeListProperty::ClearFunction}{ClearFunction}. - - \code - void appendFiles(QDeclarativeListProperty * property, File * file) - File* fileAt(QDeclarativeListProperty * property, int index) - int filesSize(QDeclarativeListProperty * property) - void clearFilesPtr(QDeclarativeListProperty *property) - \endcode - - To simplify our file dialog, the \c Directory class filters out invalid text - files, which are files that do not have a \c .txt extension. If a file name - doesn't have the \c .txt extension, then it won't be seen in our file dialog. - Also, the implementation makes sure that saved files have a \c .txt extension in - the file name. \c Directory uses \l {QTextStream}{QTextStream} to read the file - and to output the file contents to a file. - - With our \c Directory element, we can retrieve the files as a list, know how many - text files is in the application directory, get the file's name and content as a - string, and be notified whenever there are changes in the directory contents. - - To build the plugin, run \c qmake on the \c cppPlugins.pro project file, then run - \c make to build and transfer the plugin to the \c plugins directory. - - - \section2 Importing a Plugin in QML - - The qmlviewer tool imports files that are in the same directory as the - application. We can also create a \c qmldir file containing the locations of - QML files we wish to import. The \c qmldir file can also store locations of - plugins and other resources. - - \code - In qmldir: - - Button ./Button.qml - FileDialog ./FileDialog.qml - TextArea ./TextArea.qml - TextEditor ./TextEditor.qml - EditMenu ./EditMenu.qml - - plugin FileDialog plugins - \endcode - - The plugin we just created is called \c FileDialog, as indicated by the - \c TARGET field in the project file. The compiled plugin is in the \c plugins directory. - - - \section2 Integrating a File Dialog into the File Menu - - Our \c FileMenu needs to display the \c FileDialog element, containing a list of - the text files in a directory thus allowing the user to select the file by - clicking on the list. We also need to assign the save, load, and new buttons - to their respective actions. The FileMenu contains an editable text input to - allow the user to type a file name using the keyboard. - - The \c Directory element is used in the \c FileMenu.qml file and it notifies the - \c FileDialog element that the directory refreshed its contents. This notification - is performed in the signal handler, \c onDirectoryChanged. - - \code - In FileMenu.qml: - - Directory{ - id:directory - filename: textInput.text - onDirectoryChanged: fileDialog.notifyRefresh() - } - \endcode - - Keeping with the simplicity of our application, the file dialog will always be - visible and will not display invalid text files, which do not have a \c .txt - extension to their filenames. - - \code - In FileDialog.qml: - - signal notifyRefresh() - onNotifyRefresh: dirView.model = directory.files - \endcode - - The \c FileDialog element will display the contents of a directory by reading its - list property called \c files. The files are used as the model of a - \l {GridView}{GridView} element, which displays data items in a grid according - to a delegate. The delegate handles the appearance of the model and our file - dialog will simply create a grid with text centered in the middle. Clicking on - the file name will result in the appearance of a rectangle to highlight the file - name. The \c FileDialog is notified whenever the \c notifyRefresh signal is emitted, - reloading the files in the directory. - - \code - In FileMenu.qml: - - Button{ - id: newButton - label: "New" - onButtonClick:{ - textArea.textContent = "" - } - } - Button{ - id: loadButton - label: "Load" - onButtonClick:{ - directory.filename = textInput.text - directory.loadFile() - textArea.textContent = directory.fileContent - } - } - Button{ - id: saveButton - label: "Save" - onButtonClick:{ - directory.fileContent = textArea.textContent - directory.filename = textInput.text - directory.saveFile() - } - } - Button{ - id: exitButton - label: "Exit" - onButtonClick:{ - Qt.quit() - } - } - \endcode - - Our \c FileMenu can now connect to their respective actions. The \c saveButton - will transfer the text from the \c TextEdit onto the directory's \c fileContent - property, then copy its file name from the editable text input. Finally, the button - calls the \c saveFile() function, saving the file. The \c sloadButton has a similar - execution. Also, the \c New action will empty the contents of the \c TextEdit. - - Further, the \c EditMenu buttons are connected to the \c TextEdit functions to copy, - paste, and select all the text in the text editor. - - \image qml-texteditor5_filemenu.png - - \section1 Text Editor Completion - - \image qml-texteditor5_newfile.png - - The application can function as a simple text editor, able to accept text - and save the text into a file. The text editor can also load from a file and - perform text manipulation. - - -*/ \ No newline at end of file + \page gettingstartedqml.html + \title Getting Started Programming with QML + \ingroup gettingStarted + + Welcome to the world of QML, the declarative UI language. In this Getting + Started guide, we will create a simple text editor application using QML. + After reading this guide, you should be ready to develop your own applications + using QML and Qt C++. + + \section1 QML to Build User Interfaces + + The application we are building is a simple text editor that will load, save, + and perform some text manipulation. This guide will consist of two parts. The + first part will involve designing the application layout and behaviors using + declarative language in QML. For the second part, file loading and saving will + be implemented using Qt C++. Using + \l {The Meta-Object System}{Qt's Meta-Object System}, we can expose C++ functions + as properties that QML elements can use. Utilizing QML and Qt C++, we can + efficiently decouple the interface logic from the application logic. + + \image qml-texteditor5_editmenu.png + + To run the QML example code, merely provide the included \l{QML Viewer}{qmlviewer} + tool with the QML file as the argument. The C++ portion of this tutorial assumes + that the reader possesses basic knowledge of Qt's compilation procedures. + + Tutorial chapters: + \list 1 + \o \l {Defining a Button and a Menu}{Defining a Button and a Menu} + \o \l {Implementing a Menu Bar}{Implementing a Menu Bar} + \o \l {Building a Text Editor}{Building a Text Editor} + \o \l {Decorating the Text Editor}{Decorating the Text Editor} + \o \l {Extending QML using Qt C++}{Extending QML using Qt C++} + \endlist + + \section1 Defining a Button and a Menu + + \section2 Basic Component - a Button + + We start our text editor by building a button. Functionally, a button has a mouse + sensitive area and a label. Buttons perform actions when a user presses the button. + + In QML, the basic visual item is the \l {Rectangle}{Rectangle} element. The + \c Rectangle element has properties to control the element's appearance and location. + + \code + import Qt 4.7 + Rectangle { + id: simplebutton + color: "grey" + width: 150; height: 75 + + Text{ + id: buttonLabel + anchors.centerIn: parent + text: "button label" + } + } + \endcode + + First, the \c { import Qt 4.7 } allows the qmlviewer tool to import the QML elements + we will later use. This line must exist for every QML file. Notice that the version + of Qt modules is included in the import statement. + + This simple rectangle has a unique identifier, \c simplebutton, which is bound to the + id property. The \c Rectangle element's properties are bound to values by listing the + property, followed by a colon, then the value. In the code sample, the color \c grey + is bound to the the Rectangle's \c color property. Similarly, we bind the \c width + and \c height of the Rectangle. + + The \l {Text}{Text} element is a non-editable text field. We name this \c Text element + \c buttonLabel. To set the string content of the Text field, we bind a value to the + \c text property. The label is contained within the Rectangle and in order to center + it in the middle, we assign the \c anchors of the Text element to its parent, which + is called \c simplebutton. Anchors may bind to other items' anchors, allowing layout + assignments simpler. + + We shall save this code as \c SimpleButton.qml. Running qmlviewer with the file as the + argument will display the grey rectangle with a text label. + + \image qml-texteditor1_simplebutton.png + + To implement the button click functionality, we can use QML's event handling. QML's event + handling is very similar to \l {Signals & Slots}{Qt's signal and slot} mechanism. Signals + are emitted and the connected slot is called. + + \code + Rectangle{ + id:simplebutton + ... + + MouseArea{ + id: buttonMouseArea + + anchors.fill: parent //anchor all sides of the mouse area to the rectangle's anchors + //onClicked handles valid mouse button clicks + onClicked: console.log(buttonLabel.text + " clicked" ) + } + } + \endcode + + We include a \l{MouseArea} element in our simplebutton. \c MouseArea elements describe + the interactive area where mouse movements are detected. For our button, we anchor the + whole MouseArea to its parent, which is \c simplebutton. The \c anchors.fill syntax is + one way of accessing a specific property called \c fill inside a group of properties + called \c anchors. QML uses \l {Anchor-based Layout in QML}{anchor based layouts} where + items can anchor to another item, creating robust layouts. + + The \c MouseArea has many signal handlers that are called during mouse movements within + the specfied \c MouseArea boundaries. One of them is \c onClicked and it is called + whenever the acceptable mouse button is clicked, the left click being the default. We + can bind actions to the onClicked handler. In our example, \c console.log() outputs text + whenever the mouse area is clicked. The function \c console.log() is a useful tool for + debugging purposes and for outputting text. + + The code in \c SimpleButton.qml is sufficient to display a button on the screen and + output text whenever it is clicked with a mouse. + + \code + Rectangle { + id:Button + ... + + property color buttonColor: "lightblue" + property color onHoverColor: "gold" + property color borderColor: "white" + + signal buttonClick() + onButtonClick: { + console.log(buttonLabel.text + " clicked" ) + } + + MouseArea{ + onClicked: buttonClick() + hoverEnabled: true + onEntered: parent.border.color = onHoverColor + onExited: parent.border.color = borderColor + } + + //determines the color of the button by using the conditional operator + color: buttonMouseArea.pressed ? Qt.darker(buttonColor, 1.5) : buttonColor + } + \endcode + + A fully functioning button is in \c Button.qml. The code snippets in this article + have some code omitted, denoted by ellipses because they were either introduced + earlier in the previous sections or irrelevant to the current code discussion. + + Custom properties are declared using the \c {property type name} syntax. In the + code, the property \c buttonColor, of type \c color, is declared and bound to + the value \c{"lightblue"}. The \c buttonColor is later used in a conditional + operation to determine the buttons's fill color. Note that property value + assignment is possible using the \c= equals sign, in addition to value binding + using the \c : colon character. Custom properties allow internal items to be + accessible outside of the Rectangle's scope. There are basic + \l{QML Basic Types}{QML types} such as \c int, \c string, \c real, as well as + a type called \c variant. + + By binding the \c onEntered and \c onExited signal handlers to colors, the + button's border will turn yellow when the mouse hovers above the button and + reverts the color when the mouse exits the mouse area. + + A \c buttonClick() signal is declared in \c Button.qml by placing the \c signal + keyword in front of the signal name. All signals have their handlers automatically + created, their names starting with \c on. As a result, the \c onButtonClick is + \c buttonClick's handler. The \c onButtonClick is then assigned an action to + perform. In our button example, the \c onClicked mouse handler will simply call + \c onButtonClick, which displays a text. The \c onButtonClick enables outside + objects to access the \c {Button}'s mouse area easily. For example, items may + have more than one \c MouseArea declarations and a \c buttonClick signal can + make the distinction between the several \c MouseArea signal handlers better. + + We now have the basic knowledge to implement items in QML that can handle + basic mouse movements. We created a \c Text label inside a \c Rectangle, + customized its properties, and implemented behaviors that respond to mouse + movements. This idea of creating elements within elements is repeated + throughout the text editor application. + + This button is not useful unless used as a component to perform an action. + In the next section, we will soon create a menu containing several of these + buttons. + + \image qml-texteditor1_button.png + + \section2 Creating a Menu Page + + Up to this stage, we covered how to create elements and assign behaviors inside + a single QML file. In this section, we will cover how to import QML elements and how + to reuse some of the created components to build other components. + + Menus display the contents of a list, each item having the ability to perform an action. + In QML, we can create a menu in several ways. First, we will create a menu containing + buttons which will eventually perform different actions. The menu code is in + \c FileMenu.qml. + + \code + import Qt 4.7 \\import the main Qt QML module + import "folderName" \\import the contents of the folder + import "Button.qml" \\import a QML file + import "NewButton.qml" as ButtonModule \\import a QML file and give it a name + import "script.js" as Script \\import a Javascript file and name it as Script + \endcode + + To use the \c Button element in \c FileMenu.qml, we need to import \c Button.qml. + The syntax shown above, shows how to use the \c import keyword. However, the + \c {import Button.qml} is not necessary; qmlviewer will import all the contents + of the current directory. We can directly create a \c Button element by declaring + \c Button{}, similar to a \c Rectangle{} declaration. + + \code + In FileMenu.qml: + + Row{ + anchors.centerIn: parent + spacing: parent.width/6 + + Button{ + id: loadButton + buttonColor: "lightgrey" + label: "Load" + } + Button{ + buttonColor: "grey" + id: saveButton + label: "Save" + } + Button{ + id: exitButton + label: "Exit" + buttonColor: "darkgrey" + + onButtonClick: Qt.quit() + } + } + \endcode + + In \c FileMenu.qml, we declare three \c Button elements. They are declared + inside a \l {Row}{Row} element, a positioner that will position its children + along a vertical row. The \c Button declaration resides in Button.qml, + which is the same as the \c Button.qml we used in the previous section. + New property bindings can be declared within the newly created buttons, + effectively overwriting the properties set in \c Button.qml. The button + called \c exitButton will quit and close the window when it is clicked. + Note that the signal handler \c onButtonClick in \c Button.qml will be + called in addition to the \c onButtonClick handler in \c exitButton. + + \image qml-texteditor1_filemenu.png + + The \c Row declaration is declared in a \c Rectangle, creating a rectangle + container for the row of buttons. This additional rectangle creates an indirect + way of organizing the row of buttons inside a menu. + + The declaration of the edit menu is very similar at this stage. The menu has + buttons that have the labels: \c Copy, \c Paste, and \c {Select All}. + + \image qml-texteditor1_editmenu.png + + Armed with our knowledge of importing and customizing previously made + components, we may now combine these menu pages to create a menu bar, + consisting of buttons to select the menu, and look at how we may structure + data using QML. + + \section1 Implementing a Menu Bar + + Our text editor application will need a way to display menus using a menu bar. + The menu bar will switch the different menus and the user can choose which menu + to display. Menu switching implies that the menus need more structure than + merely displaying them in a row. QML uses models and views to structure data + and display the structured data. + + \section2 Using Data Models and Views + + QML has different \l {Data Models}{data views} that display + \l {Data Models}{data models}. Our menu bar will display the menus in a list, + with a header that displays a row of menu names. The list of menus are declared + inside a \c VisualItemModel. The \l{VisualItemModel}{\c VisualItemModel} + element contains items that already have views such as \c Rectangle elements + and imported UI elements. Other model types such as the \l{ListModel}{\c ListModel} + element need a delegate to display their data. + + We declare two visual items in the \c menuListModel, the \c FileMenu and the + \c EditMenu. We customize the two menus and display them using a + \l {ListView}{ListView}. The \c MenuBar.qml file contains the QML declarations + and a simple edit menu is defined in \c EditMenu.qml. + + \code + VisualItemModel{ + id: menuListModel + FileMenu{ + width: menuListView.width + height: menuBar.height + color: fileColor + } + EditMenu{ + color: editColor + width: menuListView.width + height: menuBar.height + } + } + \endcode + + The \l {ListView}{ListView} element will display a model according to a delegate. + The delegate may declare the model items to display in a \c Row element or display + the items in a grid. Our \c menuListModel already has visible items, therefore, + we do not need to declare a delegate. + + \code + ListView{ + id: menuListView + + //Anchors are set to react to window anchors + anchors.fill:parent + anchors.bottom: parent.bottom + width:parent.width + height: parent.height + + //the model contains the data + model: menuListModel + + //control the movement of the menu switching + snapMode: ListView.SnapOneItem + orientation: ListView.Horizontal + boundsBehavior: Flickable.StopAtBounds + flickDeceleration: 5000 + highlightFollowsCurrentItem: true + highlightMoveDuration:240 + highlightRangeMode: ListView.StrictlyEnforceRange + } + \endcode + + Additionally, \c ListView inherits from \l{Flickable}{\c Flickable}, making + the list respond to mouse drags and other gestures. The last portion of the + code above sets \c Flickable properties to create the desired flicking movement + to our view. In particular,the property \c highlightMoveDuration changes the + duration of the flick transition. A higher \c highlightMoveDuration value + results in slower menu switching. + + The \c ListView maintains the model items through an \c index and each visual + item in the model is accessible through the \c index, in the order of the + declaration. Changing the \c currentIndex effectively changes the highlighted + item in the \c ListView. The header of our menu bar exemplify this effect. + There are two buttons in a row, both changing the current menu when clicked. + The \c fileButton changes the current menu to the file menu when clicked, + the \c index being \c 0 because \c FileMenu is declared first in the + \c menuListModel. Similarly, the \c editButton will change the current + menu to the \c EditMenu when clicked. + + The \c labelList rectangle has \c z value of \c 1, denoting that it is displayed + at the front of the menu bar. Items with higher \c z values are displayed in front + of items with lower \c z values. The default \c z value is \c 0. + + \code + Rectangle{ + id: labelList + ... + z: 1 + Row{ + anchors.centerIn: parent + spacing:40 + Button{ + label: "File" + id: fileButton + ... + onButtonClick: menuListView.currentIndex = 0 + } + Button{ + id: editButton + label: "Edit" + ... + onButtonClick: menuListView.currentIndex = 1 + } + } + } + \endcode + + The menu bar we just created can be flicked to access the menus or by clicking + on the menu names at the top. Switching menu screens feel intuitive and responsive. + + \image qml-texteditor2_menubar.png + + */ + + /*! + \page qml-textEditor3.html + \title Building a Text Editor + + \section1 Declaring a TextArea + + Our text editor is not a text editor if it didn't contain an editable text area. + QML's \l {TextEdit}{TextEdit} element allows the declaration of a multi-line + editable text area. \l {TextEdit}{TextEdit} is different from a \l {Text}{Text} + element, which doesn't allow the user to directly edit the text. + + \code + TextEdit{ + id: textEditor + anchors.fill:parent + width:parent.width; height:parent.height + color:"midnightblue" + focus: true + + wrapMode: TextEdit.Wrap + + onCursorRectangleChanged: flickArea.ensureVisible(cursorRectangle) + } + \endcode + + The editor has its font color property set and set to wrap the text. The + \c TextEdit area is inside a flickable area that will scroll the text if the + text cursor is outside the visible area. The function \c ensureVisible() will + check if the cursor rectangle is outside the visible boundaries and move the + text area accordingly. QML uses Javascript syntax for its scripts, and as previously + mentioned, Javascript files can be imported and used within a QML file. + + \code + function ensureVisible(r){ + if (contentX >= r.x) + contentX = r.x; + else if (contentX+width <= r.x+r.width) + contentX = r.x+r.width-width; + if (contentY >= r.y) + contentY = r.y; + else if (contentY+height <= r.y+r.height) + contentY = r.y+r.height-height; + } + \endcode + + \section1 Combining Components for the Text Editor + + We are now ready to create the layout of our text editor using QML. The text + editor has two components, the menu bar we created and the text area. QML allows + us to reuse components, therefore making our code simpler, by importing components + and customizing when necessary. Our text editor splits the window into two; + one-third of the screen is dedicated to the menu bar and two-thirds of the screen + displays the text area. The menu bar is displayed in front of any other elements. + + \code + Rectangle{ + + id: screen + width: 1000; height: 1000 + + //the screen is partitioned into the MenuBar and TextArea. 1/3 of the screen is assigned to the MenuBar + property int partition: height/3 + + MenuBar{ + id:menuBar + height: partition + width:parent.width + z: 1 + } + + TextArea{ + id:textArea + anchors.bottom:parent.bottom + y: partition + color: "white" + height: partition*2 + width:parent.width + } + } + \endcode + + By importing reusable components, our \c TextEditor code looks much simpler. + We can then customize the main application, without worrying about properties + that already have defined behaviors. Using this approach, application layouts + and UI components can be created easily. + + \image qml-texteditor3_texteditor.png + + */ + + /*! + \page qml-textEditor4 + \title Decorating the Text Editor + \section1 Implementing a Drawer Interface + + Our text editor looks simple and we need to decorate it. Using QML, we can declare + transitions and animate our text editor. Our menu bar is occupying one-third of the + screen and it would be nice to have it only appear when we want it. + + We can add a drawer interface, that will contract or expand the menu bar when clicked. + In our implementation, we have a thin rectangle that responds to mouse clicks. The + \c drawer, as well as the application, has two sates: the "drawer is open" state and + the "drawer is closed" state. The \c drawer item is a strip of rectangle with a small + height. There is a nested \l {Image}{Image} element declaring that an arrow icon will + be centered inside the drawer. The drawer assigns a state to the whole application, + with the identifier \c screen, whenever a user clicks the mouse area. + + \code + Rectangle{ + id:drawer + height:15 + + Image{ + id: arrowIcon + source: "images/arrow.png" + anchors.horizontalCenter: parent.horizontalCenter + } + + MouseArea{ + id: drawerMouseArea + anchors.fill:parent + onClicked:{ + if (screen.state == "DRAWER_CLOSED"){ + screen.state = "DRAWER_OPEN" + } + else if (screen.state == "DRAWER_OPEN"){ + screen.state = "DRAWER_CLOSED" + } + } + ... + } + } + \endcode + + A state is simply a collection of configurations and it is declared in a + \l{State}{State} element. A list of states can be listed and bound to the + \c states property. In our application, the two states are called + \c DRAWER_CLOSED and \c DRAWER_OPEN. Item configurations are declared in + \l {PropertyChanges}{PropertyChanges} elements. In the \c DRAWER_OPEN state, + there are four items that will receive property changes. The first target, + \c menuBar, will change its \c y property to \c 0. Similarly, the \c textArea + will lower to a new position when the state is \c DRAWER_OPEN. The \c textArea, + the \c drawer, and the drawer's icon will undergo property changes to meet the + current state. + + \code + + states:[ + State{ + name: "DRAWER_OPEN" + PropertyChanges { target: menuBar; y:0} + PropertyChanges { target: textArea; y: partition + drawer.height} + PropertyChanges { target: drawer; y: partition} + PropertyChanges { target: arrowIcon; rotation: 180} + }, + State{ + name: "DRAWER_CLOSED" + PropertyChanges { target: menuBar; y:-partition} + PropertyChanges { target: textArea; y: drawer.height; height: screen.height - drawer.height} + PropertyChanges { target: drawer; y: 0} + PropertyChanges { target: arrowIcon; rotation: 0} + } + + ] + + \endcode + + State changes are abrupt and needs smoother transitions. Transitions between states + are defined using the \l {Transition}{Transition} element, which can then bind to + the item's \c transitions property. Our text editor has a state transition whenever + the state changes to either \c DRAWER_OPEN or \c DRAWER_CLOSED. Importantly, the + transition needs a \c from and a \c to state but for our transitions, we can use + the wild card \c * symbol to denote that the transition applies to all state changes. + + During transitions, we can assign animations to the property changes. Our + \c menuBar switches position from \c {y:0} to \c {y:-partition} and we can animate + this transition using the \l {NumberAnimation}{NumberAnimation} element. We declare + that the targets' properties will animate for a certain duration of time and using + a certain easing curve. An easing curve controls the animation rates and + interpolation behavior during state transitions. The easing curve we chose is + \l{PropertyAnimation::easing.type}{Easing.OutQuint}, which slows the movement near + the end of the animation. Pleae read \l {qdeclarativeanimation.html}{QML's Animation} + article. + + \code + transitions: [ + Transition{ + to: "*" + NumberAnimation { target: textArea; properties: "y, height"; duration: 100; easing.type: Easing.OutQuint } + NumberAnimation { target: menuBar; properties: "y"; duration: 100;easing.type: Easing.OutQuint } + NumberAnimation { target: drawer; properties: "y"; duration: 100;easing.type: Easing.OutQuint } + } + ] + \endcode + + Another way of animating property changes is by declaring a \l {Behavior}{Behavior} + element. A transition only works during state changes and \c Behavior can set an + animation for a general property change. In the text editor, the arrow has a + \c NumberAnimation animating its \c rotation property whenever the property changes. + + \code + In TextEditor.qml: + + Behavior{ + NumberAnimation{property: "rotation";easing.type: Easing.OutExpo } + } + \endcode + + Going back to our components with knowledge of states and animations, we can improve + the appearances of the components. In \c Button.qml, we can add \c color and \c scale + property changes when the button is clicked. Color types are animated using + \l {ColorAnimation}{ColorAnimation} and numbers are animated using + \l {NumberAnimation}{NumberAnimation}. The \c {on propertyName} syntax displayed below + is helpful when targeting a single property. + + \code + In Button.qml: + ... + + color: buttonMouseArea.pressed ? Qt.darker(buttonColor, 1.5) : buttonColor + Behavior on color { ColorAnimation{ duration: 55} } + + scale: buttonMouseArea.pressed ? 1.1 : 1.00 + Behavior on scale { NumberAnimation{ duration: 55} } + \endcode + + Additionally, we can enhance the appearances of our QML components by adding color + effects such as gradients and opacity effects. Declaring a \l {Gradient}{Gradient} + element will override the \c color property of the element. You may declare a color + in the gradient using the \l {GradientStop}{GradientStop} element. The gradient is + positioned using a scale, between \c 0.0 and \c 1.0. + + \code + In MenuBar.qml + gradient: Gradient { + GradientStop { position: 0.0; color: "#8C8F8C" } + GradientStop { position: 0.17; color: "#6A6D6A" } + GradientStop { position: 0.98;color: "#3F3F3F" } + GradientStop { position: 1.0; color: "#0e1B20" } + } + \endcode + + This gradient is used by the menu bar to display a gradient simulating depth. + The first color starts at \c 0.0 and the last color is at \c 1.0. + + + \section2 Where to Go from Here + + We are finished building the user interface of a very simple text editor. + Going forward, the user interface is complete, and we can implement the + application logic using regular Qt and C++. QML works nicely as a prototyping + tool, separating the application logic away from the UI design. + + \image qml-texteditor4_texteditor.png + + \section1 Extending QML using Qt C++ + + 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 + 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. + This way, we only need to load the QML file directly instead of running an executable. + + \section2 Exposing C++ Classes to QML + + We will be implementing file loading and saving using Qt and C++. C++ classes + and functions can be used in QML by registering them. The class also needs to be + compiled as a Qt plugin and the QML file will need to know where the plugin is located. + + For our application, we need to create the following items: + \list 1 + \o \c Directory class that will handle directory related operations + \o \c File class which is a QObject, simulating the list of files in a directory + \o plugin class that will register the class to the QML context + \o Qt project file that will compile the plugin + \o A \c qmldir file telling the qmlviewer tool where to find the plugin + \endlist + + \section2 Building a Qt Plugin + + To build a plugin, we need to set the following in a Qt project file. First, + the necessary sources, headers, and Qt modules need to be added into our + project file. All the C++ code and project files are in the \c filedialog + directory. + + \code + In cppPlugins.pro: + + TEMPLATE = lib + CONFIG += qt plugin + QT += declarative + + DESTDIR += ../plugins + OBJECTS_DIR = tmp + MOC_DIR = tmp + + TARGET = FileDialog + + HEADERS += directory.h \ + file.h \ + dialogPlugin.h + + SOURCES += directory.cpp \ + file.cpp \ + dialogPlugin.cpp + \endcode + + In particular, we compile Qt with the \c declarative module and configure it as a + \c plugin, needing a \c lib template. We shall put the compiled plugin into the + parent's \c plugins directory. + + + \section2 Registering a Class into QML + + \code + In dialogPlugin.h: + + #include + + class DialogPlugin : public QDeclarativeExtensionPlugin + { + Q_OBJECT + + public: + void registerTypes(const char *uri); + + }; + + \endcode + + Our plugin class, \c DialogPlugin is a subclass of \l{QDeclarativeExtensionPlugin}. + We need to implement the inherited function, \l {QDeclarativeExtensionPlugin::}{registerTypes()}. + The \c dialogPlugin.cpp file looks like this: + + \code + DialogPlugin.cpp: + + #include "dialogPlugin.h" + #include "directory.h" + #include "file.h" + #include + + void DialogPlugin::registerTypes(const char *uri){ + + qmlRegisterType(uri, 1, 0, "Directory"); + qmlRegisterType(uri, 1, 0,"File"); + } + + Q_EXPORT_PLUGIN2(FileDialog, DialogPlugin); + \endcode + + The \l{QDeclarativeExtensionPlugin::}{registerTypes()} function registers + our File and Directory classes into QML. This function needs the class name + for its template, a major version number, a minor version number, and a name + for our classes. + + We need to export the plugin using the \l {Q_EXPORT_PLUGIN2}{Q_EXPORT_PLUGIN2} + macro. Note that in our \c dialogPlugin.h file, we have the \l {Q_OBJECT}{Q_OBJECT} + macro at the top of our class. As well, we need to run \c qmake on the project + file to generate the necessary meta-object code. + + + \section2 Creating QML Properties in a C++ class + + We can create QML elements and properties using C++ and + \l {The Meta-Object System}{Qt's Meta-Object System}. We can implement + properties using slots and signals, making Qt aware of these properties. + These properties can then be used in QML. + + For the text editor, we need to be able to load and save files. Typically, + these features are contained in a file dialog. Fortunately, we can use + \l {QDir}{QDir}, \l {QFile}{QFile}, and \l {QTextStream}{QTextStream} to + implement directory reading and input/output streams. + + \code + class Directory : public QObject{ + + Q_OBJECT + + Q_PROPERTY(int filesCount READ filesCount CONSTANT) + Q_PROPERTY(QString filename READ filename WRITE setFilename NOTIFY filenameChanged) + Q_PROPERTY(QString fileContent READ fileContent WRITE setFileContent NOTIFY fileContentChanged) + Q_PROPERTY(QDeclarativeListProperty files READ files CONSTANT ) + + ... + \endcode + + The \c Directory class uses Qt's Meta-Object System to register properties it + needs to accomplish file handling. The \c Directory class is exported as a plugin + and is useable in QML as the \c Directory element. Each of the listed properties + using the \l {Q_PROPERTY()}{Q_PROPERTY} macro is a QML property. + + The \l {Q_PROPERTY()} {Q_PROPERTY} declares a property as well as its read and + write functions into Qt's Meta-Object System. For example, the \c filename + property, of type \l {QString}{QString}, is readable using the \c filename() + function and writable using the function \c setFilename(). Additionally, there + is a signal associated to the filename property called \c filenameChanged(), + which is emitted whenever the property changes. The read and write functions + are declared as \c public in the header file. + + Similarly, we have the other properties declared according to their uses. The + \c filesCount property indicates the number of files in a directory. The filename + property is set to the currently selected file's name and the loaded/saved file + content is stored in \c fileContent property. + + \code + Q_PROPERTY(QDeclarativeListProperty files READ files CONSTANT ) + \endcode + + The \c files list property is a list of all the filtered files in a directory. + The \c Directory class is implemented to filter out invalid text files; only + files with a \c .txt extension are valid. Further, \l {QLists}{QLists} can be + used in QML files by declaring them as a \c QDeclarativeListProperty in C++. + The templated object needs to inherit from a \l {QObject}{QObject}, therefore, + the \c File class must also inherit from \c QObject. In the \c Directory class, + the list of \c File objects is stored in a \c QList called \c m_fileList. + + \code + class File : public QObject{ + + Q_OBJECT + Q_PROPERTY(QString name READ name WRITE setName NOTIFY nameChanged) + + ... + }; + \endcode + + The properties can then be used in QML as part of the \c Directory element's + properties. Note that we do not have to create an identifier \c id property + in our C++ code. + + \code + Directory{ + id: directory + + filesCount + filename + fileContent + files + + files[0].name + } + + \endcode + + Because QML uses Javascript's syntax and structure, we can iterate through + the list of files and retrieve its properties. To retrieve the first file's + name property, we can call \c { files[0].name }. + + Regular C++ functions are also accessible from QML. The file loading and saving + functions are implemented in C++ and declared using the + \l {Q_INVOKABLE}{Q_INVOKABLE} macro. Alternatively, we can declare the functions + as a \c slot and the functions will be accessible from QML. + + \code + In Directory.h: + + Q_INVOKABLE void saveFile(); + Q_INVOKABLE void loadFile(); + \endcode + + The \c Directory class also has to notify other objects whenever the directory + contents change. This feature is performed using a \c signal. As previously + mentioned, QML signals have a corresponding handler with their names prepended + with \c on. The signal is called \c directoryChanged and it is emitted whenever + there is a directory refresh. The refresh simply reloads the directory contents + and updates the list of valid files in the directory. QML items can then be + notified by attaching an action to the \c onDirectoryChanged signal handler. + + The \c list properties need to be explored further. This is because list + properties use callbacks to access and modify the list contents. The list + property is of type \c QDeclarativeListProperty. Whenever the list + is accessed, the accessor function needs to return a + \c QDeclarativeListProperty. The template type, \c File, needs to be a + \c QObject derivative. Further, to create the + \l {QDeclarativeListProperty}{QDeclarativeListProperty}, the list's accessor + and modifiers need to be passed to the consructor as function pointers. The list, + a \c QList in our case, also needs to be a list of \c File pointers. + + The constructor of \l {QDeclarativeListProperty}{QDeclarativeListProperty} + constructor and the \c Directory implementation: + \code + QDeclarativeListProperty ( QObject * object, void * data, AppendFunction append, CountFunction count = 0, AtFunction at = 0, ClearFunction clear = 0 ) + QDeclarativeListProperty( this, &m_fileList, &appendFiles, &filesSize, &fileAt, &clearFilesPtr ); + \endcode + + The constructor passes pointers to functions that will append the list, count + the list, retrieve the item using an index, and empty the list. Only the append + function is mandatory. Note that the function pointers must match the definition + of \l {QDeclarativeListProperty::AppendFunction}{AppendFunction}, + \l {QDeclarativeListProperty::CountFunction}{CountFunction}, + \l {QDeclarativeListProperty::AtFunction}{AtFunction}, or + \l {QDeclarativeListProperty::ClearFunction}{ClearFunction}. + + \code + void appendFiles(QDeclarativeListProperty * property, File * file) + File* fileAt(QDeclarativeListProperty * property, int index) + int filesSize(QDeclarativeListProperty * property) + void clearFilesPtr(QDeclarativeListProperty *property) + \endcode + + To simplify our file dialog, the \c Directory class filters out invalid text + files, which are files that do not have a \c .txt extension. If a file name + doesn't have the \c .txt extension, then it won't be seen in our file dialog. + Also, the implementation makes sure that saved files have a \c .txt extension in + the file name. \c Directory uses \l {QTextStream}{QTextStream} to read the file + and to output the file contents to a file. + + With our \c Directory element, we can retrieve the files as a list, know how many + text files is in the application directory, get the file's name and content as a + string, and be notified whenever there are changes in the directory contents. + + To build the plugin, run \c qmake on the \c cppPlugins.pro project file, then run + \c make to build and transfer the plugin to the \c plugins directory. + + + \section2 Importing a Plugin in QML + + The qmlviewer tool imports files that are in the same directory as the + application. We can also create a \c qmldir file containing the locations of + QML files we wish to import. The \c qmldir file can also store locations of + plugins and other resources. + + \code + In qmldir: + + Button ./Button.qml + FileDialog ./FileDialog.qml + TextArea ./TextArea.qml + TextEditor ./TextEditor.qml + EditMenu ./EditMenu.qml + + plugin FileDialog plugins + \endcode + + The plugin we just created is called \c FileDialog, as indicated by the + \c TARGET field in the project file. The compiled plugin is in the \c plugins directory. + + + \section2 Integrating a File Dialog into the File Menu + + Our \c FileMenu needs to display the \c FileDialog element, containing a list of + the text files in a directory thus allowing the user to select the file by + clicking on the list. We also need to assign the save, load, and new buttons + to their respective actions. The FileMenu contains an editable text input to + allow the user to type a file name using the keyboard. + + The \c Directory element is used in the \c FileMenu.qml file and it notifies the + \c FileDialog element that the directory refreshed its contents. This notification + is performed in the signal handler, \c onDirectoryChanged. + + \code + In FileMenu.qml: + + Directory{ + id:directory + filename: textInput.text + onDirectoryChanged: fileDialog.notifyRefresh() + } + \endcode + + Keeping with the simplicity of our application, the file dialog will always be + visible and will not display invalid text files, which do not have a \c .txt + extension to their filenames. + + \code + In FileDialog.qml: + + signal notifyRefresh() + onNotifyRefresh: dirView.model = directory.files + \endcode + + The \c FileDialog element will display the contents of a directory by reading its + list property called \c files. The files are used as the model of a + \l {GridView}{GridView} element, which displays data items in a grid according + to a delegate. The delegate handles the appearance of the model and our file + dialog will simply create a grid with text centered in the middle. Clicking on + the file name will result in the appearance of a rectangle to highlight the file + name. The \c FileDialog is notified whenever the \c notifyRefresh signal is emitted, + reloading the files in the directory. + + \code + In FileMenu.qml: + + Button{ + id: newButton + label: "New" + onButtonClick:{ + textArea.textContent = "" + } + } + Button{ + id: loadButton + label: "Load" + onButtonClick:{ + directory.filename = textInput.text + directory.loadFile() + textArea.textContent = directory.fileContent + } + } + Button{ + id: saveButton + label: "Save" + onButtonClick:{ + directory.fileContent = textArea.textContent + directory.filename = textInput.text + directory.saveFile() + } + } + Button{ + id: exitButton + label: "Exit" + onButtonClick:{ + Qt.quit() + } + } + \endcode + + Our \c FileMenu can now connect to their respective actions. The \c saveButton + will transfer the text from the \c TextEdit onto the directory's \c fileContent + property, then copy its file name from the editable text input. Finally, the button + calls the \c saveFile() function, saving the file. The \c sloadButton has a similar + execution. Also, the \c New action will empty the contents of the \c TextEdit. + + Further, the \c EditMenu buttons are connected to the \c TextEdit functions to copy, + paste, and select all the text in the text editor. + + \image qml-texteditor5_filemenu.png + + \section1 Text Editor Completion + + \image qml-texteditor5_newfile.png + + The application can function as a simple text editor, able to accept text + and save the text into a file. The text editor can also load from a file and + perform text manipulation. +*/ diff --git a/doc/src/getting-started/gettingstartedqt.qdoc b/doc/src/getting-started/gettingstartedqt.qdoc index 1b3770f..25d0ccd 100644 --- a/doc/src/getting-started/gettingstartedqt.qdoc +++ b/doc/src/getting-started/gettingstartedqt.qdoc @@ -28,8 +28,8 @@ /*! \page gettingstartedqt.html - \title Getting Started programming with Qt - \ingroup gettingStarted + \title Getting Started Programming with Qt + \ingroup gettingStarted Welcome to the world of Qt--the cross-platform GUI toolkit. In this getting started guide, we teach basic Qt knowledge by @@ -85,7 +85,7 @@ other widgets), it is possible to show a single widget in its own window. Widgets are not visible by default; the function \l{QWidget::}{show()} makes the widget visible. - + Line 11 makes the QApplication enter its event loop. When a Qt application is running, events are generated and sent to the widgets of the application. Examples of events are mouse presses diff --git a/doc/src/qt4-intro.qdoc b/doc/src/qt4-intro.qdoc index 8867fd9..3771bcc 100644 --- a/doc/src/qt4-intro.qdoc +++ b/doc/src/qt4-intro.qdoc @@ -455,10 +455,10 @@ \image quick_screens.png - Qt 4.7 introduces Quick, the Qt UI Creation Kit. that enables the creation - of dynamic user interfaces, easier and more effective than possible - with existing UI technologies. This UI Creation Kit consist of three - technologies: + Qt 4.7 introduces \l{Qt Quick}, the Qt UI Creation Kit. that enables + the creation of dynamic user interfaces, easier and more effective + than possible with existing UI technologies. This UI Creation Kit + consists of three technologies: \list \i QML is a declarative language oriented on JavaScript that utilizes diff --git a/examples/declarative/ui-components/dialcontrol/content/Dial.qml b/examples/declarative/ui-components/dialcontrol/content/Dial.qml index b5074a64..3ffa09a 100644 --- a/examples/declarative/ui-components/dialcontrol/content/Dial.qml +++ b/examples/declarative/ui-components/dialcontrol/content/Dial.qml @@ -68,6 +68,7 @@ Item { transform: Rotation { id: needleRotation origin.x: 5; origin.y: 65 + //! [needle angle] angle: Math.min(Math.max(-130, root.value*2.6 - 130), 133) Behavior on angle { SpringAnimation { @@ -75,6 +76,7 @@ Item { damping: .15 } } + //! [needle angle] } } //! [needle] diff --git a/examples/declarative/ui-components/dialcontrol/dialcontrol.qml b/examples/declarative/ui-components/dialcontrol/dialcontrol.qml index 95df68c..46cc3e6 100644 --- a/examples/declarative/ui-components/dialcontrol/dialcontrol.qml +++ b/examples/declarative/ui-components/dialcontrol/dialcontrol.qml @@ -38,8 +38,10 @@ ** ****************************************************************************/ +//! [imports] import Qt 4.7 import "content" +//! [imports] //! [0] Rectangle { @@ -87,4 +89,4 @@ Rectangle { } } } -//! [0] \ No newline at end of file +//! [0] diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp index 1d48b1a..e3e1840 100644 --- a/src/declarative/qml/qdeclarativecomponent.cpp +++ b/src/declarative/qml/qdeclarativecomponent.cpp @@ -599,7 +599,7 @@ QDeclarativeComponent::QDeclarativeComponent(QDeclarativeComponentPrivate &dd, Q property, or else the object will not be visible. Dynamically created instances can be deleted with the \c destroy() method. - See \l {Dynamic Object Management} for more information. + See \l {Dynamic Object Management in QML} for more information. */ /*! diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 3822373..a476629 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -240,7 +240,7 @@ The format specification is described at \l{QML:Qt::formatDateTime}{Qt.formatDat \section1 Dynamic Object Creation The following functions on the global object allow you to dynamically create QML -items from files or strings. See \l{Dynamic Object Management} for an overview +items from files or strings. See \l{Dynamic Object Management in QML} for an overview of their use. \list @@ -1118,7 +1118,7 @@ For example: \snippet doc/src/snippets/declarative/createComponent-simple.qml 0 -See \l {Dynamic Object Management} for more information on using this function. +See \l {Dynamic Object Management in QML} for more information on using this function. To create a QML object from an arbitrary string of QML (instead of a file), use \l{QML:Qt::createQmlObject()}{Qt.createQmlObject()}. @@ -1170,7 +1170,7 @@ Note that this function returns immediately, and therefore may not work if the \a qml string loads new components (that is, external QML files that have not yet been loaded). If this is the case, consider using \l{QML:Qt::createComponent()}{Qt.createComponent()} instead. -See \l {Dynamic Object Management} for more information on using this function. +See \l {Dynamic Object Management in QML} for more information on using this function. */ QScriptValue QDeclarativeEnginePrivate::createQmlObject(QScriptContext *ctxt, QScriptEngine *engine) -- cgit v0.12 From 58d0e46dcc50a3cddabc177c9dfdfec5c66e932d Mon Sep 17 00:00:00 2001 From: David Boddie Date: Tue, 10 Aug 2010 15:12:42 +0200 Subject: Doc: Removed invalid entities in documentation. Details: It is not necessary to use entities. In any case, I replaced them with words for consistency. --- doc/src/getting-started/examples.qdoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/src/getting-started/examples.qdoc b/doc/src/getting-started/examples.qdoc index 1bf86e5..708c44e 100644 --- a/doc/src/getting-started/examples.qdoc +++ b/doc/src/getting-started/examples.qdoc @@ -343,8 +343,8 @@ /*! \page examples-draganddrop.html \ingroup all-examples - \title Drag & Drop Examples - \brief How to access your platform's native darg & drop functionality + \title Drag and Drop Examples + \brief How to access your platform's native drag and drop functionality. \image draganddrop-examples.png -- cgit v0.12