summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets
diff options
context:
space:
mode:
Diffstat (limited to 'doc/src/snippets')
-rw-r--r--doc/src/snippets/code/doc_src_dnd.cpp74
-rw-r--r--doc/src/snippets/code/doc_src_porting-qsa.cpp89
-rw-r--r--doc/src/snippets/code/doc_src_porting-qsa.js117
-rw-r--r--doc/src/snippets/code/doc_src_porting-qsa.qdoc99
-rw-r--r--doc/src/snippets/code/doc_src_porting4-canvas.cpp156
-rw-r--r--doc/src/snippets/code/doc_src_porting4-designer.cpp173
-rw-r--r--doc/src/snippets/code/doc_src_porting4-designer.pro43
-rw-r--r--doc/src/snippets/code/doc_src_porting4-designer.qdoc59
-rw-r--r--doc/src/snippets/code/doc_src_porting4.cpp513
-rw-r--r--doc/src/snippets/code/doc_src_q3asciidict.cpp92
-rw-r--r--doc/src/snippets/code/doc_src_q3dict.cpp69
-rw-r--r--doc/src/snippets/code/doc_src_q3intdict.cpp91
-rw-r--r--doc/src/snippets/code/doc_src_q3memarray.cpp108
-rw-r--r--doc/src/snippets/code/doc_src_q3memarray.qdoc50
-rw-r--r--doc/src/snippets/code/doc_src_q3ptrdict.cpp106
-rw-r--r--doc/src/snippets/code/doc_src_q3ptrlist.cpp122
-rw-r--r--doc/src/snippets/code/doc_src_q3valuelist.cpp135
-rw-r--r--doc/src/snippets/code/doc_src_q3valuestack.cpp53
-rw-r--r--doc/src/snippets/code/doc_src_q3valuevector.cpp125
-rw-r--r--doc/src/snippets/code/doc_src_qt3to4.cpp43
-rw-r--r--doc/src/snippets/code/doc_src_qt3to4.qdoc66
-rw-r--r--doc/src/snippets/code/doc_src_qt4-accessibility.cpp99
-rw-r--r--doc/src/snippets/code/doc_src_qt4-arthur.cpp144
-rw-r--r--doc/src/snippets/code/doc_src_qt4-sql.cpp59
-rw-r--r--doc/src/snippets/code/doc_src_qt4-tulip.cpp140
-rw-r--r--doc/src/snippets/code/src_qt3support_canvas_q3canvas.cpp91
-rw-r--r--doc/src/snippets/code/src_qt3support_dialogs_q3filedialog.cpp269
-rw-r--r--doc/src/snippets/code/src_qt3support_dialogs_q3progressdialog.cpp81
-rw-r--r--doc/src/snippets/code/src_qt3support_itemviews_q3iconview.cpp115
-rw-r--r--doc/src/snippets/code/src_qt3support_itemviews_q3listview.cpp113
-rw-r--r--doc/src/snippets/code/src_qt3support_itemviews_q3table.cpp97
-rw-r--r--doc/src/snippets/code/src_qt3support_network_q3dns.cpp98
-rw-r--r--doc/src/snippets/code/src_qt3support_network_q3ftp.cpp105
-rw-r--r--doc/src/snippets/code/src_qt3support_network_q3http.cpp114
-rw-r--r--doc/src/snippets/code/src_qt3support_network_q3localfs.cpp44
-rw-r--r--doc/src/snippets/code/src_qt3support_network_q3networkprotocol.cpp48
-rw-r--r--doc/src/snippets/code/src_qt3support_network_q3socket.cpp44
-rw-r--r--doc/src/snippets/code/src_qt3support_network_q3socketdevice.cpp44
-rw-r--r--doc/src/snippets/code/src_qt3support_network_q3url.cpp83
-rw-r--r--doc/src/snippets/code/src_qt3support_network_q3urloperator.cpp77
-rw-r--r--doc/src/snippets/code/src_qt3support_other_q3accel.cpp80
-rw-r--r--doc/src/snippets/code/src_qt3support_other_q3mimefactory.cpp72
-rw-r--r--doc/src/snippets/code/src_qt3support_other_q3process.cpp48
-rw-r--r--doc/src/snippets/code/src_qt3support_other_q3process_unix.cpp44
-rw-r--r--doc/src/snippets/code/src_qt3support_painting_q3paintdevicemetrics.cpp44
-rw-r--r--doc/src/snippets/code/src_qt3support_painting_q3painter.cpp44
-rw-r--r--doc/src/snippets/code/src_qt3support_painting_q3picture.cpp54
-rw-r--r--doc/src/snippets/code/src_qt3support_sql_q3databrowser.cpp48
-rw-r--r--doc/src/snippets/code/src_qt3support_sql_q3datatable.cpp48
-rw-r--r--doc/src/snippets/code/src_qt3support_sql_q3dataview.cpp44
-rw-r--r--doc/src/snippets/code/src_qt3support_sql_q3sqlcursor.cpp140
-rw-r--r--doc/src/snippets/code/src_qt3support_sql_q3sqlform.cpp66
-rw-r--r--doc/src/snippets/code/src_qt3support_sql_q3sqlmanager_p.cpp51
-rw-r--r--doc/src/snippets/code/src_qt3support_sql_q3sqlpropertymap.cpp75
-rw-r--r--doc/src/snippets/code/src_qt3support_sql_q3sqlselectcursor.cpp51
-rw-r--r--doc/src/snippets/code/src_qt3support_text_q3simplerichtext.cpp43
-rw-r--r--doc/src/snippets/code/src_qt3support_text_q3textbrowser.cpp43
-rw-r--r--doc/src/snippets/code/src_qt3support_text_q3textedit.cpp71
-rw-r--r--doc/src/snippets/code/src_qt3support_text_q3textstream.cpp69
-rw-r--r--doc/src/snippets/code/src_qt3support_tools_q3cstring.cpp80
-rw-r--r--doc/src/snippets/code/src_qt3support_tools_q3deepcopy.cpp98
-rw-r--r--doc/src/snippets/code/src_qt3support_tools_q3garray.cpp60
-rw-r--r--doc/src/snippets/code/src_qt3support_tools_q3signal.cpp78
-rw-r--r--doc/src/snippets/code/src_qt3support_widgets_q3combobox.cpp55
-rw-r--r--doc/src/snippets/code/src_qt3support_widgets_q3datetimeedit.cpp68
-rw-r--r--doc/src/snippets/code/src_qt3support_widgets_q3dockarea.cpp48
-rw-r--r--doc/src/snippets/code/src_qt3support_widgets_q3dockwindow.cpp44
-rw-r--r--doc/src/snippets/code/src_qt3support_widgets_q3gridview.cpp46
-rw-r--r--doc/src/snippets/code/src_qt3support_widgets_q3header.cpp46
-rw-r--r--doc/src/snippets/code/src_qt3support_widgets_q3mainwindow.cpp85
-rw-r--r--doc/src/snippets/code/src_qt3support_widgets_q3scrollview.cpp101
-rw-r--r--doc/src/snippets/code/src_qt3support_widgets_q3whatsthis.cpp43
-rw-r--r--doc/src/snippets/plaintextlayout/window.cpp108
-rw-r--r--doc/src/snippets/porting4-dropevents/window.cpp124
-rw-r--r--doc/src/snippets/qsvgwidget/main.cpp59
-rw-r--r--doc/src/snippets/scribe-overview/main.cpp73
-rw-r--r--doc/src/snippets/stringlistmodel/main.cpp83
-rw-r--r--doc/src/snippets/stringlistmodel/model.cpp211
-rw-r--r--doc/src/snippets/stringlistmodel/model.h82
-rw-r--r--doc/src/snippets/textdocument-blocks/mainwindow.cpp156
-rw-r--r--doc/src/snippets/textdocument-printing/mainwindow.cpp124
81 files changed, 7255 insertions, 0 deletions
diff --git a/doc/src/snippets/code/doc_src_dnd.cpp b/doc/src/snippets/code/doc_src_dnd.cpp
new file mode 100644
index 0000000..d5dc721
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_dnd.cpp
@@ -0,0 +1,74 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+void MyQt3Widget::customStartDragFunction()
+{
+ QDragObject *d = new QTextDrag( myHighlightedText(), this );
+ d->dragCopy();
+ // do NOT delete d.
+}
+//! [0]
+
+
+//! [1]
+void MyQt3Widget::dragEnterEvent(QDragEnterEvent* event)
+{
+ event->accept(
+ QTextDrag::canDecode(event) ||
+ QImageDrag::canDecode(event)
+ );
+}
+//! [1]
+
+
+//! [2]
+void MyQt3Widget::dropEvent(QDropEvent* event)
+{
+ QImage image;
+ QString text;
+
+ if ( QImageDrag::decode(event, image) ) {
+ insertImageAt(image, event->pos());
+ } else if ( QTextDrag::decode(event, text) ) {
+ insertTextAt(text, event->pos());
+ }
+}
+//! [2]
diff --git a/doc/src/snippets/code/doc_src_porting-qsa.cpp b/doc/src/snippets/code/doc_src_porting-qsa.cpp
new file mode 100644
index 0000000..f9b9c6b
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_porting-qsa.cpp
@@ -0,0 +1,89 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [16]
+QPushButton *button = new QPushButton();
+button->setObjectName("button");
+interpreter->addTransientObject(button);
+//! [16]
+
+
+//! [17]
+QPushButton *button = new QPushButton();
+QScriptValue scriptButton = engine.newQObject(button);
+engine.globalObject().setProperty("button", scriptButton);
+//! [17]
+
+
+//! [18]
+ModuleFactory::ModuleFactory()
+{
+ registerClass( "ImageSource", &ImgSource::staticMetaObject);
+ ...
+}
+
+QObject *ModuleFactory::create( const QString &type,
+ const QVariantList &,
+ QObject * )
+{
+ if ( type == "ImageSource" )
+ return new ImgSource();
+ ...
+}
+
+...
+
+interpreter.addObjectFactory(new ModuleFactory());
+//! [18]
+
+
+//! [19]
+QScriptValue construct_QPushButton(QScriptContext *, QScriptEngine *engine) {
+ return engine->newQObject(new QPushButton());
+}
+
+...
+
+QScriptValue constructor = engine.newFunction(construct_QPushButton);
+QScriptValue value =
+ engine.newQMetaObject(&QPushButton::staticMetaObject,
+ constructor);
+engine.globalObject().setProperty("QPushButton", value);
+//! [19]
diff --git a/doc/src/snippets/code/doc_src_porting-qsa.js b/doc/src/snippets/code/doc_src_porting-qsa.js
new file mode 100644
index 0000000..e58f5b7
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_porting-qsa.js
@@ -0,0 +1,117 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+point = new Object();
+point.x = 12;
+point.y = 35;
+//! [0]
+
+
+//! [1]
+function manhattanLength(point) {
+ return point.x + point.y;
+}
+//! [1]
+
+
+//! [2]
+manhattanLength = function(point) {
+ return point.x + point.y;
+}
+//! [2]
+
+
+//! [3]
+point.manhattanLength = function() {
+ return this.x + this.y;
+}
+print(point.manhattanLength()); // prints 47
+//! [3]
+
+
+//! [5]
+point.manhattanLength = function() {
+ return this.x + this.y;
+}
+print(point.manhattanLength()); // prints 47
+//! [5]
+
+
+//! [8]
+var car = new Object();
+car.constructor = function(regnr) {
+ // ...
+}
+car.constructor();
+//! [8]
+
+
+//! [10]
+function Car(regnr) {
+ this.regNumber = regnr;
+ this.toString = function() { return this.regNumber; }
+}
+//! [10]
+
+
+//! [11]
+function Car(regnr) {
+ this.regNumber = regnr;
+}
+Car.prototype.toString = function() { return this.regNumber; }
+//! [11]
+
+
+//! [13]
+function GasolineCar(regnr) {
+ Car(regnr);
+}
+GasolineCar.prototype = new Car();
+GasolineCar.prototype.toString = function() {
+ return "GasolineCar(" + this.regNumber + ")";
+}
+//! [13]
+
+
+//! [15]
+Car.globalCount = 0;
+print(Car.globalCount);
+//! [15]
diff --git a/doc/src/snippets/code/doc_src_porting-qsa.qdoc b/doc/src/snippets/code/doc_src_porting-qsa.qdoc
new file mode 100644
index 0000000..1846640
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_porting-qsa.qdoc
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [4]
+class Point() {
+ var x;
+ var y;
+ function manhattanLength() { return x + y; }
+}
+//! [4]
+
+
+//! [6]
+class Car {
+ var regNumber;
+ function Car(regnr) {
+ regNumber = regnr;
+ }
+}
+var car = new Car("ABC 123");
+//! [6]
+
+
+//! [7]
+function Car(regnr) {
+ this.regNumber = regnr;
+}
+var car = new Car("ABC 123");
+//! [7]
+
+
+//! [9]
+class Car {
+ var regNumber;
+ function Car(regnr) {
+ regNumber = regnr;
+ }
+ function toString() {
+ return regNumber;
+ }
+}
+//! [9]
+
+
+//! [12]
+class GasolineCar extends Car {
+ function GasolineCar(regnr) {
+ Car(regnr);
+ }
+ function toString() {
+ return "GasolineCar(" + regNumber + ")";
+ }
+}
+//! [12]
+
+
+//! [14]
+class Car {
+ static var globalCount = 0;
+}
+print(Car.globalCount);
+//! [14]
diff --git a/doc/src/snippets/code/doc_src_porting4-canvas.cpp b/doc/src/snippets/code/doc_src_porting4-canvas.cpp
new file mode 100644
index 0000000..8004163
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_porting4-canvas.cpp
@@ -0,0 +1,156 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+item->scene().sceneRect().intersects(item->sceneBoundingRect());
+//! [0]
+
+
+//! [1]
+class TileScene : public QGraphicsScene
+{
+public:
+ ...
+
+ void setTiles(const QPixmap &pixmap, int h, int v,
+ int tileHeight, int tileWidth);
+ void setTile(int x, int y, int tilenum);
+
+private:
+ QRect tileRect(int x, int y) const;
+ QRect tileRect(int tileNum) const;
+
+ QVector<QVector<int> > tiles;
+ QPixmap tilePixmap;
+ int tileW, tileH;
+ int hTiles, vTiles;
+};
+//! [1]
+
+
+//! [2]
+void TileScene::setTiles(const QPixmap &pixmap, int h, int v,
+ int tileHeight, int tileWidth)
+{
+ tilePixmap = pixmap;
+ tileW = tileWidth;
+ tileH = tileHeight;
+ hTiles = h;
+ vTiles = v;
+
+ tiles.resize(v);
+ for (int y = 0; y < v; ++y)
+ tiles[y].resize(h);
+}
+//! [2]
+
+
+//! [3]
+void TileScene::setTile(int x, int y, int tilenum)
+{
+ tiles[y][x] = tilenum;
+ update(tileRect(x, y));
+}
+//! [3]
+
+
+//! [4]
+QRect TileScene::tileRect(int x, int y) const
+{
+ return QRect(x * tileW, y * tileH, tileW, tileH);
+}
+//! [4]
+
+
+//! [5]
+QRect TileScene::tileRect(int tileNum) const
+{
+ int numHTiles = tilePixmap.width() / tileW;
+ int numVTiles = tilePixmap.height() / tileH;
+ return tileRect(tileNum % numHTiles, tileNum / numHTiles);
+}
+//! [5]
+
+
+//! [6]
+void drawBackground(QPainter *painter, const QRectF &exposed)
+{
+ for (int y = 0; y < vTiles; ++y) {
+ for (int x = 0; x < hTiles; ++x) {
+ QRect destRect = tileRect(x, y);
+ if (exposed.intersects(destRect)) {
+ painter->drawPixmap(destRect, tilePixmap,
+ tileRect(tiles[y][x]));
+ }
+ }
+ }
+}
+//! [6]
+
+
+//! [7]
+ // Before
+ Q3CanvasEllipse ellipse(10, 10);
+
+ // After
+ QGraphicsEllipseItem ellipse(-5, -5, 10, 10);
+//! [7]
+
+
+//! [8]
+static QPainterPath fromControlPoints(const Q3PointArray &pa)
+{
+ QPainterPath path;
+ path.moveTo(pa[0]);
+ for (int i = 1; i < pa.size(); i += 3)
+ path.cubicTo(pa[i], pa[(i + 1) % pa.size()], pa[(i + 2) % pa.size()]);
+ return path;
+}
+//! [8]
+
+
+//! [9]
+wildcardPath.replace("%1", "*");
+QFileInfo fi(wildcardPath);
+
+QList<QPixmap> frames;
+foreach (QString entry, QDir(fi.path(), fi.fileName()).entryList())
+ frames << QPixmap(fi.path() + "/" + entry);
+//! [9]
diff --git a/doc/src/snippets/code/doc_src_porting4-designer.cpp b/doc/src/snippets/code/doc_src_porting4-designer.cpp
new file mode 100644
index 0000000..1d73aae
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_porting4-designer.cpp
@@ -0,0 +1,173 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+namespace Ui {
+
+class HelloWorld
+{
+public:
+ QVBoxLayout *vboxLayout;
+ QPushButton *pushButton;
+
+ void setupUi(QWidget *HelloWorld)
+ {
+ HelloWorld->setObjectName(QString::fromUtf8("HelloWorld"));
+
+ vboxLayout = new QVBoxLayout(HelloWorld);
+ vboxLayout->setObjectName(QString::fromUtf8("vboxLayout"));
+
+ pushButton = new QPushButton(HelloWorld);
+ pushButton->setObjectName(QString::fromUtf8("pushButton"));
+
+ vboxLayout->addWidget(pushButton);
+
+ retranslateUi(HelloWorld);
+ }
+};
+
+}
+//! [0]
+
+
+//! [1]
+#include <QApplication>
+#include <QWidget>
+
+#include "ui_helloworld.h" // defines Ui::HelloWorld
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+ QWidget w;
+ Ui::HelloWorld ui;
+ ui.setupUi(&w);
+
+ w.show();
+ return app.exec();
+}
+//! [1]
+
+
+//! [2]
+#include <QApplication>
+#include <QWidget>
+
+#include "ui_helloworld.h" // defines Ui::HelloWorld
+
+class HelloWorldWidget : public QWidget, public Ui::HelloWorld
+{
+ Q_OBJECT
+
+public:
+ HelloWorldWidget(QWidget *parent = 0)
+ : QWidget(parent)
+ { setupUi(this); }
+};
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ HelloWorldWidget w;
+ w.show();
+ return app.exec();
+}
+//! [2]
+
+
+//! [5]
+class HelloWorldWidget : public QWidget, public Ui::HelloWorld
+{
+ Q_OBJECT
+
+public:
+ HelloWorldWidget(QWidget *parent = 0);
+
+public slots:
+ void mySlot();
+};
+
+HelloWorldWidget::HelloWorldWidget(QWidget *parent)
+ : QWidget(parent)
+{
+ setupUi(this);
+
+ QObject::connect(pushButton, SIGNAL(clicked()),
+ this, SLOT(mySlot()));
+}
+
+void HelloWorldWidget::mySlot()
+{
+ ...
+}
+//! [5]
+
+
+//! [6]
+class HelloWorldWidget : public QWidget, public Ui::HelloWorld
+{
+ Q_OBJECT
+
+public:
+ HelloWorldWidget(QWidget *parent = 0);
+
+public slots:
+ void on_pushButton_clicked();
+};
+
+HelloWorldWidget::HelloWorldWidget(QWidget *parent)
+ : QWidget(parent)
+{
+ setupUi(this);
+}
+
+void HelloWorldWidget::on_pushButton_clicked()
+{
+ ...
+}
+//! [6]
+
+
+//! [9]
+QFile file(":/icons/yes.png");
+QIcon icon(":/icons/no.png");
+QPixmap pixmap(":/icons/no.png");
+//! [9]
diff --git a/doc/src/snippets/code/doc_src_porting4-designer.pro b/doc/src/snippets/code/doc_src_porting4-designer.pro
new file mode 100644
index 0000000..673e593
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_porting4-designer.pro
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#! [8]
+RESOURCES += icons.qrc
+#! [8]
diff --git a/doc/src/snippets/code/doc_src_porting4-designer.qdoc b/doc/src/snippets/code/doc_src_porting4-designer.qdoc
new file mode 100644
index 0000000..b5c686b
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_porting4-designer.qdoc
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [3]
+uic3 myform.ui > myform.h
+uic3 -impl myform.h myform.ui > myform.cpp
+//! [3]
+
+
+//! [4]
+uic3 -convert myform3.ui > myform4.ui
+//! [4]
+
+
+//! [7]
+<RCC version="1.0">
+ <qresource prefix="/icons">
+ <file>yes.png</file>
+ <file>no.png</file>
+ </qresource>
+</RCC>
+//! [7]
diff --git a/doc/src/snippets/code/doc_src_porting4.cpp b/doc/src/snippets/code/doc_src_porting4.cpp
new file mode 100644
index 0000000..14c708a
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_porting4.cpp
@@ -0,0 +1,513 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+void MyButton::paintEvent(QPaintEvent *)
+{
+ QPainter painter(this);
+ drawButton(&painter);
+}
+//! [0]
+
+
+//! [1]
+ba.at(0) = 'X';
+//! [1]
+
+
+//! [2]
+ba[0] = 'X';
+//! [2]
+
+
+//! [3]
+if (!cache.insert(key, object))
+ delete object;
+//! [3]
+
+
+//! [4]
+cache.insert(key, object);
+//! [4]
+
+
+//! [5]
+Q3Cache<QWidget> cache;
+cache.insert(widget->name(), widget);
+...
+QWidget *foo = cache.take("foo");
+if (foo)
+ foo->show();
+//! [5]
+
+
+//! [6]
+typedef QWidget *QWidgetPtr;
+QCache<QString, QWidgetPtr> cache;
+cache.insert(widget->name(), new QWidgetPtr(widget));
+...
+QWidgetPtr *ptr = cache.take("foo");
+if (ptr) {
+ QWidget *foo = *ptr;
+ delete ptr;
+ foo->show();
+}
+//! [6]
+
+
+//! [7]
+painter.setBrush(palette().brush(QPalette::Text));
+//! [7]
+
+
+//! [8]
+QByteArray ba("Hello");
+ba.size(); // returns 5 (the '\0' is not counted)
+ba.length(); // returns 5
+ba.data()[5]; // returns '\0'
+//! [8]
+
+
+//! [9]
+dict.replace(key, value);
+//! [9]
+
+
+//! [10]
+delete hash.take(key);
+hash.insert(key, value);
+//! [10]
+
+
+//! [11]
+dict.remove(key, value);
+//! [11]
+
+
+//! [12]
+delete hash.take(key);
+//! [12]
+
+
+//! [13]
+dict.clear();
+//! [13]
+
+
+//! [14]
+while (!hash.isEmpty()) {
+ T *value = *hash.begin();
+ hash.erase(hash.begin());
+ delete value;
+}
+//! [14]
+
+
+//! [15]
+qDeleteAll(hash);
+hash.clear();
+//! [15]
+
+
+//! [16]
+Q3DictIterator<QWidget> i(dict);
+while (i.current() != 0) {
+ do_something(i.currentKey(), i.current());
+ ++i;
+}
+//! [16]
+
+
+//! [17]
+QHashIterator<QString, QWidget *> i(hash);
+while (i.hasNext()) {
+ i.next(); // must come first
+ do_something(i.key(), i.value());
+}
+//! [17]
+
+
+//! [18]
+QList<QWidget *> myWidgets = myParent->findChildren<QWidget *>();
+//! [18]
+
+
+//! [19]
+list.replace(index, value);
+//! [19]
+
+
+//! [20]
+delete list[index];
+list[index] = value;
+//! [20]
+
+
+//! [21]
+list.removeFirst();
+//! [21]
+
+
+//! [22]
+delete list.takeFirst();
+//! [22]
+
+
+//! [23]
+list.removeLast();
+//! [23]
+
+
+//! [24]
+delete list.takeLast();
+//! [24]
+
+
+//! [25]
+list.remove(index);
+//! [25]
+
+
+//! [26]
+delete list.takeAt(index);
+//! [26]
+
+
+//! [27]
+list.remove(value);
+//! [27]
+
+
+//! [28]
+int i = list.indexOf(value);
+if (i != -1)
+ delete list.takeAt(i);
+//! [28]
+
+
+//! [29]
+list.remove();
+//! [29]
+
+
+//! [30]
+QMutableListIterator<T *> i;
+...
+delete i.value();
+i.remove();
+//! [30]
+
+
+//! [31]
+list.clear();
+//! [31]
+
+
+//! [32]
+while (!list.isEmpty())
+ delete list.takeFirst();
+//! [32]
+
+
+//! [33]
+qDeleteAll(list);
+list.clear();
+//! [33]
+
+
+//! [34]
+QPtrList<QWidget> list;
+...
+while (list.current() != 0) {
+ do_something(list.current());
+ list.next();
+}
+//! [34]
+
+
+//! [35]
+QList<QWidget *> list;
+...
+QListIterator<QWidget *> i(list);
+while (i.hasNext())
+ do_something(i.next());
+//! [35]
+
+
+//! [36]
+QPtrList<QWidget> list;
+...
+QPtrListIterator<QWidget> i;
+while (i.current() != 0) {
+ do_something(i.current());
+ i.next();
+}
+//! [36]
+
+
+//! [37]
+QList<QWidget *> list;
+...
+QListIterator<QWidget *> i(list);
+while (i.hasNext())
+ do_something(i.next());
+//! [37]
+
+
+//! [38]
+queue.dequeue();
+//! [38]
+
+
+//! [39]
+delete queue.dequeue();
+//! [39]
+
+
+//! [40]
+queue.remove();
+//! [40]
+
+
+//! [41]
+delete queue.dequeue();
+//! [41]
+
+
+//! [42]
+queue.clear();
+//! [42]
+
+
+//! [43]
+while (!queue.isEmpty())
+ delete queue.dequeue();
+//! [43]
+
+
+//! [44]
+qDeleteAll(queue);
+queue.clear();
+//! [44]
+
+
+//! [45]
+stack.pop();
+//! [45]
+
+
+//! [46]
+delete stack.pop();
+//! [46]
+
+
+//! [47]
+stack.remove();
+//! [47]
+
+
+//! [48]
+delete stack.pop();
+//! [48]
+
+
+//! [49]
+stack.clear();
+//! [49]
+
+
+//! [50]
+while (!stack.isEmpty())
+ delete stack.pop();
+//! [50]
+
+
+//! [51]
+qDeleteAll(stack);
+stack.clear();
+//! [51]
+
+
+//! [52]
+vect.insert(i, ptr);
+//! [52]
+
+
+//! [53]
+delete vect[i];
+vect[i] = ptr;
+//! [53]
+
+
+//! [54]
+vect.remove(i);
+//! [54]
+
+
+//! [55]
+delete vect[i];
+vect[i] = 0;
+//! [55]
+
+
+//! [56]
+T *ptr = vect.take(i);
+//! [56]
+
+
+//! [57]
+T *ptr = vect[i];
+vect[i] = 0;
+//! [57]
+
+
+//! [58]
+vect.resize(n)
+//! [58]
+
+
+//! [59]
+while (n > vect.size())
+ vect.append(0);
+while (n < vect.size() {
+ T *ptr = vect.last();
+ vect.remove(vect.size() - 1);
+ delete ptr;
+}
+//! [59]
+
+
+//! [60]
+vect.clear();
+//! [60]
+
+
+//! [61]
+for (int i = 0; i < vect.size(); ++i)
+ T *ptr = vect[i];
+ vect[i] = 0;
+ delete ptr;
+}
+//! [61]
+
+
+//! [62]
+qDeleteAll(vect);
+vect.clear();
+//! [62]
+
+
+//! [63]
+struct Shared
+{
+ Shared() : count(1) {}
+ void ref() { ++count; }
+ bool deref() { return !--count; }
+ uint count;
+};
+//! [63]
+
+//! [63a]
+// Declare the object
+QSimpleRichText richText(text, font);
+
+// Set the width of the paragraph to w
+richText.setWidth(w);
+
+// Or set a reasonable default size
+richText.adjustSize();
+
+// Query for its used size
+int width = richText.widthUsed();
+int height = richText.height();
+
+// Draw
+richText.draw(painter, x, y, clipRect, colorGroup);
+//! [63a]
+
+
+//! [63b]
+// Declare the object
+QTextDocument doc;
+
+// If text is rich text, use setHtml()
+doc.setHtml(text);
+
+// Otherwise, use setPlainText()
+doc.setPlainText(text);
+
+// Set the width of the paragraph of text to w
+doc.setTextWidth(w);
+
+// Query for the used size
+int width = doc.idealWidth();
+int height = doc.size().height();
+
+// Draw
+painter.translate(x, y);
+doc.drawContents(painter, clipRect);
+
+// If you have a palette/colorgroup you can draw using lower-level functions:
+QAbstractTextDocumentLayout::PaintContext context;
+context.palette = myPalette;
+doc.documentLayout()->draw(painter, context);
+//! [63b]
+
+//! [63c]
+QSlider *slider;
+slider->style()->subControlRect(CC_Slider, sliderOption, SC_SliderHandle, slider);
+//! [63c]
+
+//! [64]
+QString greeting = "Hello";
+const char *badData = greeting.toAscii().constData(); // data is invalid
+QByteArray asciiData = greeting.toAscii();
+const char *goodData = asciiData.constData();
+//! [64]
+
+
+//! [65]
+str.at(0) = 'X';
+//! [65]
+
+
+//! [66]
+str[0] = 'X';
+//! [66]
diff --git a/doc/src/snippets/code/doc_src_q3asciidict.cpp b/doc/src/snippets/code/doc_src_q3asciidict.cpp
new file mode 100644
index 0000000..4b32817
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_q3asciidict.cpp
@@ -0,0 +1,92 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+Q3AsciiDict<QLineEdit> fields; // char* keys, QLineEdit* values
+fields.insert( "forename", new QLineEdit( this ) );
+fields.insert( "surname", new QLineEdit( this ) );
+
+fields["forename"]->setText( "Homer" );
+fields["surname"]->setText( "Simpson" );
+
+Q3AsciiDictIterator<QLineEdit> it( fields ); // See Q3AsciiDictIterator
+for( ; it.current(); ++it )
+ cout << it.currentKey() << ": " << it.current()->text() << endl;
+cout << endl;
+
+if ( fields["forename"] && fields["surname"] )
+ cout << fields["forename"]->text() << " "
+ << fields["surname"]->text() << endl; // Prints "Homer Simpson"
+
+fields.remove( "forename" ); // Does not delete the line edit
+if ( ! fields["forename"] )
+ cout << "forename is not in the dictionary" << endl;
+//! [0]
+
+
+//! [1]
+Q3AsciiDict<char> dict;
+ ...
+if ( dict.find(key) )
+ dict.remove( key );
+dict.insert( key, item );
+//! [1]
+
+
+//! [2]
+Q3AsciiDict<QLineEdit> fields;
+fields.insert( "forename", new QLineEdit( this ) );
+fields.insert( "surname", new QLineEdit( this ) );
+fields.insert( "age", new QLineEdit( this ) );
+
+fields["forename"]->setText( "Homer" );
+fields["surname"]->setText( "Simpson" );
+fields["age"]->setText( "45" );
+
+Q3AsciiDictIterator<QLineEdit> it( fields );
+for( ; it.current(); ++it )
+ cout << it.currentKey() << ": " << it.current()->text() << endl;
+cout << endl;
+
+// Output (random order):
+// age: 45
+// surname: Simpson
+// forename: Homer
+//! [2]
diff --git a/doc/src/snippets/code/doc_src_q3dict.cpp b/doc/src/snippets/code/doc_src_q3dict.cpp
new file mode 100644
index 0000000..9c51cae
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_q3dict.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+Q3Dict<char> dict;
+ ...
+if ( dict.find( key ) )
+ dict.remove( key );
+dict.insert( key, item );
+//! [0]
+
+
+//! [1]
+Q3Dict<QLineEdit> fields;
+fields.insert( "forename", new QLineEdit( this ) );
+fields.insert( "surname", new QLineEdit( this ) );
+fields.insert( "age", new QLineEdit( this ) );
+
+fields["forename"]->setText( "Homer" );
+fields["surname"]->setText( "Simpson" );
+fields["age"]->setText( "45" );
+
+Q3DictIterator<QLineEdit> it( fields );
+for( ; it.current(); ++it )
+ cout << it.currentKey() << ": " << it.current()->text() << endl;
+cout << endl;
+
+// Output (random order):
+// age: 45
+// surname: Simpson
+// forename: Homer
+//! [1]
diff --git a/doc/src/snippets/code/doc_src_q3intdict.cpp b/doc/src/snippets/code/doc_src_q3intdict.cpp
new file mode 100644
index 0000000..0f15b6f
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_q3intdict.cpp
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+Q3IntDict<QLineEdit> fields; // long int keys, QLineEdit* values
+for ( int i = 0; i < 3; i++ )
+ fields.insert( i, new QLineEdit( this ) );
+
+fields[0]->setText( "Homer" );
+fields[1]->setText( "Simpson" );
+fields[2]->setText( "45" );
+
+Q3IntDictIterator<QLineEdit> it( fields );
+for ( ; it.current(); ++it )
+ cout << it.currentKey() << ": " << it.current()->text() << endl;
+
+for ( int i = 0; i < 3; i++ )
+ cout << fields[i]->text() << " "; // Prints "Homer Simpson 45"
+cout << endl;
+
+fields.remove( 1 ); // Does not delete the line edit
+for ( int i = 0; i < 3; i++ )
+ if ( fields[i] )
+ cout << fields[i]->text() << " "; // Prints "Homer 45"
+//! [0]
+
+
+//! [1]
+Q3IntDict<char> dict;
+// ...
+if ( dict.find(key) )
+ dict.remove( key );
+dict.insert( key, item );
+//! [1]
+
+
+//! [2]
+Q3IntDict<QLineEdit> fields;
+for ( int i = 0; i < 3; i++ )
+ fields.insert( i, new QLineEdit( this ) );
+
+fields[0]->setText( "Homer" );
+fields[1]->setText( "Simpson" );
+fields[2]->setText( "45" );
+
+Q3IntDictIterator<QLineEdit> it( fields );
+for ( ; it.current(); ++it )
+ cout << it.currentKey() << ": " << it.current()->text() << endl;
+
+// Output (random order):
+// 0: Homer
+// 1: Simpson
+// 2: 45
+//! [2]
diff --git a/doc/src/snippets/code/doc_src_q3memarray.cpp b/doc/src/snippets/code/doc_src_q3memarray.cpp
new file mode 100644
index 0000000..2c91050
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_q3memarray.cpp
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+#include <q3memarray.h>
+#include <stdio.h>
+
+Q3MemArray<int> fib( int num ) // returns fibonacci array
+{
+ Q_ASSERT( num > 2 );
+ Q3MemArray<int> f( num ); // array of ints
+
+ f[0] = f[1] = 1;
+ for ( int i = 2; i < num; i++ )
+ f[i] = f[i-1] + f[i-2];
+
+ return f;
+}
+
+int main()
+{
+ Q3MemArray<int> a = fib( 6 ); // get first 6 fibonaccis
+ for ( int i = 0; i < a.size(); i++ )
+ qDebug( "%d: %d", i, a[i] );
+
+ qDebug( "1 is found %d times", a.contains(1) );
+ qDebug( "5 is found at index %d", a.find(5) );
+
+ return 0;
+}
+//! [0]
+
+
+//! [2]
+// MyStruct may be padded to 4 or 8 bytes
+struct MyStruct
+{
+ short i; // 2 bytes
+ char c; // 1 byte
+};
+
+Q3MemArray<MyStruct> a(1);
+a[0].i = 5;
+a[0].c = 't';
+
+MyStruct x;
+x.i = '5';
+x.c = 't';
+int i = a.find( x ); // may return -1 if the pad bytes differ
+//! [2]
+
+
+//! [3]
+static char bindata[] = { 231, 1, 44, ... };
+QByteArray a;
+a.setRawData( bindata, sizeof(bindata) ); // a points to bindata
+QDataStream s( a, IO_ReadOnly ); // open on a's data
+s >> <something>; // read raw bindata
+a.resetRawData( bindata, sizeof(bindata) ); // finished
+//! [3]
+
+
+//! [4]
+static char bindata[] = { 231, 1, 44, ... };
+QByteArray a, b;
+a.setRawData( bindata, sizeof(bindata) ); // a points to bindata
+a.resize( 8 ); // will crash
+b = a; // will crash
+a[2] = 123; // might crash
+// forget to resetRawData: will crash
+//! [4]
diff --git a/doc/src/snippets/code/doc_src_q3memarray.qdoc b/doc/src/snippets/code/doc_src_q3memarray.qdoc
new file mode 100644
index 0000000..a966e50
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_q3memarray.qdoc
@@ -0,0 +1,50 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [1]
+0: 1
+1: 1
+2: 2
+3: 3
+4: 5
+5: 8
+1 is found 2 times
+5 is found at index 4
+//! [1]
diff --git a/doc/src/snippets/code/doc_src_q3ptrdict.cpp b/doc/src/snippets/code/doc_src_q3ptrdict.cpp
new file mode 100644
index 0000000..e64d874
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_q3ptrdict.cpp
@@ -0,0 +1,106 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+Q3PtrDict<char> fields; // void* keys, char* values
+
+QLineEdit *le1 = new QLineEdit( this );
+le1->setText( "Simpson" );
+QLineEdit *le2 = new QLineEdit( this );
+le2->setText( "Homer" );
+QLineEdit *le3 = new QLineEdit( this );
+le3->setText( "45" );
+
+fields.insert( le1, "Surname" );
+fields.insert( le2, "Forename" );
+fields.insert( le3, "Age" );
+
+Q3PtrDictIterator<char> it( fields );
+for( ; it.current(); ++it )
+ cout << it.current() << endl;
+cout << endl;
+
+if ( fields[le1] ) // Prints "Surname: Simpson"
+ cout << fields[le1] << ": " << le1->text() << endl;
+if ( fields[le2] ) // Prints "Forename: Homer"
+ cout << fields[le2] << ": " << le2->text() << endl;
+
+fields.remove( le1 ); // Removes le1 from the dictionary
+cout << le1->text() << endl; // Prints "Simpson"
+//! [0]
+
+
+//! [1]
+Q3PtrDict<ItemType> dict;
+ ...
+if ( dict.find( key ) )
+ dict.remove( key );
+dict.insert( key, item );
+//! [1]
+
+
+//! [2]
+Q3PtrDict<char> fields;
+
+QLineEdit *le1 = new QLineEdit( this );
+le1->setText( "Simpson" );
+QLineEdit *le2 = new QLineEdit( this );
+le2->setText( "Homer" );
+QLineEdit *le3 = new QLineEdit( this );
+le3->setText( "45" );
+
+fields.insert( le1, "Surname" );
+fields.insert( le2, "Forename" );
+fields.insert( le3, "Age" );
+
+Q3PtrDictIterator<char> it( fields );
+for( ; it.current(); ++it ) {
+ QLineEdit *le = (QLineEdit)it.currentKey();
+ cout << it.current() << ": " << le->text() << endl;
+}
+cout << endl;
+
+// Output (random order):
+// Forename: Homer
+// Age: 45
+// Surname: Simpson
+//! [2]
+
+
diff --git a/doc/src/snippets/code/doc_src_q3ptrlist.cpp b/doc/src/snippets/code/doc_src_q3ptrlist.cpp
new file mode 100644
index 0000000..4f97c65
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_q3ptrlist.cpp
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+class Employee
+{
+public:
+ Employee() : sn( 0 ) { }
+ Employee( const QString& forename, const QString& surname, int salary )
+ : fn( forename ), sn( surname ), sal( salary )
+ { }
+
+ void setSalary( int salary ) { sal = salary; }
+
+ QString forename() const { return fn; }
+ QString surname() const { return sn; }
+ int salary() const { return sal; }
+
+private:
+ QString fn;
+ QString sn;
+ int sal;
+};
+
+Q3PtrList<Employee> list;
+list.setAutoDelete( TRUE ); // the list owns the objects
+
+list.append( new Employee("John", "Doe", 50000) );
+list.append( new Employee("Jane", "Williams", 80000) );
+list.append( new Employee("Tom", "Jones", 60000) );
+
+Employee *employee;
+for ( employee = list.first(); employee; employee = list.next() )
+ cout << employee->surname().latin1() << ", " <<
+ employee->forename().latin1() << " earns " <<
+ employee->salary() << endl;
+cout << endl;
+
+// very inefficient for big lists
+for ( uint i = 0; i < list.count(); ++i )
+ if ( list.at(i) )
+ cout << list.at( i )->surname().latin1() << endl;
+//! [0]
+
+
+//! [1]
+Doe, John earns 50000
+Williams, Jane earns 80000
+Jones, Tom earns 60000
+
+Doe
+Williams
+Jones
+//! [1]
+
+
+//! [2]
+if ( list.findRef( item ) != -1 )
+ list.remove();
+//! [2]
+
+
+//! [3]
+Q3PtrList<Employee> list;
+
+list.append( new Employee("John", "Doe", 50000) );
+list.append( new Employee("Jane", "Williams", 80000) );
+list.append( new Employee("Tom", "Jones", 60000) );
+
+Q3PtrListIterator<Employee> it( list );
+Employee *employee;
+while ( (employee = it.current()) != 0 ) {
+ ++it;
+ cout << employee->surname().latin1() << ", " <<
+ employee->forename().latin1() << " earns " <<
+ employee->salary() << endl;
+}
+//! [3]
+
+
+//! [4]
+Doe, John earns 50000
+Williams, Jane earns 80000
+Jones, Tom earns 60000
+//! [4]
diff --git a/doc/src/snippets/code/doc_src_q3valuelist.cpp b/doc/src/snippets/code/doc_src_q3valuelist.cpp
new file mode 100644
index 0000000..38ee9f6
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_q3valuelist.cpp
@@ -0,0 +1,135 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+class Employee
+{
+public:
+ Employee(): sn(0) {}
+ Employee( const QString& forename, const QString& surname, int salary )
+ : fn(forename), sn(surname), sal(salary)
+ {}
+
+ QString forename() const { return fn; }
+ QString surname() const { return sn; }
+ int salary() const { return sal; }
+ void setSalary( int salary ) { sal = salary; }
+
+private:
+ QString fn;
+ QString sn;
+ int sal;
+};
+
+typedef Q3ValueList<Employee> EmployeeList;
+EmployeeList list;
+
+list.append( Employee("John", "Doe", 50000) );
+list.append( Employee("Jane", "Williams", 80000) );
+list.append( Employee("Tom", "Jones", 60000) );
+
+Employee mary( "Mary", "Hawthorne", 90000 );
+list.append( mary );
+mary.setSalary( 100000 );
+
+EmployeeList::iterator it;
+for ( it = list.begin(); it != list.end(); ++it )
+ cout << (*it).surname().latin1() << ", " <<
+ (*it).forename().latin1() << " earns " <<
+ (*it).salary() << endl;
+
+// Output:
+// Doe, John earns 50000
+// Williams, Jane earns 80000
+// Hawthorne, Mary earns 90000
+// Jones, Tom earns 60000
+//! [0]
+
+
+//! [1]
+Q3ValueList<int> list;
+list.append( 1 );
+list.append( 2 );
+list.append( 3 );
+...
+if ( !list.empty() ) {
+ // OK, modify the first item
+ int& i = list.first();
+ i = 18;
+}
+...
+Q3ValueList<double> dlist;
+double d = dlist.last(); // undefined
+//! [1]
+
+
+//! [2]
+Q3ValueList<int> l;
+...
+Q3ValueList<int>::iterator it = l.end();
+--it;
+if ( it != end() )
+ // ...
+//! [2]
+
+
+//! [3]
+Q3ValueList<int> l;
+...
+Q3ValueList<int>::iterator it = l.end();
+--it;
+if ( it != end() )
+ // ...
+//! [3]
+
+
+//! [4]
+EmployeeList::iterator it;
+for ( it = list.begin(); it != list.end(); ++it )
+ cout << (*it).surname().latin1() << ", " <<
+ (*it).forename().latin1() << " earns " <<
+ (*it).salary() << endl;
+
+// Output:
+// Doe, John earns 50000
+// Williams, Jane earns 80000
+// Hawthorne, Mary earns 90000
+// Jones, Tom earns 60000
+//! [4]
diff --git a/doc/src/snippets/code/doc_src_q3valuestack.cpp b/doc/src/snippets/code/doc_src_q3valuestack.cpp
new file mode 100644
index 0000000..50827e6
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_q3valuestack.cpp
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+Q3ValueStack<int> stack;
+stack.push( 1 );
+stack.push( 2 );
+stack.push( 3 );
+while ( ! stack.isEmpty() )
+ cout << "Item: " << stack.pop() << endl;
+
+// Output:
+// Item: 3
+// Item: 2
+// Item: 1
+//! [0]
diff --git a/doc/src/snippets/code/doc_src_q3valuevector.cpp b/doc/src/snippets/code/doc_src_q3valuevector.cpp
new file mode 100644
index 0000000..8af1568
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_q3valuevector.cpp
@@ -0,0 +1,125 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+#include <qvaluevector.h>
+#include <qstring.h>
+#include <stdio.h>
+
+class Employee
+{
+public:
+ Employee(): s(0) {}
+ Employee( const QString& name, int salary )
+ : n( name ), s( salary )
+ { }
+
+ QString name() const { return n; }
+ int salary() const { return s; }
+ void setSalary( int salary ) { s = salary; }
+private:
+ QString n;
+ int s;
+};
+
+int main()
+{
+ typedef Q3ValueVector<Employee> EmployeeVector;
+ EmployeeVector vec( 3 ); // vector of 3 Employees
+
+ vec[0] = Employee( "Bill", 50000 );
+ vec[1] = Employee( "Steve", 80000 );
+ vec[2] = Employee( "Ron", 60000 );
+
+ Employee joe( "Joe", 50000 );
+ vec.push_back( joe ); // vector expands to accommodate 4 Employees
+ joe.setSalary( 70000 );
+
+ EmployeeVector::iterator it;
+ for( it = vec.begin(); it != vec.end(); ++it )
+ printf( "%s earns %d\n", (*it).name().latin1(), (*it).salary() );
+
+ return 0;
+}
+//! [0]
+
+
+//! [1]
+Bill earns 50000
+Steve earns 80000
+Ron earns 60000
+Joe earns 50000
+//! [1]
+
+
+//! [2]
+Q3ValueVector<int> vec1; // an empty vector
+vec1[10] = 4; // WARNING: undefined, probably a crash
+
+Q3ValueVector<QString> vec2(25); // initialize with 25 elements
+vec2[10] = "Dave"; // OK
+//! [2]
+
+
+//! [3]
+void func( Q3ValueVector<int>& vec )
+{
+ if ( vec.size() > 10 ) {
+ vec[9] = 99; // OK
+ }
+};
+//! [3]
+
+
+//! [4]
+Q3ValueVector<int> vec( 3 );
+vec.push_back( 1 );
+vec.push_back( 2 );
+vec.push_back( 3 );
+...
+if ( !vec.empty() ) {
+ // OK: modify the first element
+ int& i = vec.front();
+ i = 18;
+}
+...
+Q3ValueVector<double> dvec;
+double d = dvec.back(); // undefined behavior
+//! [4]
diff --git a/doc/src/snippets/code/doc_src_qt3to4.cpp b/doc/src/snippets/code/doc_src_qt3to4.cpp
new file mode 100644
index 0000000..d8eb5b4
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_qt3to4.cpp
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [2]
+using namespace Qt;
+//! [2]
diff --git a/doc/src/snippets/code/doc_src_qt3to4.qdoc b/doc/src/snippets/code/doc_src_qt3to4.qdoc
new file mode 100644
index 0000000..8ef0780
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_qt3to4.qdoc
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+qt3to4 myfile.cpp
+qt3to4 myapp.pro
+//! [0]
+
+
+//! [1]
+<Rules>
+ <Include>/path/to/q3porting.xml</Include>
+
+ <item Type="RenamedHeader" Disable="True" >
+ <Qt4>q3sqlselectcursor.h</Qt4>
+ <Qt3>qsqlselectcursor.h</Qt3>
+ </item>
+
+ <item Type="RenamedHeader" >
+ <Qt4>newclass.h</Qt4>
+ <Qt3>oldclass.h</Qt3>
+ </item>
+</Rules>
+//! [1]
+
+
+//! [2]
+using namespace Qt;
+//! [2]
diff --git a/doc/src/snippets/code/doc_src_qt4-accessibility.cpp b/doc/src/snippets/code/doc_src_qt4-accessibility.cpp
new file mode 100644
index 0000000..efbbc5a
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_qt4-accessibility.cpp
@@ -0,0 +1,99 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [environment]
+export QT_ACCESSIBILITY=1
+//! [environment]
+
+//! [0]
+class MyWidgetInterface : public QAccessibleWidget
+{
+public:
+ MyWidgetInterface(QWidget *widget, Role role);
+
+ QString text(Text text, int child) const;
+ State state(int child) const;
+ QString actionText(int action, Text text, int child) const;
+ bool doAction(int action, int child, const QVariantList &params);
+ ...
+};
+//! [0]
+
+
+//! [1]
+bool MyWidgetInterface::doAction(int action, int child,
+ const QVariantList &params)
+{
+ if (child || !widget()->isEnabled())
+ return false;
+
+ switch (action) {
+ case DefaultAction:
+ case Press:
+ {
+ MyWidget *widget = qobject_cast<MyWidget *>(object());
+ if (widget)
+ widget->click();
+ }
+ return true;
+ }
+ return QAccessibleWidget::doAction(action, child, params);
+}
+//! [1]
+
+
+//! [2]
+QStringList MyFactory::keys() const
+{
+ return QStringList() << "MyWidget" << "MyOtherWidget";
+}
+
+QAccessibleInterface *MyFactory::create(const QString &className,
+ QObject *object)
+{
+ if (classname == "MyWidget")
+ return new MyWidgetInterface(object);
+ if (classname == "MyOtherWidget")
+ return new MyOtherWidgetInterface(object);
+ return 0;
+}
+
+Q_EXPORT_PLUGIN2(myfactory, MyFactory)
+//! [2]
diff --git a/doc/src/snippets/code/doc_src_qt4-arthur.cpp b/doc/src/snippets/code/doc_src_qt4-arthur.cpp
new file mode 100644
index 0000000..6268309
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_qt4-arthur.cpp
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QLinearGradient gradient(0, 0, 100, 100);
+gradient.setColorAt(0, Qt::red);
+gradient.setColorAt(0.5, Qt::green);
+gradient.setColorAt(1, Qt::blue);
+painter.setBrush(gradient);
+painter.drawRect(0, 0, 100, 100);
+//! [0]
+
+
+//! [1]
+QRadialGradient gradient(50, 50, 50, 30, 30);
+gradient.setColorAt(0.2, Qt::white);
+gradient.setColorAt(0.8, Qt::green);
+gradient.setColorAt(1, Qt::black);
+painter.setBrush(gradient);
+painter.drawEllipse(0, 0, 100, 100);
+//! [1]
+
+
+//! [2]
+QConicalGradient gradient(60, 40, 0);
+gradient.setColorAt(0, Qt::black);
+gradient.setColorAt(0.4, Qt::green);
+gradient.setColorAt(0.6, Qt::white);
+gradient.setColorAt(1, Qt::black);
+painter.setBrush(gradient);
+painter.drawEllipse(0, 0, 100, 100);
+//! [2]
+
+
+//! [3]
+// Specfiy semi-transparent red
+painter.setBrush(QColor(255, 0, 0, 127));
+painter.drawRect(0, 0, width()/2, height());
+
+// Specify semi-transparend blue
+painter.setBrush(QColor(0, 0, 255, 127));
+painter.drawRect(0, 0, width(), height()/2);
+//! [3]
+
+
+//! [4]
+// One line without anti-aliasing
+painter.drawLine(0, 0, width()/2, height());
+
+// One line with anti-aliasing
+painter.setRenderHint(QPainter::Antialiasing);
+painter.drawLine(width()/2, 0, width()/2, height());
+//! [4]
+
+
+//! [5]
+QPainterPath path;
+path.addRect(20, 20, 60, 60);
+path.addBezier(0, 0, 99, 0, 50, 50, 99, 99);
+path.addBezier(99, 99, 0, 99, 50, 50, 0, 0);
+painter.drawPath(path);
+//! [5]
+
+
+//! [6]
+QPixmap buffer(size());
+QPainter painter(&buffer);
+
+// Paint code here
+
+painter.end();
+bitBlt(this, 0, 0, &buffer);
+//! [6]
+
+
+//! [7]
+QPainter painter(this);
+
+// Paint code here
+
+painter.end();
+//! [7]
+
+
+//! [8]
+unbufferedWidget->setAttribute(Qt::WA_PaintOnScreen);
+//! [8]
+
+
+//! [9]
+QLinearGradient gradient(0, 0, 100, 100);
+gradient.setColorAt(0, Qt::blue);
+gradient.setColorAt(1, Qt::red);
+painter.setPen(QPen(gradient, 0));
+for (int y=fontSize; y<100; y+=fontSize)
+ drawText(0, y, text);
+//! [9]
+
+
+//! [10]
+QImage image(100, 100, 32);
+QPainter painter(&image);
+
+// painter commands.
+
+painter.end();
+//! [10]
diff --git a/doc/src/snippets/code/doc_src_qt4-sql.cpp b/doc/src/snippets/code/doc_src_qt4-sql.cpp
new file mode 100644
index 0000000..cbcfb2d
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_qt4-sql.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QSqlQueryModel model;
+model.setQuery("select * from person");
+
+QTableView view;
+view.setModel(&model);
+view.show();
+//! [0]
+
+
+//! [1]
+QSqlTableModel model;
+model.setTable("person");
+model.select();
+
+QTableView view;
+view.setModel(&model);
+view.show();
+//! [1]
diff --git a/doc/src/snippets/code/doc_src_qt4-tulip.cpp b/doc/src/snippets/code/doc_src_qt4-tulip.cpp
new file mode 100644
index 0000000..83b1210
--- /dev/null
+++ b/doc/src/snippets/code/doc_src_qt4-tulip.cpp
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+foreach (variable, container)
+ statement;
+//! [0]
+
+
+//! [1]
+QList<QString> list;
+...
+foreach (const QString &str, list)
+ cout << str.ascii() << endl;
+//! [1]
+
+
+//! [2]
+QString str;
+foreach (str, list)
+ cout << str.ascii() << endl;
+//! [2]
+
+
+//! [3]
+// forward // backward
+QList<QString> list; QList<QString> list;
+... ...
+QListIterator<QString> i(list); QListIterator<QString> i(list);
+while (i.hasNext()) i.toBack();
+ cout << i.next().ascii() << endl; while (i.hasPrev())
+ cout << i.prev().ascii() << endl;
+//! [3]
+
+
+//! [4]
+// forward // backward
+QMutableListIterator<int> i(list); QMutableListIterator<int> i(list);
+while (i.hasNext()) i.toBack();
+ if (i.next() > 128) while (i.hasPrev())
+ i.setValue(128); if (i.prev() > 128)
+ i.setValue(128);
+//! [4]
+
+
+//! [5]
+// forward // backward
+QMutableListIterator<int> i(list); QMutableListIterator<int> i(list);
+while (i.hasNext()) i.toBack();
+ if (i.next() % 2 != 0) while (i.hasPrev())
+ i.remove(); if (i.prev() % 2 != 0)
+ i.remove();
+//! [5]
+
+
+//! [6]
+// STL-style // Java-style
+QMap<int, QWidget *>::const_iterator i; QMapIterator<int, QWidget *> i(map);
+for (i = map.begin(); i != map.end(); ++i) while (i.findNext(widget))
+ if (i.value() == widget) cout << "Found widget " << widget
+ cout << "Found widget " << widget << " under key "
+ << " under key " << i.key() << endl;
+ << i.key() << endl;
+//! [6]
+
+
+//! [7]
+// STL-style // Java-style
+QList<int>::iterator i = list.begin(); QMutableListIterator<int> i(list);
+while (i != list.end()) { while (i.hasNext()) {
+ if (*i == 0) { int val = i.next();
+ i = list.erase(i); if (val < 0)
+ } else { i.setValue(-val);
+ if (*i < 0) else if (val == 0)
+ *i = -*i; i.remove();
+ ++i; }
+ }
+}
+//! [7]
+
+
+//! [8]
+QList<double> list;
+...
+for (int i = 0; i < list.size(); ++i) {
+ if (list[i] < 0.0)
+ list[i] = 0.0;
+}
+//! [8]
+
+
+//! [9]
+QMap<QString, int> map;
+...
+map.value("TIMEOUT", 30); // returns 30 if "TIMEOUT" isn't in the map
+//! [9]
+
+
+//! [10]
+QMultiMap<QString, int> map;
+...
+QList<int> values = map.values("TIMEOUT");
+//! [10]
diff --git a/doc/src/snippets/code/src_qt3support_canvas_q3canvas.cpp b/doc/src/snippets/code/src_qt3support_canvas_q3canvas.cpp
new file mode 100644
index 0000000..5476f0a
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_canvas_q3canvas.cpp
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QPrinter pr;
+if (pr.setup()) {
+ QPainter p(&pr);
+ canvas.drawArea(canvas.rect(), &p);
+}
+//! [0]
+
+
+//! [1]
+void MyCanvasView::contentsMousePressEvent(QMouseEvent* e)
+{
+ Q3CanvasItemList l = canvas()->collisions(e->pos());
+ for (Q3CanvasItemList::Iterator it=l.begin(); it!=l.end(); ++it) {
+ if ((*it)->rtti() == Q3CanvasRectangle::RTTI)
+ qDebug("A Q3CanvasRectangle lies somewhere at this point");
+ }
+}
+//! [1]
+
+
+//! [2]
+QMatrix wm;
+wm.scale(2, 2); // Zooms in by 2 times
+wm.rotate(90); // Rotates 90 degrees counter clockwise
+ // around the origin.
+wm.translate(0, -canvas->height());
+ // moves the canvas down so what was visible
+ // before is still visible.
+myCanvasView->setWorldMatrix(wm);
+//! [2]
+
+
+//! [3]
+QRect rc = QRect(myCanvasView->contentsX(), myCanvasView->contentsY(),
+ myCanvasView->visibleWidth(), myCanvasView->visibleHeight());
+QRect canvasRect = myCanvasView->inverseWorldMatrix().mapRect(rc);
+//! [3]
+
+
+//! [4]
+Q3CanvasItem* item;
+// Find an item, e.g. with Q3CanvasItem::collisions().
+...
+if (item->rtti() == MySprite::RTTI) {
+ MySprite* s = (MySprite*)item;
+ if (s->isDamagable()) s->loseHitPoints(1000);
+ if (s->isHot()) myself->loseHitPoints(1000);
+ ...
+}
+//! [4]
diff --git a/doc/src/snippets/code/src_qt3support_dialogs_q3filedialog.cpp b/doc/src/snippets/code/src_qt3support_dialogs_q3filedialog.cpp
new file mode 100644
index 0000000..80b8eac
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_dialogs_q3filedialog.cpp
@@ -0,0 +1,269 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QString s = Q3FileDialog::getOpenFileName(
+ "/home",
+ "Images (*.png *.xpm *.jpg)",
+ this,
+ "open file dialog",
+ "Choose a file");
+//! [0]
+
+
+//! [1]
+"Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)"
+//! [1]
+
+
+//! [2]
+Q3FileDialog* fd = new Q3FileDialog(this, "file dialog", true);
+fd->setMode(Q3FileDialog::AnyFile);
+//! [2]
+
+
+//! [3]
+fd->setFilter("Images (*.png *.xpm *.jpg)");
+//! [3]
+
+
+//! [4]
+fd->setViewMode(Q3FileDialog::Detail);
+//! [4]
+
+
+//! [5]
+QString fileName;
+if (fd->exec() == QDialog::Accepted)
+ fileName = fd->selectedFile();
+//! [5]
+
+
+//! [6]
+class Preview : public QLabel, public Q3FilePreview
+{
+public:
+ Preview(QWidget *parent=0) : QLabel(parent) {}
+
+ void previewUrl(const Q3Url &u)
+ {
+ QString path = u.path();
+ QPixmap pix(path);
+ if (pix.isNull())
+ setText("This is not a pixmap");
+ else
+ setPixmap(pix);
+ }
+};
+//! [6]
+
+
+//! [7]
+Preview* p = new Preview;
+
+Q3FileDialog* fd = new Q3FileDialog(this);
+fd->setContentsPreviewEnabled(true);
+fd->setContentsPreview(p, p);
+fd->setPreviewMode(Q3FileDialog::Contents);
+fd->show();
+//! [7]
+
+
+//! [8]
+QStringList list = myFileDialog.selectedFiles();
+QStringList::Iterator it = list.begin();
+while(it != list.end()) {
+ myProcessing(*it);
+ ++it;
+}
+//! [8]
+
+
+//! [9]
+fd->setFilter("All C++ files (*.cpp *.cc *.C *.cxx *.c++)");
+fd->setFilter("*.cpp *.cc *.C *.cxx *.c++");
+fd->setFilter("All C++ files (*.cpp;*.cc;*.C;*.cxx;*.c++)");
+fd->setFilter("*.cpp;*.cc;*.C;*.cxx;*.c++");
+//! [9]
+
+
+//! [10]
+QString s = Q3FileDialog::getOpenFileName(
+ "/home",
+ "Images (*.png *.xpm *.jpg)",
+ this,
+ "open file dialog",
+ "Choose a file to open");
+//! [10]
+
+
+//! [11]
+QString s = Q3FileDialog::getSaveFileName(
+ "/home",
+ "Images (*.png *.xpm *.jpg)",
+ this,
+ "save file dialog",
+ "Choose a filename to save under");
+//! [11]
+
+
+//! [12]
+QString s = Q3FileDialog::getExistingDirectory(
+ "/home",
+ this,
+ "get existing directory",
+ "Choose a directory",
+ true);
+//! [12]
+
+
+//! [13]
+MyFileDialog::MyFileDialog(QWidget* parent, const char* name) :
+ Q3FileDialog(parent, name)
+{
+ QLabel* label = new QLabel("Added widgets", this);
+ QLineEdit* lineedit = new QLineEdit(this);
+ QPushButton* pushbutton = new QPushButton(this);
+
+ addWidgets(label, lineedit, pushbutton);
+}
+//! [13]
+
+
+//! [14]
+QString types("Image files (*.png *.xpm *.jpg);;"
+ "Text files (*.txt);;"
+ "Any files (*)");
+Q3FileDialog fd = new Q3FileDialog(this);
+fd->setFilters(types);
+fd->show();
+//! [14]
+
+
+//! [15]
+Q3FileDialog* fd = new Q3FileDialog(this);
+fd->addFilter("Images (*.png *.jpg *.xpm)");
+fd->show();
+//! [15]
+
+
+//! [16]
+QStringList files = Q3FileDialog::getOpenFileNames(
+ "Images (*.png *.xpm *.jpg)",
+ "/home",
+ this,
+ "open files dialog",
+ "Select one or more files to open");
+//! [16]
+
+
+//! [17]
+QStringList list = files;
+QStringList::Iterator it = list.begin();
+while(it != list.end()) {
+ myProcessing(*it);
+ ++it;
+}
+//! [17]
+
+
+//! [18]
+class Preview : public QLabel, public Q3FilePreview
+{
+public:
+ Preview(QWidget *parent=0) : QLabel(parent) {}
+
+ void previewUrl(const Q3Url &u)
+ {
+ QString path = u.path();
+ QPixmap pix(path);
+ if (pix.isNull())
+ setText("This is not a pixmap");
+ else
+ setText("This is a pixmap");
+ }
+};
+
+//...
+
+int main(int argc, char** argv)
+{
+ Preview* p = new Preview;
+
+ Q3FileDialog* fd = new Q3FileDialog(this);
+ fd->setInfoPreviewEnabled(true);
+ fd->setInfoPreview(p, p);
+ fd->setPreviewMode(Q3FileDialog::Info);
+ fd->show();
+}
+
+//! [18]
+
+
+//! [19]
+class Preview : public QLabel, public Q3FilePreview
+{
+public:
+ Preview(QWidget *parent=0) : QLabel(parent) {}
+
+ void previewUrl(const Q3Url &u)
+ {
+ QString path = u.path();
+ QPixmap pix(path);
+ if (pix.isNull())
+ setText("This is not a pixmap");
+ else
+ setPixmap(pix);
+ }
+};
+
+//...
+
+int main(int argc, char** argv)
+{
+ Preview* p = new Preview;
+
+ Q3FileDialog* fd = new Q3FileDialog(this);
+ fd->setContentsPreviewEnabled(true);
+ fd->setContentsPreview(p, p);
+ fd->setPreviewMode(Q3FileDialog::Contents);
+ fd->show();
+}
+//! [19]
diff --git a/doc/src/snippets/code/src_qt3support_dialogs_q3progressdialog.cpp b/doc/src/snippets/code/src_qt3support_dialogs_q3progressdialog.cpp
new file mode 100644
index 0000000..c7022a0
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_dialogs_q3progressdialog.cpp
@@ -0,0 +1,81 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+Q3ProgressDialog progress("Copying files...", "Abort Copy", numFiles,
+ this, "progress", true);
+for (int i = 0; i < numFiles; i++) {
+ progress.setProgress(i);
+ qApp->processEvents();
+
+ if (progress.wasCanceled())
+ break;
+ //... copy one file
+}
+progress.setProgress(numFiles);
+//! [0]
+
+
+//! [1]
+Operation::Operation(QObject *parent = 0)
+ : QObject(parent), steps(0)
+{
+ pd = new Q3ProgressDialog("Operation in progress.", "Cancel", 100);
+ connect(pd, SIGNAL(canceled()), this, SLOT(cancel()));
+ t = new QTimer(this);
+ connect(t, SIGNAL(timeout()), this, SLOT(perform()));
+ t->start(0);
+}
+
+void Operation::perform()
+{
+ pd->setProgress(steps);
+ //... perform one percent of the operation
+ steps++;
+ if (steps > pd->totalSteps())
+ t->stop();
+}
+
+void Operation::cancel()
+{
+ t->stop();
+ //... cleanup
+}
+//! [1]
diff --git a/doc/src/snippets/code/src_qt3support_itemviews_q3iconview.cpp b/doc/src/snippets/code/src_qt3support_itemviews_q3iconview.cpp
new file mode 100644
index 0000000..d4e1cb1
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_itemviews_q3iconview.cpp
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+(void) new Q3IconViewItem(
+ iconView, // A pointer to a Q3IconView
+ "This is the text of the item",
+ aPixmap);
+//! [0]
+
+
+//! [1]
+Q3IconViewItem *item;
+for (item = iconView->firstItem(); item; item = item->nextItem())
+ do_something_with(item);
+//! [1]
+
+
+//! [2]
+Q3IconViewItem *item;
+for (item = iconView->firstItem(); item; item = item->nextItem())
+ do_something_with(item);
+//! [2]
+
+
+//! [3]
+int MyIconViewItem::compare(Q3IconViewItem *i) const
+{
+ return key().compare(i->key());
+}
+//! [3]
+
+
+//! [4]
+Q3IconView *iv = new Q3IconView(this);
+QDir dir(path, "*.xpm");
+for (uint i = 0; i < dir.count(); i++) {
+ (void) new Q3IconViewItem(iv, dir[i], QPixmap(path + dir[i]));
+}
+iv->resize(600, 400);
+iv->show();
+//! [4]
+
+
+//! [5]
+for (Q3IconViewItem *item = iv->firstItem(); item; item = item->nextItem())
+ do_something(item);
+//! [5]
+
+
+//! [6]
+Q3DragObject *MyIconView::dragObject()
+{
+ return new Q3TextDrag(currentItem()->text(), this);
+}
+//! [6]
+
+
+//! [7]
+bool MyIconViewItem::acceptDrop(const QMimeSource *mime) const
+{
+ if (mime->provides("text/plain"))
+ return true;
+ return false;
+}
+
+void MyIconViewItem::dropped(QDropEvent *evt, const Q3ValueList<Q3IconDragItem>&)
+{
+ QString label;
+ if (Q3TextDrag::decode(evt, label))
+ setText(label);
+}
+//! [7]
+
+
+//! [8]
+(void) new Q3IconViewItem(myIconview, "The text of the item", aPixmap);
+//! [8]
diff --git a/doc/src/snippets/code/src_qt3support_itemviews_q3listview.cpp b/doc/src/snippets/code/src_qt3support_itemviews_q3listview.cpp
new file mode 100644
index 0000000..07559cc
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_itemviews_q3listview.cpp
@@ -0,0 +1,113 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+(void) new Q3ListViewItem(listView, "Column 1", "Column 2");
+(void) new Q3ListViewItem(listView->firstChild(), "A", "B", "C");
+//! [0]
+
+
+//! [1]
+Q3ListViewItem * myChild = myItem->firstChild();
+while(myChild) {
+ doSomething(myChild);
+ myChild = myChild->nextSibling();
+}
+//! [1]
+
+
+//! [2]
+Q3ListViewItemIterator it(listview);
+while (it.current()) {
+ Q3ListViewItem *item = it.current();
+ doSomething(item);
+ ++it;
+}
+//! [2]
+
+
+//! [3]
+int MyListViewItem::compare(Q3ListViewItem *i, int col,
+ bool ascending) const
+{
+ return key(col, ascending).compare(i->key(col, ascending));
+}
+//! [3]
+
+
+//! [4]
+Q3ListViewItem *i = itemAt(p);
+if (i) {
+ if (p.x() > header()->sectionPos(header()->mapToIndex(0)) +
+ treeStepSize() * (i->depth() + (rootIsDecorated() ? 1 : 0)) + itemMargin() ||
+ p.x() < header()->sectionPos(header()->mapToIndex(0))) {
+ ; // p is not on root decoration
+ else
+ ; // p is on the root decoration
+}
+//! [4]
+
+
+//! [5]
+QRect r(listView->itemRect(item));
+r.setHeight(qMin(item->totalHeight(),
+ listView->viewport->height() - r.y()))
+//! [5]
+
+
+//! [6]
+QList<Q3ListViewItem *> lst;
+Q3ListViewItemIterator it(myListView);
+while (it.current()) {
+ if (it.current()->isSelected())
+ lst.append(it.current());
+ ++it;
+}
+//! [6]
+
+
+//! [7]
+QList<Q3ListViewItem *> lst;
+Q3ListViewItemIterator it(myListView, Selected);
+while (it.current()) {
+ lst.append(it.current());
+ ++it;
+}
+//! [7]
diff --git a/doc/src/snippets/code/src_qt3support_itemviews_q3table.cpp b/doc/src/snippets/code/src_qt3support_itemviews_q3table.cpp
new file mode 100644
index 0000000..1c7bba0
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_itemviews_q3table.cpp
@@ -0,0 +1,97 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+void wrapInFunction()
+{
+
+//! [0]
+for (int row = 0; row < table->numRows(); row++) {
+ for (int col = 0; col < table->numCols(); col++) {
+ table->setItem(row, col,
+ new Q3TableItem(table, Q3TableItem::WhenCurrent, QString::number(row * col)));
+ }
+}
+//! [0]
+
+
+//! [1]
+QWidget* MyTableItem::createEditor() const
+{
+ QHBox* hbox = new QHBox(table()->viewport());
+ hbox->setFocusProxy(new QLineEdit(hbox));
+ new QLineEdit(hbox);
+ return hbox;
+}
+//! [1]
+
+
+//! [2]
+p->setClipRect(table()->cellRect(row, col), QPainter::ClipPainter);
+//... your drawing code
+p->setClipping(false);
+//! [2]
+
+
+//! [3]
+Q3Table *table = new Q3Table(100, 250, this);
+table->setPixmap(3, 2, pix);
+table->setText(3, 2, "A pixmap");
+//! [3]
+
+
+//! [4]
+p->setClipRect(cellRect(row, col), QPainter::CoordPainter);
+//... your drawing code
+p->setClipping(false);
+//! [4]
+
+
+//! [5]
+Q3TableItem *i = item(row, col);
+if (initFromCell || (i && !i->isReplaceable()))
+ // If we had a Q3TableItem ask the base class to create the editor
+ return Q3Table::createEditor(row, col, initFromCell);
+else
+ return ...(create your own editor)
+//! [5]
+
+}
+
diff --git a/doc/src/snippets/code/src_qt3support_network_q3dns.cpp b/doc/src/snippets/code/src_qt3support_network_q3dns.cpp
new file mode 100644
index 0000000..6464a1d
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_network_q3dns.cpp
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QStringList list = myDns.qualifiedNames();
+QStringList::Iterator it = list.begin();
+while( it != list.end() ) {
+ myProcessing( *it );
+ ++it;
+}
+//! [0]
+
+
+//! [1]
+Q3ValueList<QHostAddress> list = myDns.addresses();
+Q3ValueList<QHostAddress>::Iterator it = list.begin();
+while( it != list.end() ) {
+ myProcessing( *it );
+ ++it;
+}
+//! [1]
+
+
+//! [2]
+Q3ValueList<Q3Dns::MailServer> list = myDns.mailServers();
+Q3ValueList<Q3Dns::MailServer>::Iterator it = list.begin();
+while( it != list.end() ) {
+ myProcessing( *it );
+ ++it;
+}
+//! [2]
+
+
+//! [3]
+Q3ValueList<Q3Dns::Server> list = myDns.servers();
+Q3ValueList<Q3Dns::Server>::Iterator it = list.begin();
+while( it != list.end() ) {
+ myProcessing( *it );
+ ++it;
+}
+//! [3]
+
+
+//! [4]
+QStringList list = myDns.hostNames();
+QStringList::Iterator it = list.begin();
+while( it != list.end() ) {
+ myProcessing( *it );
+ ++it;
+}
+//! [4]
+
+
+//! [5]
+QStringList list = myDns.texts();
+QStringList::Iterator it = list.begin();
+while( it != list.end() ) {
+ myProcessing( *it );
+ ++it;
+}
+//! [5]
diff --git a/doc/src/snippets/code/src_qt3support_network_q3ftp.cpp b/doc/src/snippets/code/src_qt3support_network_q3ftp.cpp
new file mode 100644
index 0000000..552ffcc
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_network_q3ftp.cpp
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QUrlOperator op( "ftp://ftp.qt.nokia.com" );
+op.listChildren(); // Asks the server to provide a directory listing
+//! [0]
+
+
+//! [1]
+Q3Ftp *ftp = new Q3Ftp( this ); // this is an optional QObject parent
+ftp->connectToHost( "ftp.qt.nokia.com" );
+ftp->login();
+//! [1]
+
+
+//! [2]
+ftp->connectToHost( "ftp.qt.nokia.com" ); // id == 1
+ftp->login(); // id == 2
+ftp->cd( "qt" ); // id == 3
+ftp->get( "INSTALL" ); // id == 4
+ftp->close(); // id == 5
+//! [2]
+
+
+//! [3]
+start( 1 )
+stateChanged( HostLookup )
+stateChanged( Connecting )
+stateChanged( Connected )
+finished( 1, false )
+
+start( 2 )
+stateChanged( LoggedIn )
+finished( 2, false )
+
+start( 3 )
+finished( 3, false )
+
+start( 4 )
+dataTransferProgress( 0, 3798 )
+dataTransferProgress( 2896, 3798 )
+readyRead()
+dataTransferProgress( 3798, 3798 )
+readyRead()
+finished( 4, false )
+
+start( 5 )
+stateChanged( Closing )
+stateChanged( Unconnected )
+finished( 5, false )
+
+done( false )
+//! [3]
+
+
+//! [4]
+start( 1 )
+stateChanged( HostLookup )
+stateChanged( Connecting )
+stateChanged( Connected )
+finished( 1, false )
+
+start( 2 )
+finished( 2, true )
+
+done( true )
+//! [4]
diff --git a/doc/src/snippets/code/src_qt3support_network_q3http.cpp b/doc/src/snippets/code/src_qt3support_network_q3http.cpp
new file mode 100644
index 0000000..0ddc18f
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_network_q3http.cpp
@@ -0,0 +1,114 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+content-type: text/html
+//! [0]
+
+
+//! [1]
+header.setValue( "content-type", "text/html" );
+QString contentType = header.value( "content-type" );
+//! [1]
+
+
+//! [2]
+QUrlOperator op( "http://qt.nokia.com" );
+op.get( "index.html" );
+//! [2]
+
+
+//! [3]
+Q3HttpRequestHeader header( "GET", "/index.html" );
+header.setValue( "Host", "qt.nokia.com" );
+http->setHost( "qt.nokia.com" );
+http->request( header );
+//! [3]
+
+
+//! [4]
+http->setHost( "qt.nokia.com" ); // id == 1
+http->get( "/index.html" ); // id == 2
+//! [4]
+
+
+//! [5]
+requestStarted( 1 )
+requestFinished( 1, false )
+
+requestStarted( 2 )
+stateChanged( Connecting )
+stateChanged( Sending )
+dataSendProgress( 77, 77 )
+stateChanged( Reading )
+responseHeaderReceived( responseheader )
+dataReadProgress( 5388, 0 )
+readyRead( responseheader )
+dataReadProgress( 18300, 0 )
+readyRead( responseheader )
+stateChanged( Connected )
+requestFinished( 2, false )
+
+done( false )
+
+stateChanged( Closing )
+stateChanged( Unconnected )
+//! [5]
+
+
+//! [6]
+http->setHost( "www.foo.bar" ); // id == 1
+http->get( "/index.html" ); // id == 2
+http->post( "register.html", data ); // id == 3
+//! [6]
+
+
+//! [7]
+requestStarted( 1 )
+requestFinished( 1, false )
+
+requestStarted( 2 )
+stateChanged( HostLookup )
+requestFinished( 2, true )
+
+done( true )
+
+stateChanged( Unconnected )
+//! [7]
diff --git a/doc/src/snippets/code/src_qt3support_network_q3localfs.cpp b/doc/src/snippets/code/src_qt3support_network_q3localfs.cpp
new file mode 100644
index 0000000..ba9e0f4
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_network_q3localfs.cpp
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+Q3UrlOperator op( "file:///tmp" );
+op.listChildren(); // Asks the server to provide a directory listing
+//! [0]
diff --git a/doc/src/snippets/code/src_qt3support_network_q3networkprotocol.cpp b/doc/src/snippets/code/src_qt3support_network_q3networkprotocol.cpp
new file mode 100644
index 0000000..219a75c
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_network_q3networkprotocol.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+Q3NetworkProtocol::registerNetworkProtocol( "nntp", new Q3NetworkProtocolFactory<Nntp> );
+//! [0]
+
+
+//! [1]
+Q3Ftp *ftp = Q3NetworkProtocol::getNetworkProtocol( "ftp" );
+//! [1]
diff --git a/doc/src/snippets/code/src_qt3support_network_q3socket.cpp b/doc/src/snippets/code/src_qt3support_network_q3socket.cpp
new file mode 100644
index 0000000..4fdda94
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_network_q3socket.cpp
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+while( !socket->canReadLine() ) // WRONG
+ ;
+//! [0]
diff --git a/doc/src/snippets/code/src_qt3support_network_q3socketdevice.cpp b/doc/src/snippets/code/src_qt3support_network_q3socketdevice.cpp
new file mode 100644
index 0000000..7f2c905
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_network_q3socketdevice.cpp
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+::close( sd->socket() );
+sd->writeBlock( someData, 42 );
+//! [0]
diff --git a/doc/src/snippets/code/src_qt3support_network_q3url.cpp b/doc/src/snippets/code/src_qt3support_network_q3url.cpp
new file mode 100644
index 0000000..6365fe5
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_network_q3url.cpp
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+Q3Url url( "http://qt.nokia.com" );
+// or
+Q3Url url( "file:///home/myself/Mail", "Inbox" );
+//! [0]
+
+
+//! [1]
+Q3Url url( "http://qt.nokia.com" );
+QString s = url;
+// or
+QString s( "http://qt.nokia.com" );
+Q3Url url( s );
+//! [1]
+
+
+//! [2]
+Q3Url url( "ftp://ftp.qt.nokia.com/qt/source", "qt-2.1.0.tar.gz" );
+//! [2]
+
+
+//! [3]
+Q3Url url( "ftp://ftp.qt.nokia.com/qt/source", "/usr/local" );
+//! [3]
+
+
+//! [4]
+Q3Url url( "ftp://ftp.qt.nokia.com/qt/source", "file:///usr/local" );
+//! [4]
+
+
+//! [5]
+QString url = http://qt.nokia.com
+Q3Url::encode( url );
+// url is now "http%3A//qt%20nokia%20com"
+//! [5]
+
+
+//! [6]
+QString url = "http%3A//qt%20nokia%20com"
+Q3Url::decode( url );
+// url is now "http://qt.nokia.com"
+//! [6]
diff --git a/doc/src/snippets/code/src_qt3support_network_q3urloperator.cpp b/doc/src/snippets/code/src_qt3support_network_q3urloperator.cpp
new file mode 100644
index 0000000..12d40a6
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_network_q3urloperator.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+Q3UrlOperator *op = new Q3UrlOperator();
+op->copy( QString("ftp://ftp.qt.nokia.com/qt/source/qt-2.1.0.tar.gz"),
+ "file:///tmp" );
+//! [0]
+
+
+//! [1]
+Q3UrlOperator op( "http://www.whatever.org/cgi-bin/search.pl?cmd=Hello" );
+op.get();
+//! [1]
+
+
+//! [2]
+Q3UrlOperator op( "ftp://ftp.whatever.org/pub" );
+// do some other stuff like op.listChildren() or op.mkdir( "new_dir" )
+op.get( "a_file.txt" );
+//! [2]
+
+
+//! [3]
+Q3UrlOperator op( "http://www.whatever.org/cgi-bin" );
+op.get( "search.pl?cmd=Hello" ); // WRONG!
+//! [3]
+
+
+//! [4]
+Q3UrlOperator op( "ftp://ftp.whatever.com/home/me/filename.dat" );
+op.put( data );
+//! [4]
+
+
+//! [5]
+Q3UrlOperator op( "ftp://ftp.whatever.com/home/me" );
+// do some other stuff like op.listChildren() or op.mkdir( "new_dir" )
+op.put( data, "filename.dat" );
+//! [5]
diff --git a/doc/src/snippets/code/src_qt3support_other_q3accel.cpp b/doc/src/snippets/code/src_qt3support_other_q3accel.cpp
new file mode 100644
index 0000000..4bbd401
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_other_q3accel.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QPushButton p("&Exit", parent); // automatic shortcut Alt+E
+Q3PopupMenu *fileMenu = new fileMenu(parent);
+fileMenu->insertItem("Undo", parent, SLOT(undo()),
+ Qt::CTRL + Qt::Key_Z);
+//! [0]
+
+
+//! [1]
+accelerator->insertItem(QKeySequence("M"));
+//! [1]
+
+
+//! [2]
+Q3Accel *a = new Q3Accel(myWindow);
+a->connectItem(a->insertItem(Qt::CTRL + Qt::Key_P),
+ myWindow, SLOT(printDoc()));
+//! [2]
+
+
+//! [3]
+Q3Accel *a = new Q3Accel(myWindow); // create accels for myWindow
+a->insertItem(CTRL + Key_P, 200); // Ctrl+P, e.g. to print document
+a->insertItem(ALT + Key_X, 201); // Alt+X, e.g. to quit
+a->insertItem(UNICODE_ACCEL + 'q', 202); // Unicode 'q', e.g. to quit
+a->insertItem(Key_D); // gets a unique negative id < -1
+a->insertItem(CTRL + SHIFT + Key_P); // gets a unique negative id < -1
+//! [3]
+
+
+//! [4]
+a->connectItem(201, mainView, SLOT(quit()));
+//! [4]
+
+
+//! [5]
+Q3PopupMenu *file = new Q3PopupMenu(this);
+file->insertItem(p1, tr("&Open..."), this, SLOT(open()),
+ Q3Accel::stringToKey(tr("Ctrl+O", "File|Open")));
+//! [5]
diff --git a/doc/src/snippets/code/src_qt3support_other_q3mimefactory.cpp b/doc/src/snippets/code/src_qt3support_other_q3mimefactory.cpp
new file mode 100644
index 0000000..e2505f4
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_other_q3mimefactory.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+static const char* myimage_data[]={
+"...",
+...
+"..."};
+//! [0]
+
+
+//! [1]
+Q3MimeSourceFactory::defaultFactory()->setImage("myimage", QImage(myimage_data));
+//! [1]
+
+
+//! [2]
+QLabel* label = new QLabel(
+ "Rich text with embedded image:<img source=\"myimage\">"
+ "Isn't that <em>cute</em>?");
+//! [2]
+
+
+//! [3]
+delete label;
+Q3MimeSourceFactory::defaultFactory()->setData("myimage", 0);
+//! [3]
+
+
+//! [4]
+setExtensionType("html", "text/html;charset=iso8859-1");
+setExtensionType("htm", "text/html;charset=iso8859-1");
+setExtensionType("txt", "text/plain");
+setExtensionType("xml", "text/xml;charset=UTF-8");
+//! [4]
diff --git a/doc/src/snippets/code/src_qt3support_other_q3process.cpp b/doc/src/snippets/code/src_qt3support_other_q3process.cpp
new file mode 100644
index 0000000..fece6e3
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_other_q3process.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QStringList list = myProcess.arguments();
+QStringList::Iterator it = list.begin();
+while( it != list.end() ) {
+ myProcessing( *it );
+ ++it;
+}
+//! [0]
diff --git a/doc/src/snippets/code/src_qt3support_other_q3process_unix.cpp b/doc/src/snippets/code/src_qt3support_other_q3process_unix.cpp
new file mode 100644
index 0000000..cc5e977
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_other_q3process_unix.cpp
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+process->tryTerminate();
+QTimer::singleShot( 5000, process, SLOT(kill()) );
+//! [0]
diff --git a/doc/src/snippets/code/src_qt3support_painting_q3paintdevicemetrics.cpp b/doc/src/snippets/code/src_qt3support_painting_q3paintdevicemetrics.cpp
new file mode 100644
index 0000000..f89fb92
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_painting_q3paintdevicemetrics.cpp
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+Q3PaintDeviceMetrics pdm(myWidget);
+double aspect = (double)pdm.widthMM() / (double)pdm.heightMM();
+//! [0]
diff --git a/doc/src/snippets/code/src_qt3support_painting_q3painter.cpp b/doc/src/snippets/code/src_qt3support_painting_q3painter.cpp
new file mode 100644
index 0000000..352719e
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_painting_q3painter.cpp
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QPainter p(myWidget);
+p.drawArc(QRect(10,10, 70,100), 100*16, 160*16); // draws a "(" arc
+//! [0]
diff --git a/doc/src/snippets/code/src_qt3support_painting_q3picture.cpp b/doc/src/snippets/code/src_qt3support_painting_q3picture.cpp
new file mode 100644
index 0000000..8164a77
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_painting_q3picture.cpp
@@ -0,0 +1,54 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+Q3Picture picture;
+picture.load("drawing.svg", SVG);
+//! [0]
+
+
+//! [1]
+Q3Picture picture;
+QPainter painter;
+painter.begin(&picture); // paint in picture
+...
+painter.end(); // painting done
+picture.save("drawing.svg", SVG); // save picture
+//! [1]
diff --git a/doc/src/snippets/code/src_qt3support_sql_q3databrowser.cpp b/doc/src/snippets/code/src_qt3support_sql_q3databrowser.cpp
new file mode 100644
index 0000000..52557d4
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_sql_q3databrowser.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QStringList list = myDataBrowser.sort();
+QStringList::Iterator it = list.begin();
+while(it != list.end()) {
+ myProcessing(*it);
+ ++it;
+}
+//! [0]
diff --git a/doc/src/snippets/code/src_qt3support_sql_q3datatable.cpp b/doc/src/snippets/code/src_qt3support_sql_q3datatable.cpp
new file mode 100644
index 0000000..117fe27
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_sql_q3datatable.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QStringList list = myDataTable.sort();
+QStringList::Iterator it = list.begin();
+while( it != list.end() ) {
+ myProcessing( *it );
+ ++it;
+}
+//! [0]
diff --git a/doc/src/snippets/code/src_qt3support_sql_q3dataview.cpp b/doc/src/snippets/code/src_qt3support_sql_q3dataview.cpp
new file mode 100644
index 0000000..df95c9e
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_sql_q3dataview.cpp
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+myView.setRecord(record);
+myView.readFields();
+//! [0]
diff --git a/doc/src/snippets/code/src_qt3support_sql_q3sqlcursor.cpp b/doc/src/snippets/code/src_qt3support_sql_q3sqlcursor.cpp
new file mode 100644
index 0000000..e4a0c28
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_sql_q3sqlcursor.cpp
@@ -0,0 +1,140 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+Q3SqlCursor cur( "staff" ); // Specify the table/view name
+cur.select(); // We'll retrieve every record
+while ( cur.next() ) {
+ qDebug( cur.value( "id" ).toString() + ": " +
+ cur.value( "surname" ).toString() + ' ' +
+ cur.value( "salary" ).toString() );
+}
+//! [0]
+
+
+//! [1]
+Q3SqlCursor cur( "prices" );
+cur.select( "id=202" );
+if ( cur.next() ) {
+ QSqlRecord *buffer = cur.primeUpdate();
+ double price = buffer->value( "price" ).toDouble();
+ double newprice = price * 1.05;
+ buffer->setValue( "price", newprice );
+ cur.update();
+}
+//! [1]
+
+
+//! [2]
+Q3SqlCursor cur("Employee"); // Use the Employee table or view
+cur.select("deptno=10"); // select all records in department 10
+while(cur.next()) {
+ ... // process data
+}
+...
+// select records in other departments, ordered by department number
+cur.select("deptno>10", cur.index("deptno"));
+...
+//! [2]
+
+
+//! [3]
+Q3SqlCursor cur("Employee");
+cur.select("deptno=10"); // select all records in department 10
+while(cur.next()) {
+ ... // process data
+}
+...
+cur.select(); // re-selects all records in department 10
+...
+//! [3]
+
+
+//! [4]
+Q3SqlCursor cur("Employee");
+QSqlIndex pk = cur.primaryIndex();
+cur.setValue("id", 10);
+cur.select(pk, pk); // generates "SELECT ... FROM Employee WHERE id=10 ORDER BY id"
+...
+//! [4]
+
+
+//! [5]
+Q3SqlCursor cur("Employee");
+cur.setMode(Q3SqlCursor::Writable); // allow insert/update/delete
+...
+cur.setMode(Q3SqlCursor::Insert | Q3SqlCursor::Update); // allow inserts and updates only
+...
+cur.setMode(Q3SqlCursor::ReadOnly); // no inserts/updates/deletes allowed
+
+//! [5]
+
+
+//! [6]
+Q3SqlCursor cur("prices");
+QSqlRecord *buffer = cur.primeInsert();
+buffer->setValue("id", 53981);
+buffer->setValue("name", "Thingy");
+buffer->setValue("price", 105.75);
+cur.insert();
+//! [6]
+
+
+//! [7]
+Q3SqlCursor cur("prices");
+cur.select("id=202");
+if (cur.next()) {
+ QSqlRecord *buffer = cur.primeUpdate();
+ double price = buffer->value("price").toDouble();
+ double newprice = price * 1.05;
+ buffer->setValue("price", newprice);
+ cur.update();
+}
+//! [7]
+
+
+//! [8]
+Q3SqlCursor cur("prices");
+cur.select("id=999");
+if (cur.next()) {
+ cur.primeDelete();
+ cur.del();
+}
+//! [8]
diff --git a/doc/src/snippets/code/src_qt3support_sql_q3sqlform.cpp b/doc/src/snippets/code/src_qt3support_sql_q3sqlform.cpp
new file mode 100644
index 0000000..177eef4
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_sql_q3sqlform.cpp
@@ -0,0 +1,66 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QLineEdit myEditor(this);
+Q3SqlForm myForm(this);
+Q3SqlCursor myCursor("mytable");
+
+// Execute a query to make the cursor valid
+myCursor.select();
+// Move the cursor to a valid record (the first record)
+myCursor.next();
+// Set the form's record pointer to the cursor's edit buffer (which
+// contains the current record's values)
+myForm.setRecord(myCursor.primeUpdate());
+
+// Insert a field into the form that uses myEditor to edit the
+// field 'somefield' in 'mytable'
+myForm.insert(&myEditor, "somefield");
+
+// Update myEditor with the value from the mapped database field
+myForm.readFields();
+...
+// Let the user edit the form
+...
+// Update the database
+myForm.writeFields(); // Update the cursor's edit buffer from the form
+myCursor.update(); // Update the database from the cursor's buffer
+//! [0]
diff --git a/doc/src/snippets/code/src_qt3support_sql_q3sqlmanager_p.cpp b/doc/src/snippets/code/src_qt3support_sql_q3sqlmanager_p.cpp
new file mode 100644
index 0000000..ee5ace9
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_sql_q3sqlmanager_p.cpp
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+Q3SqlCursor* myCursor = myManager.cursor();
+...
+QSqlRecord* buf = myCursor->primeUpdate();
+buf->setValue("name", "Ola");
+buf->setValue("city", "Oslo");
+...
+myCursor->update(); // update current record
+myCursor->select(); // refresh the cursor
+myManager.findBuffer(myCursor->primaryIndex()); // go to the updated record
+//! [0]
diff --git a/doc/src/snippets/code/src_qt3support_sql_q3sqlpropertymap.cpp b/doc/src/snippets/code/src_qt3support_sql_q3sqlpropertymap.cpp
new file mode 100644
index 0000000..425ebff
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_sql_q3sqlpropertymap.cpp
@@ -0,0 +1,75 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+Q3SqlPropertyMap *myMap = new Q3SqlPropertyMap();
+Q3SqlForm *myForm = new Q3SqlForm(this);
+MyEditor myEditor(this);
+
+// Set the Q3SqlForm's record buffer to the update buffer of
+// a pre-existing Q3SqlCursor called 'cur'.
+myForm->setRecord(cur->primeUpdate());
+
+// Install the customized map
+myMap->insert("MyEditor", "content");
+myForm->installPropertyMap(myMap); // myForm now owns myMap
+...
+// Insert a field into the form that uses a myEditor to edit the
+// field 'somefield'
+myForm->insert(&myEditor, "somefield");
+
+// Update myEditor with the value from the mapped database field
+myForm->readFields();
+...
+// Let the user edit the form
+...
+// Update the database fields with the values in the form
+myForm->writeFields();
+...
+//! [0]
+
+
+//! [1]
+Q3SqlPropertyMap *myMap = new Q3SqlPropertyMap;
+
+myMap->insert("MyEditor", "content");
+Q3SqlPropertyMap::installDefaultMap(myMap);
+...
+//! [1]
diff --git a/doc/src/snippets/code/src_qt3support_sql_q3sqlselectcursor.cpp b/doc/src/snippets/code/src_qt3support_sql_q3sqlselectcursor.cpp
new file mode 100644
index 0000000..b8ecadf
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_sql_q3sqlselectcursor.cpp
@@ -0,0 +1,51 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+...
+Q3SqlSelectCursor* cur = new Q3SqlSelectCursor("SELECT id, firstname, lastname FROM author");
+Q3DataTable* table = new Q3DataTable(this);
+table->setSqlCursor(cur, true, true);
+table->refresh();
+...
+cur->exec("SELECT * FROM books");
+table->refresh();
+...
+//! [0]
diff --git a/doc/src/snippets/code/src_qt3support_text_q3simplerichtext.cpp b/doc/src/snippets/code/src_qt3support_text_q3simplerichtext.cpp
new file mode 100644
index 0000000..0910b9a
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_text_q3simplerichtext.cpp
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+Q3SimpleRichText myrichtext(contents, mywidget->font());
+//! [0]
diff --git a/doc/src/snippets/code/src_qt3support_text_q3textbrowser.cpp b/doc/src/snippets/code/src_qt3support_text_q3textbrowser.cpp
new file mode 100644
index 0000000..8f0c1f6
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_text_q3textbrowser.cpp
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+mimeSourceFactory()->setExtensionType("qml", "text/utf8");
+//! [0]
diff --git a/doc/src/snippets/code/src_qt3support_text_q3textedit.cpp b/doc/src/snippets/code/src_qt3support_text_q3textedit.cpp
new file mode 100644
index 0000000..95dfef7
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_text_q3textedit.cpp
@@ -0,0 +1,71 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QFile file(fileName); // Read the text from a file
+if (file.open(IO_ReadOnly)) {
+ QTextStream stream(&file);
+ textEdit->setText(stream.read());
+}
+
+QFile file(fileName); // Write the text to a file
+if (file.open(IO_WriteOnly)) {
+ QTextStream stream(&file);
+ stream << textEdit->text();
+ textEdit->setModified(false);
+}
+//! [0]
+
+
+//! [1]
+This is <font color=red>red</font> while <b>this</b> is <font color=blue>blue</font>.
+<font color=green><font color=yellow>Yellow,</font> and <u>green</u>.
+//! [1]
+
+
+//! [2]
+Q3TextEdit * log = new Q3TextEdit(this);
+log->setTextFormat(Qt::LogText);
+Q3StyleSheetItem * item = new Q3StyleSheetItem(log->styleSheet(), "mytag");
+item->setColor("red");
+item->setFontWeight(QFont::Bold);
+item->setFontUnderline(true);
+log->append("This is a <mytag>custom tag</mytag>!");
+//! [2]
diff --git a/doc/src/snippets/code/src_qt3support_text_q3textstream.cpp b/doc/src/snippets/code/src_qt3support_text_q3textstream.cpp
new file mode 100644
index 0000000..700c7cd
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_text_q3textstream.cpp
@@ -0,0 +1,69 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+QString str;
+Q3TextStream ts( &str, IO_WriteOnly );
+ts << "pi = " << 3.14; // str == "pi = 3.14"
+//! [0]
+
+
+//! [1]
+QString str = "pi = 3.14";
+Q3TextStream ts( &str, IO_WriteOnly );
+ts << "2+2 = " << 2+2; // str == "2+2 = 414"
+//! [1]
+
+
+//! [2]
+QByteArray array;
+Q3TextStream ts( array, IO_WriteOnly );
+ts << "pi = " << 3.14 << '\0'; // array == "pi = 3.14"
+//! [2]
+
+
+//! [3]
+QByteArray array;
+QBuffer buf( array );
+buf.open( IO_WriteOnly );
+Q3TextStream ts( &buf );
+ts << "pi = " << 3.14 << '\0'; // array == "pi = 3.14"
+buf.close();
+//! [3]
diff --git a/doc/src/snippets/code/src_qt3support_tools_q3cstring.cpp b/doc/src/snippets/code/src_qt3support_tools_q3cstring.cpp
new file mode 100644
index 0000000..af7887f
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_tools_q3cstring.cpp
@@ -0,0 +1,80 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+Q3CString str("helloworld", 6); // assigns "hello" to str
+//! [0]
+
+
+//! [1]
+Q3CString a; // a.data() == 0, a.size() == 0, a.length() == 0
+Q3CString b == ""; // b.data() == "", b.size() == 1, b.length() == 0
+a.isNull(); // true because a.data() == 0
+a.isEmpty(); // true because a.length() == 0
+b.isNull(); // false because b.data() == ""
+b.isEmpty(); // true because b.length() == 0
+//! [1]
+
+
+//! [2]
+Q3CString s = "truncate this string";
+s.truncate(5); // s == "trunc"
+//! [2]
+
+
+//! [3]
+Q3CString s;
+s.sprintf("%d - %s", 1, "first"); // result < 256 chars
+
+Q3CString big(25000); // very long string
+big.sprintf("%d - %s", 2, longString); // result < 25000 chars
+//! [3]
+
+
+//! [4]
+Q3CString s("apple");
+Q3CString t = s.leftJustify(8, '.'); // t == "apple..."
+//! [4]
+
+
+//! [5]
+Q3CString s("pie");
+Q3CString t = s.rightJustify(8, '.'); // t == ".....pie"
+//! [5]
diff --git a/doc/src/snippets/code/src_qt3support_tools_q3deepcopy.cpp b/doc/src/snippets/code/src_qt3support_tools_q3deepcopy.cpp
new file mode 100644
index 0000000..c2ddf62
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_tools_q3deepcopy.cpp
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+// all 5 strings share the same data
+QString s1 = "abcd";
+QString s2 = s1;
+QString s3 = s2;
+QString s4 = s3;
+QString s5 = s2;
+//! [0]
+
+
+//! [1]
+// s1, s2 and s5 share the same data, neither s3 nor s4 are shared
+QString s1 = "abcd";
+QString s2 = s1;
+Q3DeepCopy<QString> s3 = s2; // s3 is a deep copy of s2
+QString s4 = s3; // s4 is a deep copy of s3
+QString s5 = s2;
+//! [1]
+
+
+//! [2]
+// s1, s2 and s5 share the same data, s3 and s4 share the same data
+QString s1 = "abcd";
+QString s2 = s1;
+QString s3 = Q3DeepCopy<QString>( s2 ); // s3 is a deep copy of s2
+QString s4 = s3; // s4 is a shallow copy of s3
+QString s5 = s2;
+//! [2]
+
+
+//! [3]
+Q3DeepCopy<QString> global_string; // global string data
+QMutex global_mutex; // mutex to protext global_string
+
+...
+
+void setGlobalString( const QString &str )
+{
+ global_mutex.lock();
+ global_string = str; // global_string is a deep copy of str
+ global_mutex.unlock();
+}
+
+...
+
+void MyThread::run()
+{
+ global_mutex.lock();
+ QString str = global_string; // str is a deep copy of global_string
+ global_mutex.unlock();
+
+ // process the string data
+ ...
+
+ // update global_string
+ setGlobalString( str );
+}
+//! [3]
diff --git a/doc/src/snippets/code/src_qt3support_tools_q3garray.cpp b/doc/src/snippets/code/src_qt3support_tools_q3garray.cpp
new file mode 100644
index 0000000..623035b
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_tools_q3garray.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+static uchar bindata[] = { 231, 1, 44, ... };
+QByteArray a;
+a.setRawData(bindata, sizeof(bindata)); // a points to bindata
+QDataStream s(a, IO_ReadOnly); // open on a's data
+s >> <something>; // read raw bindata
+s.close();
+a.resetRawData(bindata, sizeof(bindata)); // finished
+//! [0]
+
+
+//! [1]
+static uchar bindata[] = { 231, 1, 44, ... };
+QByteArray a, b;
+a.setRawData(bindata, sizeof(bindata)); // a points to bindata
+a.resize(8); // will crash
+b = a; // will crash
+a[2] = 123; // might crash
+ // forget to resetRawData - will crash
+//! [1]
diff --git a/doc/src/snippets/code/src_qt3support_tools_q3signal.cpp b/doc/src/snippets/code/src_qt3support_tools_q3signal.cpp
new file mode 100644
index 0000000..9f6dd58
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_tools_q3signal.cpp
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+#include <q3signal.h>
+
+class MyClass
+{
+public:
+ MyClass();
+ ~MyClass();
+
+ void doSomething();
+
+ void connect(QObject *receiver, const char *member);
+
+private:
+ Q3Signal *sig;
+};
+
+MyClass::MyClass()
+{
+ sig = new Q3Signal;
+}
+
+MyClass::~MyClass()
+{
+ delete sig;
+}
+
+void MyClass::doSomething()
+{
+ // ... does something
+ sig->activate(); // emits the signal
+}
+
+void MyClass::connect(QObject *receiver, const char *member)
+{
+ sig->connect(receiver, member);
+}
+//! [0]
diff --git a/doc/src/snippets/code/src_qt3support_widgets_q3combobox.cpp b/doc/src/snippets/code/src_qt3support_widgets_q3combobox.cpp
new file mode 100644
index 0000000..6a495e8
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_widgets_q3combobox.cpp
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+Q3ComboBox *c = new Q3ComboBox(this, tr("read-only combobox"));
+//! [0]
+
+
+//! [1]
+Q3ComboBox *c1 = new Q3ComboBox(false, this, tr("read-only combobox"));
+Q3ComboBox *c2 = new Q3ComboBox(true, this, tr("editable combobox"));
+//! [1]
+
+
+//! [2]
+static const char* items[] = { "red", "green", "blue", 0 };
+combo->insertStrList( items );
+//! [2]
diff --git a/doc/src/snippets/code/src_qt3support_widgets_q3datetimeedit.cpp b/doc/src/snippets/code/src_qt3support_widgets_q3datetimeedit.cpp
new file mode 100644
index 0000000..a84c898
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_widgets_q3datetimeedit.cpp
@@ -0,0 +1,68 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+void wrapInFunction()
+{
+
+//! [0]
+Q3DateEdit *dateEdit = new Q3DateEdit(QDate::currentDate(), this);
+dateEdit->setRange(QDate::currentDate().addDays(-365),
+ QDate::currentDate().addDays( 365));
+dateEdit->setOrder(Q3DateEdit::MDY);
+dateEdit->setAutoAdvance(true);
+//! [0]
+
+
+//! [1]
+QTime timeNow = QTime::currentTime();
+Q3TimeEdit *timeEdit = new Q3TimeEdit(timeNow, this);
+timeEdit->setRange(timeNow, timeNow.addSecs(60 * 60));
+//! [1]
+
+
+//! [2]
+Q3DateTimeEdit *dateTimeEdit = new Q3DateTimeEdit(QDateTime::currentDateTime(), this);
+dateTimeEdit->dateEdit()->setRange(QDateTime::currentDate(),
+ QDateTime::currentDate().addDays(7));
+//! [2]
+
+}
+
diff --git a/doc/src/snippets/code/src_qt3support_widgets_q3dockarea.cpp b/doc/src/snippets/code/src_qt3support_widgets_q3dockarea.cpp
new file mode 100644
index 0000000..e11d058
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_widgets_q3dockarea.cpp
@@ -0,0 +1,48 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+ts << *myDockArea;
+//! [0]
+
+
+//! [1]
+ts >> *myDockArea;
+//! [1]
diff --git a/doc/src/snippets/code/src_qt3support_widgets_q3dockwindow.cpp b/doc/src/snippets/code/src_qt3support_widgets_q3dockwindow.cpp
new file mode 100644
index 0000000..345e825
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_widgets_q3dockwindow.cpp
@@ -0,0 +1,44 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+Q3ToolBar *fileTools = new Q3ToolBar(this, "File Actions");
+moveDockWindow(fileTools, Left);
+//! [0]
diff --git a/doc/src/snippets/code/src_qt3support_widgets_q3gridview.cpp b/doc/src/snippets/code/src_qt3support_widgets_q3gridview.cpp
new file mode 100644
index 0000000..bb4e473
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_widgets_q3gridview.cpp
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+p->setClipRect(cellRect(), QPainter::CoordPainter);
+//... your drawing code
+p->setClipping(false);
+
+//! [0]
diff --git a/doc/src/snippets/code/src_qt3support_widgets_q3header.cpp b/doc/src/snippets/code/src_qt3support_widgets_q3header.cpp
new file mode 100644
index 0000000..2ce3577
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_widgets_q3header.cpp
@@ -0,0 +1,46 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+// Allow resizing of all current and future sections
+header->setResizeEnabled(true);
+// Disable resizing of section 3, (the fourth section added)
+header->setResizeEnabled(false, 3);
+//! [0]
diff --git a/doc/src/snippets/code/src_qt3support_widgets_q3mainwindow.cpp b/doc/src/snippets/code/src_qt3support_widgets_q3mainwindow.cpp
new file mode 100644
index 0000000..1777095
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_widgets_q3mainwindow.cpp
@@ -0,0 +1,85 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+Q3MainWindow *mw = new Q3MainWindow;
+QTextEdit *edit = new QTextEdit(mw, "editor");
+edit->setFocus();
+mw->setWindowTitle("Main Window");
+mw->setCentralWidget(edit);
+mw->show();
+//! [0]
+
+
+//! [1]
+Q3ToolBar *tb = new Q3ToolBar(this);
+addDockWindow(tb, tr("Menubar"), Top, false);
+QMenuBar *mb = new QMenuBar(tb);
+mb->setFrameStyle(QFrame::NoFrame);
+tb->setStretchableWidget(mb);
+setDockEnabled(tb, Left, false);
+setDockEnabled(tb, Right, false);
+//! [1]
+
+
+//! [2]
+QFile file(filename);
+if (file.open(IO_WriteOnly)) {
+ QTextStream stream(&file);
+ stream << *mainWindow;
+ file.close();
+}
+//! [2]
+
+
+//! [3]
+QFile file(filename);
+if (file.open(IO_ReadOnly)) {
+ QTextStream stream(&file);
+ stream >> *mainWindow;
+ file.close();
+}
+//! [3]
+
+
+//! [4]
+Q3PopupMenu * help = new Q3PopupMenu(this);
+help->insertItem("What's &This", this , SLOT(enterWhatsThis()), Qt::SHIFT+Qt::Key_F1);
+//! [4]
diff --git a/doc/src/snippets/code/src_qt3support_widgets_q3scrollview.cpp b/doc/src/snippets/code/src_qt3support_widgets_q3scrollview.cpp
new file mode 100644
index 0000000..cff871a
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_widgets_q3scrollview.cpp
@@ -0,0 +1,101 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+Q3ScrollView* sv = new Q3ScrollView(...);
+QWidget *widget = new QWidget(sv->viewport());
+QVBoxLayout *layout = new QVBoxLayout(widget);
+addChild(widget);
+//! [0]
+
+
+//! [1]
+QLabel* child1 = new QLabel("CHILD", widget);
+QLabel* child2 = new QLabel("CHILD", widget);
+QLabel* child3 = new QLabel("CHILD", widget);
+layout->addWidget(child1);
+layout->addWidget(child2);
+layout->addWidget(child3);
+...
+//! [1]
+
+
+//! [2]
+Q3ScrollView* sv = new Q3ScrollView(...);
+QLabel* child1 = new QLabel("CHILD", sv->viewport());
+sv->addChild(child1);
+QLabel* child2 = new QLabel("CHILD", sv->viewport());
+sv->addChild(child2);
+QLabel* child3 = new QLabel("CHILD", sv->viewport());
+sv->addChild(child3);
+//! [2]
+
+
+//! [3]
+Q3ScrollView* sv = new Q3ScrollView(...);
+sv->enableClipper(true);
+QLabel* child1 = new QLabel("CHILD", sv->viewport());
+sv->addChild(child1);
+QLabel* child2 = new QLabel("CHILD", sv->viewport());
+sv->addChild(child2);
+QLabel* child3 = new QLabel("CHILD", sv->viewport());
+sv->addChild(child3);
+//! [3]
+
+
+//! [4]
+{
+ // Fill a 40000 by 50000 rectangle at (100000,150000)
+
+ // Calculate the coordinates...
+ int x1 = 100000, y1 = 150000;
+ int x2 = x1+40000-1, y2 = y1+50000-1;
+
+ // Clip the coordinates so X/Windows will not have problems...
+ if (x1 < clipx) x1=clipx;
+ if (y1 < clipy) y1=clipy;
+ if (x2 > clipx+clipw-1) x2=clipx+clipw-1;
+ if (y2 > clipy+cliph-1) y2=clipy+cliph-1;
+
+ // Paint using the small coordinates...
+ if (x2 >= x1 && y2 >= y1)
+ p->fillRect(x1, y1, x2-x1+1, y2-y1+1, red);
+}
+//! [4]
diff --git a/doc/src/snippets/code/src_qt3support_widgets_q3whatsthis.cpp b/doc/src/snippets/code/src_qt3support_widgets_q3whatsthis.cpp
new file mode 100644
index 0000000..e919901
--- /dev/null
+++ b/doc/src/snippets/code/src_qt3support_widgets_q3whatsthis.cpp
@@ -0,0 +1,43 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//! [0]
+(void)Q3WhatsThis::whatsThisButton( my_help_tool_bar );
+//! [0]
diff --git a/doc/src/snippets/plaintextlayout/window.cpp b/doc/src/snippets/plaintextlayout/window.cpp
new file mode 100644
index 0000000..71def18
--- /dev/null
+++ b/doc/src/snippets/plaintextlayout/window.cpp
@@ -0,0 +1,108 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <math.h>
+
+#include "window.h"
+
+Window::Window(QWidget *parent)
+ : QWidget(parent)
+{
+ text = QString("Support for text rendering and layout in Qt 4 has been "
+ "redesigned around a system that allows textual content to "
+ "be represented in a more flexible way than was possible "
+ "with Qt 3. Qt 4 also provides a more convenient "
+ "programming interface for editing documents. These "
+ "improvements are made available through a reimplementation "
+ "of the existing text rendering engine, and the "
+ "introduction of several new classes. "
+ "See the relevant module overview for a detailed discussion "
+ "of this framework. The following sections provide a brief "
+ "overview of the main concepts behind Scribe.");
+
+ setWindowTitle(tr("Plain Text Layout"));
+}
+
+void Window::paintEvent(QPaintEvent *event)
+{
+//! [0]
+ QTextLayout textLayout(text, font);
+ qreal margin = 10;
+ qreal radius = qMin(width()/2.0, height()/2.0) - margin;
+ QFontMetrics fm(font);
+
+ qreal lineHeight = fm.height();
+ qreal y = 0;
+
+ textLayout.beginLayout();
+
+ while (1) {
+ // create a new line
+ QTextLine line = textLayout.createLine();
+ if (!line.isValid())
+ break;
+
+ qreal x1 = qMax(0.0, pow(pow(radius,2)-pow(radius-y,2), 0.5));
+ qreal x2 = qMax(0.0, pow(pow(radius,2)-pow(radius-(y+lineHeight),2), 0.5));
+ qreal x = qMax(x1, x2) + margin;
+ qreal lineWidth = (width() - margin) - x;
+
+ line.setLineWidth(lineWidth);
+ line.setPosition(QPointF(x, margin+y));
+ y += line.height();
+ }
+
+ textLayout.endLayout();
+
+ QPainter painter;
+ painter.begin(this);
+ painter.setRenderHint(QPainter::Antialiasing);
+ painter.fillRect(rect(), Qt::white);
+ painter.setBrush(QBrush(Qt::black));
+ painter.setPen(QPen(Qt::black));
+ textLayout.draw(&painter, QPoint(0,0));
+
+ painter.setBrush(QBrush(QColor("#a6ce39")));
+ painter.setPen(QPen(Qt::black));
+ painter.drawEllipse(QRectF(-radius, margin, 2*radius, 2*radius));
+ painter.end();
+//! [0]
+}
diff --git a/doc/src/snippets/porting4-dropevents/window.cpp b/doc/src/snippets/porting4-dropevents/window.cpp
new file mode 100644
index 0000000..d883b14
--- /dev/null
+++ b/doc/src/snippets/porting4-dropevents/window.cpp
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "window.h"
+
+MyWidget::MyWidget(QWidget *parent)
+ : QWidget(parent)
+{
+ QLabel *textLabel = new QLabel(tr("Data:"), this);
+ dataLabel = new QLabel(this);
+ dataLabel->setFixedSize(200, 200);
+
+ QVBoxLayout *layout = new QVBoxLayout(this);
+ layout->addWidget(textLabel);
+ layout->addWidget(dataLabel);
+
+ setAcceptDrops(true);
+ setWindowTitle(tr("Drop Events"));
+}
+
+//! [0]
+void MyWidget::dragEnterEvent(QDragEnterEvent *event)
+{
+ if (event->mimeData()->hasText() || event->mimeData()->hasImage())
+ event->acceptProposedAction();
+}
+//! [0]
+
+//! [1]
+void MyWidget::dropEvent(QDropEvent *event)
+{
+ if (event->mimeData()->hasText())
+ dataLabel->setText(event->mimeData()->text());
+ else if (event->mimeData()->hasImage()) {
+ QVariant imageData = event->mimeData()->imageData();
+ dataLabel->setPixmap(qvariant_cast<QPixmap>(imageData));
+ }
+ event->acceptProposedAction();
+}
+//! [1]
+
+//! [2]
+void MyWidget::mousePressEvent(QMouseEvent *event)
+{
+//! [2]
+ QString text = dataLabel->text();
+ QPixmap iconPixmap(32, 32);
+ iconPixmap.fill(qRgba(255, 0, 0, 127));
+ QImage image(100, 100, QImage::Format_RGB32);
+ image.fill(qRgb(0, 0, 255));
+
+//! [3]
+ if (event->button() == Qt::LeftButton) {
+
+ QDrag *drag = new QDrag(this);
+ QMimeData *mimeData = new QMimeData;
+
+ mimeData->setText(text);
+ mimeData->setImageData(image);
+ drag->setMimeData(mimeData);
+ drag->setPixmap(iconPixmap);
+
+ Qt::DropAction dropAction = drag->exec();
+//! [3]
+ // ...
+//! [4]
+ event->accept();
+ }
+//! [4]
+ else if (event->button() == Qt::MidButton) {
+
+ QDrag *drag = new QDrag(this);
+ QMimeData *mimeData = new QMimeData;
+
+ mimeData->setImageData(image);
+ drag->setMimeData(mimeData);
+ drag->setPixmap(iconPixmap);
+
+ Qt::DropAction dropAction = drag->exec();
+ // ...
+ event->accept();
+ }
+//! [5]
+}
+//! [5]
diff --git a/doc/src/snippets/qsvgwidget/main.cpp b/doc/src/snippets/qsvgwidget/main.cpp
new file mode 100644
index 0000000..0b44f8b
--- /dev/null
+++ b/doc/src/snippets/qsvgwidget/main.cpp
@@ -0,0 +1,59 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+#include <QtSvg>
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+//! [0]
+ QSvgWidget window(":/files/spheres.svg");
+ window.show();
+//! [0]
+ QSvgRenderer *renderer = window.renderer();
+ QImage image(150, 150, QImage::Format_RGB32);
+ QPainter painter;
+ painter.begin(&image);
+ renderer->render(&painter);
+ painter.end();
+ image.save("spheres.png", "PNG", 9);
+ return app.exec();
+}
diff --git a/doc/src/snippets/scribe-overview/main.cpp b/doc/src/snippets/scribe-overview/main.cpp
new file mode 100644
index 0000000..9443d0b
--- /dev/null
+++ b/doc/src/snippets/scribe-overview/main.cpp
@@ -0,0 +1,73 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+void mergeFormat(QTextEdit *edit)
+{
+//! [0]
+ QTextDocument *document = edit->document();
+ QTextCursor cursor(document);
+
+ cursor.movePosition(QTextCursor::Start);
+ cursor.movePosition(QTextCursor::EndOfLine, QTextCursor::KeepAnchor);
+
+ QTextCharFormat format;
+ format.setFontWeight(QFont::Bold);
+
+ cursor.mergeCharFormat(format);
+//! [0]
+}
+
+int main(int argc, char *argv[])
+{
+ QWidget *parent = 0;
+ QString aStringContainingHTMLtext("<h1>Scribe Overview</h1>");
+
+ QApplication app(argc, argv);
+
+//! [1]
+ QTextEdit *editor = new QTextEdit(parent);
+ editor->setHtml(aStringContainingHTMLtext);
+ editor->show();
+//! [1]
+
+ return app.exec();
+}
diff --git a/doc/src/snippets/stringlistmodel/main.cpp b/doc/src/snippets/stringlistmodel/main.cpp
new file mode 100644
index 0000000..cd2ac3f
--- /dev/null
+++ b/doc/src/snippets/stringlistmodel/main.cpp
@@ -0,0 +1,83 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ The main function for the string list model example. This creates and
+ populates a model with values from a string list then displays the
+ contents of the model using a QListView widget.
+*/
+
+#include <QAbstractItemModel>
+#include <QApplication>
+#include <QListView>
+
+#include "model.h"
+
+//! [0]
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+
+// Unindented for quoting purposes:
+//! [1]
+QStringList numbers;
+numbers << "One" << "Two" << "Three" << "Four" << "Five";
+
+QAbstractItemModel *model = new StringListModel(numbers);
+//! [0] //! [1] //! [2] //! [3]
+QListView *view = new QListView;
+//! [2]
+view->setWindowTitle("View onto a string list model");
+//! [4]
+view->setModel(model);
+//! [3] //! [4]
+
+ model->insertRows(5, 7, QModelIndex());
+
+ for (int row = 5; row < 12; ++row) {
+ QModelIndex index = model->index(row, 0, QModelIndex());
+ model->setData(index, QString::number(row+1));
+ }
+
+//! [5]
+ view->show();
+ return app.exec();
+}
+//! [5]
diff --git a/doc/src/snippets/stringlistmodel/model.cpp b/doc/src/snippets/stringlistmodel/model.cpp
new file mode 100644
index 0000000..c097ced
--- /dev/null
+++ b/doc/src/snippets/stringlistmodel/model.cpp
@@ -0,0 +1,211 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*
+ model.cpp
+
+ A simple model that uses a QStringList as its data source.
+*/
+
+#include "model.h"
+
+/*!
+ Returns the number of items in the string list as the number of rows
+ in the model.
+*/
+
+//! [0]
+int StringListModel::rowCount(const QModelIndex &parent) const
+{
+ return stringList.count();
+}
+//! [0]
+
+
+#ifdef 0
+// This represents a read-only version of data(), an early stage in the
+// development of the example leading to an editable StringListModel.
+
+/*!
+ Returns an appropriate value for the requested data.
+ If the view requests an invalid index, an invalid variant is returned.
+ Any valid index that corresponds to a string in the list causes that
+ string to be returned.
+*/
+
+//! [1-data-read-only]
+QVariant StringListModel::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid())
+ return QVariant();
+
+ if (index.row() >= stringList.size())
+ return QVariant();
+
+ if (role == Qt::DisplayRole)
+ return stringList.at(index.row());
+ else
+ return QVariant();
+}
+//! [1-data-read-only]
+#endif
+
+
+/*!
+ Returns an appropriate value for the requested data.
+ If the view requests an invalid index, an invalid variant is returned.
+ Any valid index that corresponds to a string in the list causes that
+ string to be returned.
+*/
+
+//! [1]
+QVariant StringListModel::data(const QModelIndex &index, int role) const
+{
+ if (!index.isValid())
+ return QVariant();
+
+ if (index.row() >= stringList.size())
+ return QVariant();
+
+ if (role == Qt::DisplayRole || role == Qt::EditRole)
+ return stringList.at(index.row());
+ else
+ return QVariant();
+}
+//! [1]
+
+/*!
+ Returns the appropriate header string depending on the orientation of
+ the header and the section. If anything other than the display role is
+ requested, we return an invalid variant.
+*/
+
+//! [2]
+QVariant StringListModel::headerData(int section, Qt::Orientation orientation,
+ int role) const
+{
+ if (role != Qt::DisplayRole)
+ return QVariant();
+
+ if (orientation == Qt::Horizontal)
+ return QString("Column %1").arg(section);
+ else
+ return QString("Row %1").arg(section);
+}
+//! [2]
+
+/*!
+ Returns an appropriate value for the item's flags. Valid items are
+ enabled, selectable, and editable.
+*/
+
+//! [3]
+Qt::ItemFlags StringListModel::flags(const QModelIndex &index) const
+{
+ if (!index.isValid())
+ return Qt::ItemIsEnabled;
+
+ return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
+}
+//! [3]
+
+/*!
+ Changes an item in the string list, but only if the following conditions
+ are met:
+
+ * The index supplied is valid.
+ * The index corresponds to an item to be shown in a view.
+ * The role associated with editing text is specified.
+
+ The dataChanged() signal is emitted if the item is changed.
+*/
+
+//! [4]
+bool StringListModel::setData(const QModelIndex &index,
+ const QVariant &value, int role)
+{
+ if (index.isValid() && role == Qt::EditRole) {
+
+ stringList.replace(index.row(), value.toString());
+ emit dataChanged(index, index);
+ return true;
+ }
+//! [4] //! [5]
+ return false;
+}
+//! [5]
+
+/*!
+ Inserts a number of rows into the model at the specified position.
+*/
+
+//! [6]
+bool StringListModel::insertRows(int position, int rows, const QModelIndex &parent)
+{
+ beginInsertRows(QModelIndex(), position, position+rows-1);
+
+ for (int row = 0; row < rows; ++row) {
+ stringList.insert(position, "");
+ }
+
+ endInsertRows();
+ return true;
+//! [6] //! [7]
+}
+//! [7]
+
+/*!
+ Removes a number of rows from the model at the specified position.
+*/
+
+//! [8]
+bool StringListModel::removeRows(int position, int rows, const QModelIndex &parent)
+{
+ beginRemoveRows(QModelIndex(), position, position+rows-1);
+
+ for (int row = 0; row < rows; ++row) {
+ stringList.removeAt(position);
+ }
+
+ endRemoveRows();
+ return true;
+//! [8] //! [9]
+}
+//! [9]
diff --git a/doc/src/snippets/stringlistmodel/model.h b/doc/src/snippets/stringlistmodel/model.h
new file mode 100644
index 0000000..35e5d60
--- /dev/null
+++ b/doc/src/snippets/stringlistmodel/model.h
@@ -0,0 +1,82 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef MODEL_H
+#define MODEL_H
+
+#include <QAbstractListModel>
+#include <QObject>
+#include <QStringList>
+
+//! [0]
+class StringListModel : public QAbstractListModel
+{
+ Q_OBJECT
+
+public:
+ StringListModel(const QStringList &strings, QObject *parent = 0)
+ : QAbstractListModel(parent), stringList(strings) {}
+
+ int rowCount(const QModelIndex &parent = QModelIndex()) const;
+ QVariant data(const QModelIndex &index, int role) const;
+ QVariant headerData(int section, Qt::Orientation orientation,
+//! [0] //! [1]
+ int role = Qt::DisplayRole) const;
+//! [1]
+
+//! [2]
+ Qt::ItemFlags flags(const QModelIndex &index) const;
+ bool setData(const QModelIndex &index, const QVariant &value,
+//! [2] //! [3]
+ int role = Qt::EditRole);
+//! [3]
+
+//! [4]
+ bool insertRows(int position, int rows, const QModelIndex &index = QModelIndex());
+ bool removeRows(int position, int rows, const QModelIndex &index = QModelIndex());
+//! [4]
+
+//! [5]
+private:
+ QStringList stringList;
+};
+//! [5]
+
+#endif
diff --git a/doc/src/snippets/textdocument-blocks/mainwindow.cpp b/doc/src/snippets/textdocument-blocks/mainwindow.cpp
new file mode 100644
index 0000000..39e427d
--- /dev/null
+++ b/doc/src/snippets/textdocument-blocks/mainwindow.cpp
@@ -0,0 +1,156 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+#include "xmlwriter.h"
+
+MainWindow::MainWindow()
+{
+ QMenu *fileMenu = new QMenu(tr("&File"));
+
+ QAction *saveAction = fileMenu->addAction(tr("&Save..."));
+ saveAction->setShortcut(tr("Ctrl+S"));
+
+ QAction *quitAction = fileMenu->addAction(tr("E&xit"));
+ quitAction->setShortcut(tr("Ctrl+Q"));
+
+ QMenu *insertMenu = new QMenu(tr("&Insert"));
+
+ QAction *calendarAction = insertMenu->addAction(tr("&Calendar"));
+ calendarAction->setShortcut(tr("Ctrl+I"));
+
+ menuBar()->addMenu(fileMenu);
+ menuBar()->addMenu(insertMenu);
+
+//! [0]
+ editor = new QTextEdit(this);
+//! [0]
+
+ connect(saveAction, SIGNAL(triggered()), this, SLOT(saveFile()));
+ connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
+ connect(calendarAction, SIGNAL(triggered()), this, SLOT(insertCalendar()));
+
+ setCentralWidget(editor);
+ setWindowTitle(tr("Text Document Writer"));
+}
+
+void MainWindow::saveFile()
+{
+ QString fileName = QFileDialog::getSaveFileName(this,
+ tr("Save document as:"), "", tr("XML (*.xml)"));
+
+ if (!fileName.isEmpty()) {
+ if (writeXml(fileName))
+ setWindowTitle(fileName);
+ else
+ QMessageBox::warning(this, tr("Warning"),
+ tr("Failed to save the document."), QMessageBox::Cancel,
+ QMessageBox::NoButton);
+ }
+}
+
+void MainWindow::insertCalendar()
+{
+//! [1]
+ QTextCursor cursor(editor->textCursor());
+ cursor.movePosition(QTextCursor::Start);
+
+ QTextCharFormat format(cursor.charFormat());
+ format.setFontFamily("Courier");
+
+ QTextCharFormat boldFormat = format;
+ boldFormat.setFontWeight(QFont::Bold);
+
+ cursor.insertBlock();
+ cursor.insertText(" ", boldFormat);
+
+ QDate date = QDate::currentDate();
+ int year = date.year(), month = date.month();
+
+ for (int weekDay = 1; weekDay <= 7; ++weekDay) {
+ cursor.insertText(QString("%1 ").arg(QDate::shortDayName(weekDay), 3),
+ boldFormat);
+ }
+
+ cursor.insertBlock();
+ cursor.insertText(" ", format);
+
+ for (int column = 1; column < QDate(year, month, 1).dayOfWeek(); ++column) {
+ cursor.insertText(" ", format);
+ }
+
+ for (int day = 1; day <= date.daysInMonth(); ++day) {
+//! [1] //! [2]
+ int weekDay = QDate(year, month, day).dayOfWeek();
+
+ if (QDate(year, month, day) == date)
+ cursor.insertText(QString("%1 ").arg(day, 3), boldFormat);
+ else
+ cursor.insertText(QString("%1 ").arg(day, 3), format);
+
+ if (weekDay == 7) {
+ cursor.insertBlock();
+ cursor.insertText(" ", format);
+ }
+//! [2] //! [3]
+ }
+//! [3]
+}
+
+bool MainWindow::writeXml(const QString &fileName)
+{
+ XmlWriter documentWriter(editor->document());
+
+ QDomDocument *domDocument = documentWriter.toXml();
+ QFile file(fileName);
+
+ if (file.open(QFile::WriteOnly)) {
+ QTextStream textStream(&file);
+ textStream.setCodec(QTextCodec::codecForName("UTF-8"));
+
+ textStream << domDocument->toString(1).toUtf8();
+ file.close();
+ return true;
+ }
+ else
+ return false;
+}
diff --git a/doc/src/snippets/textdocument-printing/mainwindow.cpp b/doc/src/snippets/textdocument-printing/mainwindow.cpp
new file mode 100644
index 0000000..2ea4977
--- /dev/null
+++ b/doc/src/snippets/textdocument-printing/mainwindow.cpp
@@ -0,0 +1,124 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui>
+
+#include "mainwindow.h"
+
+MainWindow::MainWindow()
+{
+ QMenu *fileMenu = new QMenu(tr("&File"));
+
+ fileMenu->addAction(tr("&Open..."), this, SLOT(openFile()),
+ QKeySequence(tr("Ctrl+O", "File|Open")));
+
+ printAction = fileMenu->addAction(tr("&Print..."), this, SLOT(printFile()));
+ printAction->setEnabled(false);
+
+ pdfPrintAction = fileMenu->addAction(tr("Print as P&DF..."), this, SLOT(printPdf()));
+ pdfPrintAction->setEnabled(false);
+
+ fileMenu->addAction(tr("E&xit"), this, SLOT(close()),
+ QKeySequence(tr("Ctrl+Q", "File|Exit")));
+
+ menuBar()->addMenu(fileMenu);
+
+ editor = new QTextEdit(this);
+ document = new QTextDocument(this);
+ editor->setDocument(document);
+
+ connect(editor, SIGNAL(selectionChanged()), this, SLOT(updateMenus()));
+
+ setCentralWidget(editor);
+ setWindowTitle(tr("Text Document Writer"));
+}
+
+void MainWindow::openFile()
+{
+ QString fileName = QFileDialog::getOpenFileName(this,
+ tr("Open file"), currentFile, "HTML files (*.html);;Text files (*.txt)");
+
+ if (!fileName.isEmpty()) {
+ QFileInfo info(fileName);
+ if (info.completeSuffix() == "html") {
+ QFile file(fileName);
+
+ if (file.open(QIODevice::ReadOnly)) {
+ editor->setHtml(file.readAll());
+ file.close();
+ currentFile = fileName;
+ }
+ } else if (info.completeSuffix() == "txt") {
+ QFile file(fileName);
+
+ if (file.open(QIODevice::ReadOnly)) {
+ editor->setPlainText(file.readAll());
+ file.close();
+ currentFile = fileName;
+ }
+ }
+ printAction->setEnabled(true);
+ pdfPrintAction->setEnabled(true);
+ }
+}
+
+void MainWindow::printFile()
+{
+//! [0]
+ QTextDocument *document = editor->document();
+ QPrinter printer;
+
+ QPrintDialog *dlg = new QPrintDialog(&printer, this);
+ if (dlg->exec() != QDialog::Accepted)
+ return;
+
+ document->print(&printer);
+//! [0]
+}
+
+void MainWindow::printPdf()
+{
+ QPrinter printer(QPrinter::HighResolution);
+ printer.setOutputFormat(QPrinter::PdfFormat);
+
+ QPrintDialog *printDialog = new QPrintDialog(&printer, this);
+ if (printDialog->exec() == QDialog::Accepted)
+ editor->document()->print(&printer);
+}