summaryrefslogtreecommitdiffstats
path: root/doc/src/porting
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2011-03-31 15:54:58 +0200
committerOlivier Goffart <olivier.goffart@nokia.com>2011-03-31 15:54:58 +0200
commit37feac98c573a099502fddfb5703c2359711b4c4 (patch)
tree33d74f9650065de4564bc0d749ca50bd65b13a2c /doc/src/porting
parent7b18baf23b1e8c663872b2b25b1323798b1d09df (diff)
parentb764d3e6cb114988394e7500236ba087a3385a50 (diff)
Merge remote-tracking branch 'origin/4.7' into qt-master-from-4.7
Conflicts: doc/src/declarative/example-slideswitch.qdoc doc/src/development/qmake-manual.qdoc doc/src/snippets/code/doc_src_qmake-manual.pro doc/src/snippets/code/doc_src_qtscript.qdoc src/corelib/animation/qabstractanimation.cpp src/s60installs/bwins/QtOpenGLu.def src/s60installs/eabi/QtOpenGLu.def src/s60installs/eabi/QtOpenVGu.def tests/auto/qdir/qdir.pro tests/auto/qsslsocket/tst_qsslsocket.cpp tools/qdoc3/doc/qdoc-manual.qdocconf
Diffstat (limited to 'doc/src/porting')
-rw-r--r--doc/src/porting/porting-qsa.qdoc28
-rw-r--r--doc/src/porting/porting4-canvas.qdoc20
-rw-r--r--doc/src/porting/porting4-designer.qdoc14
-rw-r--r--doc/src/porting/porting4-dnd.qdoc6
-rw-r--r--doc/src/porting/porting4.qdoc140
-rw-r--r--doc/src/porting/qt3to4.qdoc2
-rw-r--r--doc/src/porting/qt4-accessibility.qdoc8
-rw-r--r--doc/src/porting/qt4-arthur.qdoc22
-rw-r--r--doc/src/porting/qt4-mainwindow.qdoc20
-rw-r--r--doc/src/porting/qt4-sql.qdoc4
-rw-r--r--doc/src/porting/qt4-styles.qdoc8
-rw-r--r--doc/src/porting/qt4-tulip.qdoc22
12 files changed, 147 insertions, 147 deletions
diff --git a/doc/src/porting/porting-qsa.qdoc b/doc/src/porting/porting-qsa.qdoc
index ea83e97fbf..e831583d5a 100644
--- a/doc/src/porting/porting-qsa.qdoc
+++ b/doc/src/porting/porting-qsa.qdoc
@@ -64,7 +64,7 @@
can have named properties. For instance to create an point object with
the properties x and y one would write the following Qt Script code:
- \snippet doc/src/snippets/code/doc_src_porting-qsa.qdoc 0
+ \snippet doc/src/snippets/code/doc_src_porting-qsa.js 0
The object \c point in this case is constructed as a plain object and
we assign two properties, \c x and \c y, to it with the values 12 and
@@ -73,17 +73,17 @@
global namespace of the script engine. Similarly, global functions are
named properties of the global object; for example:
- \snippet doc/src/snippets/code/doc_src_porting-qsa.qdoc 1
+ \snippet doc/src/snippets/code/doc_src_porting-qsa.js 1
An equivalent construction that illustrates that the function is a
property of the global object is the following assignment:
- \snippet doc/src/snippets/code/doc_src_porting-qsa.qdoc 2
+ \snippet doc/src/snippets/code/doc_src_porting-qsa.js 2
Since functions are objects, they can be assigned to objects as
properties, becoming member functions:
- \snippet doc/src/snippets/code/doc_src_porting-qsa.qdoc 3
+ \snippet doc/src/snippets/code/doc_src_porting-qsa.js 3
In the code above, we see the first subtle difference between
QSA and Qt Script. In QSA one would write the point class like this:
@@ -99,7 +99,7 @@
All the code above runs with QSA except the assignment of a function
to \c{point.manhattanLength}, which we repeat here for clarity:
- \snippet doc/src/snippets/code/doc_src_porting-qsa.qdoc 5
+ \snippet doc/src/snippets/code/doc_src_porting-qsa.js 5
This is because, in QSA, the value of \c this is decided based on
the location of the declaration of the function it is used in. In the
@@ -129,7 +129,7 @@
function with the newly created object as the \c this pointer.
So, in a sense, it is equivalent to:
- \snippet doc/src/snippets/code/doc_src_porting-qsa.qdoc 8
+ \snippet doc/src/snippets/code/doc_src_porting-qsa.js 8
This is similar to the manhattenLength() example above. Again, the
main difference between QSA and Qt Script is that one has to
@@ -149,7 +149,7 @@
one could write this in Qt Script as:
- \snippet doc/src/snippets/code/doc_src_porting-qsa.qdoc 10
+ \snippet doc/src/snippets/code/doc_src_porting-qsa.js 10
In QSA, the member functions were part of the class declaration,
and were therefore shared between all instances of a given class.
@@ -173,7 +173,7 @@
To make the \c toString() function part of the prototype, we write
code like this:
- \snippet doc/src/snippets/code/doc_src_porting-qsa.qdoc 11
+ \snippet doc/src/snippets/code/doc_src_porting-qsa.js 11
Here, we made the \c toString() function part of the prototype so
that, when we call \c{car.toString()} it will be resolved via the
@@ -195,7 +195,7 @@
without any special members, but it is possible to replace this
object with another prototype object.
- \snippet doc/src/snippets/code/doc_src_porting-qsa.qdoc 13
+ \snippet doc/src/snippets/code/doc_src_porting-qsa.js 13
In the code above, we have a constructor, \c{GasolineCar}, which
calls the "base class" implementation of the constructor to
@@ -223,7 +223,7 @@
as static members as properties of the constructor function. For
example:
- \snippet doc/src/snippets/code/doc_src_porting-qsa.qdoc 15
+ \snippet doc/src/snippets/code/doc_src_porting-qsa.js 15
Note that in QSA, static member variables were also accessible in
instances of the given class. In Qt Script, with the approach
@@ -374,7 +374,7 @@
the interpreter using their object names as the names of the
variables.
- \snippet doc/src/snippets/code/doc_src_porting-qsa.qdoc 16
+ \snippet doc/src/snippets/code/doc_src_porting-qsa.cpp 16
The code above adds the button to the global namespace under the name
"button". One obvious limitation here is that there is potential for
@@ -382,7 +382,7 @@
provides a more flexible way of adding QObjects to the scripting
environment.
- \snippet doc/src/snippets/code/doc_src_porting-qsa.qdoc 17
+ \snippet doc/src/snippets/code/doc_src_porting-qsa.cpp 17
In the code above we create a QPushButton and wrap it in a script
value using the function, QScriptEngine::newQObject(). This gives us
@@ -404,14 +404,14 @@
Below is listed some code from the filter example in the QSA
package.
- \snippet doc/src/snippets/code/doc_src_porting-qsa.qdoc 18
+ \snippet doc/src/snippets/code/doc_src_porting-qsa.cpp 18
The equivalent in Qt Script is written in much the same way as
constructors are written in scripts. We register a callback C++
function under the name "ImageSource" in the global namespace and
return the QObject from this function:
- \snippet doc/src/snippets/code/doc_src_porting-qsa.qdoc 19
+ \snippet doc/src/snippets/code/doc_src_porting-qsa.cpp 19
In the Qt Script case we use the same approach that we use to expose
a QObject, namely via QScriptEngine::newQObject(). This function also
diff --git a/doc/src/porting/porting4-canvas.qdoc b/doc/src/porting/porting4-canvas.qdoc
index 445f66d352..1e20384d8e 100644
--- a/doc/src/porting/porting4-canvas.qdoc
+++ b/doc/src/porting/porting4-canvas.qdoc
@@ -152,7 +152,7 @@
\row \o Q3Canvas::onCanvas() \o The is no equivalent to this
function in Graphics View. However, you can combine
QGraphicsScene::sceneRect() and QRectF::intersects():
- \snippet doc/src/snippets/code/doc_src_porting4-canvas.qdoc 0
+ \snippet doc/src/snippets/code/doc_src_porting4-canvas.cpp 0
\row \o Q3Canvas::rect() \o The equivalent,
QGraphicsScene::sceneRect(), returns a QRectF (double
@@ -251,7 +251,7 @@
out the public tile API can then be declared as new members of
this class. Here is one example of how to implement tile support:
- \snippet doc/src/snippets/code/doc_src_porting4-canvas.qdoc 1
+ \snippet doc/src/snippets/code/doc_src_porting4-canvas.cpp 1
Depending on how your scene uses tiles, you may be able to
simplify this approach. In this example, we will try to mimic the behavior
@@ -264,30 +264,30 @@
two-dimensional vector of ints to keep track of what tiles should
be used at what parts of the scene.
- \snippet doc/src/snippets/code/doc_src_porting4-canvas.qdoc 2
+ \snippet doc/src/snippets/code/doc_src_porting4-canvas.cpp 2
In setTiles(), we store the pixmap and tile properties as
members of the class. Then we resize the tiles vector
to match the width and height of our tile grid.
- \snippet doc/src/snippets/code/doc_src_porting4-canvas.qdoc 3
+ \snippet doc/src/snippets/code/doc_src_porting4-canvas.cpp 3
The setTile() function updates the tiles index, and then
updates the corresponding rect in the scene by calling
tileRect().
- \snippet doc/src/snippets/code/doc_src_porting4-canvas.qdoc 4
+ \snippet doc/src/snippets/code/doc_src_porting4-canvas.cpp 4
The first tileRect() function returns a QRect for the tile at
position (x, y).
- \snippet doc/src/snippets/code/doc_src_porting4-canvas.qdoc 5
+ \snippet doc/src/snippets/code/doc_src_porting4-canvas.cpp 5
The second tileRect() function returns a QRect for a tile number.
With these functions in place, we can implement the drawBackground()
function.
- \snippet doc/src/snippets/code/doc_src_porting4-canvas.qdoc 6
+ \snippet doc/src/snippets/code/doc_src_porting4-canvas.cpp 6
In drawBackground(), we redraw all tiles that have been
exposed by intersecting each tile rect with the exposed background
@@ -522,7 +522,7 @@
For compatibility, you may want to shift the ellipse up and to the
left to keep the ellipse centered. Example:
- \snippet doc/src/snippets/code/doc_src_porting4-canvas.qdoc 7
+ \snippet doc/src/snippets/code/doc_src_porting4-canvas.cpp 7
Note: QGraphicsEllipseItem uses QAbstractGraphicsShapeItem::pen()
for outlines, whereas Q3CanvasEllipse did not use
@@ -588,7 +588,7 @@
QPainterPath::moveTo() and QPainterPath::cubicTo(). Here is how
you can convert a bezier curve Q3PointArray to a QPainterPath:
- \snippet doc/src/snippets/code/doc_src_porting4-canvas.qdoc 8
+ \snippet doc/src/snippets/code/doc_src_porting4-canvas.cpp 8
Note: QGraphicsPathItem uses QAbstractGraphicsShapeItem::pen() for
outlines, whereas Q3CanvasSpline did not use
@@ -653,7 +653,7 @@
functionality using Graphics View, you can load the images by
using QDir:
- \snippet doc/src/snippets/code/doc_src_porting4-canvas.qdoc 9
+ \snippet doc/src/snippets/code/doc_src_porting4-canvas.cpp 9
\section2 Q3CanvasText
diff --git a/doc/src/porting/porting4-designer.qdoc b/doc/src/porting/porting4-designer.qdoc
index d84af3f732..ef3e746dc1 100644
--- a/doc/src/porting/porting4-designer.qdoc
+++ b/doc/src/porting/porting4-designer.qdoc
@@ -104,7 +104,7 @@
For example, here's the \c uic output for a simple \c
helloworld.ui form (some details were removed for simplicity):
- \snippet doc/src/snippets/code/doc_src_porting4-designer.qdoc 0
+ \snippet doc/src/snippets/code/doc_src_porting4-designer.cpp 0
In this case, the main container was specified to be a QWidget
(or any subclass of QWidget). Had we started with a QMainWindow
@@ -116,7 +116,7 @@
an instance of the main container (a plain QWidget), and call \c
setupUi():
- \snippet doc/src/snippets/code/doc_src_porting4-designer.qdoc 1
+ \snippet doc/src/snippets/code/doc_src_porting4-designer.cpp 1
The second approach is to inherit from both the \c Ui::HelloWorld
class and the main container, and to call \c setupUi() in the
@@ -124,7 +124,7 @@
its subclasses, e.g. QDialog) must appear first in the base class
list so that \l{moc} picks it up correctly. For example:
- \snippet doc/src/snippets/code/doc_src_porting4-designer.qdoc 2
+ \snippet doc/src/snippets/code/doc_src_porting4-designer.cpp 2
This second method is useful when porting Qt 3 forms to Qt 4. \c
HelloWorldWidget is a class whose instance is the actual form
@@ -212,7 +212,7 @@
them to the widgets in the form after calling \c setupUi(). For
example:
- \snippet doc/src/snippets/code/doc_src_porting4-designer.qdoc 5
+ \snippet doc/src/snippets/code/doc_src_porting4-designer.cpp 5
A quick and dirty way to port forms containing custom signals and
slots is to generate the code using \c uic3, rather than \c uic. Since
@@ -233,7 +233,7 @@
\tt{\e{signalName}}, then this signal will be connected to the
main container's slot. For example:
- \snippet doc/src/snippets/code/doc_src_porting4-designer.qdoc 6
+ \snippet doc/src/snippets/code/doc_src_porting4-designer.cpp 6
Because of the naming convention, \c setupUi() automatically
connects \c pushButton's \c clicked() signal to \c
@@ -257,14 +257,14 @@
Next, we add the resource file to our \c .pro file:
- \snippet doc/src/snippets/code/doc_src_porting4-designer.qdoc 8
+ \snippet doc/src/snippets/code/doc_src_porting4-designer.pro 8
When \c qmake is run, it will create the appropriate Makefile
rules to call \c rcc on the resource file, and compile and link
the result into the application. The icons may be accessed as
follows:
- \snippet doc/src/snippets/code/doc_src_porting4-designer.qdoc 9
+ \snippet doc/src/snippets/code/doc_src_porting4-designer.cpp 9
In each case, the leading colon tells Qt to look for the file in
the virtual file tree defined by the set of resource files
diff --git a/doc/src/porting/porting4-dnd.qdoc b/doc/src/porting/porting4-dnd.qdoc
index 92b9fc17c4..993b8d2d15 100644
--- a/doc/src/porting/porting4-dnd.qdoc
+++ b/doc/src/porting/porting4-dnd.qdoc
@@ -54,7 +54,7 @@
\l{Q3DragObject::}{drag()} function is called, and it receives no information
about how the operation ended.
- \snippet doc/src/snippets/code/doc_src_dnd.qdoc 0
+ \snippet doc/src/snippets/code/doc_src_dnd.cpp 0
Similarly, in Qt 4, drag operations are also initiated when a QDrag object
is constructed and its \l{QDrag::}{exec()} function is called. In contrast,
@@ -94,7 +94,7 @@
indicating success or failure of these checks via the event's
\l{QDragEnterEvent::}{accept()} function, as shown in this simple example:
- \snippet doc/src/snippets/code/doc_src_dnd.qdoc 1
+ \snippet doc/src/snippets/code/doc_src_dnd.cpp 1
In Qt 4, you can examine the MIME type describing the data to determine
whether the widget should accept the event or, for common data types, you
@@ -113,7 +113,7 @@
accept dropped data in the form of text or images might provide an
implementation of \l{QWidget::}{dropEvent()} that looks like the following:
- \snippet doc/src/snippets/code/doc_src_dnd.qdoc 2
+ \snippet doc/src/snippets/code/doc_src_dnd.cpp 2
In Qt 4, the event is handled in a similar way:
diff --git a/doc/src/porting/porting4.qdoc b/doc/src/porting/porting4.qdoc
index a3960c3c85..1c11a025e6 100644
--- a/doc/src/porting/porting4.qdoc
+++ b/doc/src/porting/porting4.qdoc
@@ -760,7 +760,7 @@
function. The solution is to reimplement QWidget::paintEvent() in
your QAbstractButton subclass as follows:
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 0
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 0
\table
\header \o Q3Button function \o QAbstractButton equivalent
@@ -860,11 +860,11 @@
\o QMemArray::at() returned a non-const reference, whereas the
new QByteArray::at() returns a const value. Code like
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 1
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 1
will no longer compile. Instead, use QByteArray::operator[]:
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 2
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 2
\o The QMemArray::contains(char) function has been renamed
QByteArray::count(char). In addition, there now exists a
@@ -935,11 +935,11 @@
function returns \c void and either adds it to the cache or
deletes it right away. Old code like
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 3
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 3
becomes
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 4
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 4
\o The new QCache class \e always takes ownership of the items
it stores (i.e. auto-delete is always on). If you use Q3Cache
@@ -950,11 +950,11 @@
pointers, not the objects that the pointers refer to. For
example,
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 5
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 5
becomes
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 6
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 6
An alternative is to stick to using Q3Cache.
\endlist
@@ -1051,7 +1051,7 @@
you can simply replace colorGroup() with palette():
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 7
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 7
\section1 QColorDrag
@@ -1089,7 +1089,7 @@
'\\0' issue is handled by having QByteArray allocate one extra
byte that it always sets to '\\0'. For example:
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 8
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 8
The Qt3Support library contains a class called
Q3CString that inherits from the new QByteArray class and that
@@ -1416,26 +1416,26 @@
\header \o Q3Dict idiom \o QMultiHash idiom
\row
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 9
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 9
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 10
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 10
\row
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 11
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 11
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 12
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 12
\row
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 13
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 13
(also called from Q3Dict's destructor)
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 14
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 14
In 99% of cases, the following idiom also works:
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 15
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 15
However, it may lead to crashes if \c hash is referenced from
the value type's destructor, because \c hash contains
@@ -1471,11 +1471,11 @@
Be aware that QHashIterator has a different way of iterating than
Q3DictIterator. A typical loop with Q3DictIterator looks like this:
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 16
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 16
Here's the equivalent QHashIterator loop:
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 17
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 17
See \l{Java-style iterators} for details.
@@ -2377,7 +2377,7 @@
Use QObject::findChildren() instead of QObject::queryList().
For example:
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 18
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 18
QObject::killTimers() has been removed because it was unsafe to
use in subclass. (A subclass normally doesn't know whether the
@@ -2712,48 +2712,48 @@
\header \o QPtrList idiom \o QList idiom
\row
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 19
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 19
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 20
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 20
\row
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 21
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 21
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 22
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 22
\row
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 23
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 23
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 24
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 24
\row
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 25
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 25
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 26
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 26
\row
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 27
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 27
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 28
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 28
\row
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 29
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 29
(removes the current item)
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 30
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 30
\row
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 31
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 31
(also called from QPtrList's destructor)
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 32
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 32
In 99% of cases, the following idiom also works:
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 33
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 33
However, it may lead to crashes if \c list is referenced from
the value type's destructor, because \c list contains
@@ -2790,11 +2790,11 @@
Be aware that QListIterator has a different way of iterating than
QPtrList. A typical loop with QPtrList looks like this:
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 34
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 34
Here's the equivalent QListIterator loop:
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 35
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 35
Finally, QPtrListIterator<T> must also be ported. There are no
fewer than four iterator classes that can be used as a
@@ -2821,11 +2821,11 @@
iterating than QPtrList. A typical loop with QPtrList looks like
this:
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 36
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 36
Here's the equivalent QListIterator loop:
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 37
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 37
Finally, QPtrListStdIterator<T> must also be ported. This is
easy, because QList also provides STL-style iterators
@@ -2864,26 +2864,26 @@
\header \o QPtrQueue idiom \o QQueue idiom
\row
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 38
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 38
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 39
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 39
\row
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 40
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 40
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 41
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 41
\row
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 42
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 42
(also called from QPtrQueue's destructor)
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 43
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 43
In 99% of cases, the following idiom also works:
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 44
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 44
However, it may lead to crashes if \c queue is referenced
from the value type's destructor, because \c queue contains
@@ -2923,26 +2923,26 @@
\header \o QPtrStack idiom \o QStack idiom
\row
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 45
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 45
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 46
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 46
\row
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 47
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 47
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 48
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 48
\row
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 49
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 49
(also called from QPtrStack's destructor)
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 50
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 50
In 99% of cases, the following idiom also works:
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 51
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 51
However, it may lead to crashes if \c stack is referenced
from the value type's destructor, because \c stack contains
@@ -3024,36 +3024,36 @@
\header \o QPtrVector idiom \o QVector idiom
\row
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 52
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 52
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 53
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 53
\row
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 54
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 54
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 55
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 55
\row
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 56
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 56
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 57
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 57
\row
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 58
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 58
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 59
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 59
\row
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 60
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 60
(also called from QPtrVector's destructor)
\o
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 61
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 61
In 99% of cases, the following idiom also works:
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 62
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 62
However, it may lead to crashes if \c vect is referenced from
the value type's destructor, because \c vect contains
@@ -3193,7 +3193,7 @@
An easy way of porting to Qt 4 is to include this class into your
project and to use it instead of \c QShared:
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 63
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 63
If possible, we recommend that you use QSharedData and
QSharedDataPointer instead. They provide thread-safe reference
@@ -3217,11 +3217,11 @@
Previously, you would do the following with Q3SimpleRichText:
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 63a
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 63a
However, with QTextDocument, you use the following code instead:
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 63b
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 63b
See \l{Rich Text Processing} for an overview of the Qt 4 rich
text classes.
@@ -3233,7 +3233,7 @@
The slider's rect can now be retrieved using the code snippet below:
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 63c
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 63c
In addition, the direction of a vertical QSlider has changed,
i.e. the bottom is now the minimum, and the top the maximum. You
@@ -3454,7 +3454,7 @@
byte array; you should avoid taking a pointer to the data
contained in temporary objects.
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 64
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 64
In the above example, the \c goodData pointer is valid for the lifetime
of the \c asciiData byte array. If you need to keep a copy of the data
@@ -3464,11 +3464,11 @@
\o QString::at() returned a non-const reference, whereas the
new QString::at() returns a const value. Code like
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 65
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 65
will no longer compile. Instead, use QString::operator[]:
- \snippet doc/src/snippets/code/doc_src_porting4.qdoc 66
+ \snippet doc/src/snippets/code/doc_src_porting4.cpp 66
\o The QString::contains(\e x) function (where \e x is a
character or a string) has been renamed QString::count(\e x).
diff --git a/doc/src/porting/qt3to4.qdoc b/doc/src/porting/qt3to4.qdoc
index 336601f250..3c95b4c2c2 100644
--- a/doc/src/porting/qt3to4.qdoc
+++ b/doc/src/porting/qt3to4.qdoc
@@ -122,7 +122,7 @@
In some cases, you might get compiler errors because of identifiers
in the global namespace (e.g., \c CTRL). Adding
- \snippet doc/src/snippets/code/doc_src_qt3to4.qdoc 2
+ \snippet doc/src/snippets/code/doc_src_qt3to4.cpp 2
at the beginning of the source file that contains
the indentifier solves the problem.
diff --git a/doc/src/porting/qt4-accessibility.qdoc b/doc/src/porting/qt4-accessibility.qdoc
index 6e56942cbd..2d9e8c3fbb 100644
--- a/doc/src/porting/qt4-accessibility.qdoc
+++ b/doc/src/porting/qt4-accessibility.qdoc
@@ -68,7 +68,7 @@
variable set to 1. For example, this is set in the following way with
the bash shell:
- \snippet doc/src/snippets/code/doc_src_qt4-accessibility.qdoc environment
+ \snippet doc/src/snippets/code/doc_src_qt4-accessibility.cpp environment
Accessibility features are built into Qt by default when the libraries
are configured and built.
@@ -132,17 +132,17 @@
information for a custom widget. We can use QAccessibleWidget as
a base class and reimplement various functions:
- \snippet doc/src/snippets/code/doc_src_qt4-accessibility.qdoc 0
+ \snippet doc/src/snippets/code/doc_src_qt4-accessibility.cpp 0
Here's how we would implement the
\l{QAccessibleInterface::doAction()}{doAction()} function to call
a function named click() on the wrapped MyWidget object when the
user invokes the object's default action or "presses" it.
- \snippet doc/src/snippets/code/doc_src_qt4-accessibility.qdoc 1
+ \snippet doc/src/snippets/code/doc_src_qt4-accessibility.cpp 1
To export the widget interface as a plugin, we must subclass
QAccessibleFactory:
- \snippet doc/src/snippets/code/doc_src_qt4-accessibility.qdoc 2
+ \snippet doc/src/snippets/code/doc_src_qt4-accessibility.cpp 2
*/
diff --git a/doc/src/porting/qt4-arthur.qdoc b/doc/src/porting/qt4-arthur.qdoc
index 434aa292fe..460a0486d3 100644
--- a/doc/src/porting/qt4-arthur.qdoc
+++ b/doc/src/porting/qt4-arthur.qdoc
@@ -119,7 +119,7 @@
Setting a linear gradient brush is done by creating a QLinearGradient
object and setting it as a brush.
- \snippet doc/src/snippets/code/doc_src_qt4-arthur.qdoc 0
+ \snippet doc/src/snippets/code/doc_src_qt4-arthur.cpp 0
The code shown above produces a pattern as show in the following
pixmap:
@@ -130,7 +130,7 @@
focal point. Setting a radial brush is done by creating a QRadialGradient
object and setting it as a brush.
- \snippet doc/src/snippets/code/doc_src_qt4-arthur.qdoc 1
+ \snippet doc/src/snippets/code/doc_src_qt4-arthur.cpp 1
The code shown above produces a pattern as shown in the following
pixmap:
@@ -141,7 +141,7 @@
angle. Setting a conical brush is done by creating a
QConicalGradient object and setting it as a brush.
- \snippet doc/src/snippets/code/doc_src_qt4-arthur.qdoc 2
+ \snippet doc/src/snippets/code/doc_src_qt4-arthur.cpp 2
The code shown above produces a pattern as shown in the following
pixmap:
@@ -156,7 +156,7 @@
transparent color, while 255 represents a fully opaque color. For
example:
- \snippet doc/src/snippets/code/doc_src_qt4-arthur.qdoc 3
+ \snippet doc/src/snippets/code/doc_src_qt4-arthur.cpp 3
The code shown above produces the following output:
@@ -180,7 +180,7 @@
provide the option of turning on anti-aliased edges when drawing
graphics primitives.
- \snippet doc/src/snippets/code/doc_src_qt4-arthur.qdoc 4
+ \snippet doc/src/snippets/code/doc_src_qt4-arthur.cpp 4
This produces the following output:
@@ -221,7 +221,7 @@
first add a rectangle, which becomes a closed subpath. We then add
two bezier curves, and finally draw the entire path.
- \snippet doc/src/snippets/code/doc_src_qt4-arthur.qdoc 5
+ \snippet doc/src/snippets/code/doc_src_qt4-arthur.cpp 5
The code above produces the following output:
@@ -236,18 +236,18 @@
painting to an off-screen pixmap then copying the pixmap to the
screen. For example:
- \snippet doc/src/snippets/code/doc_src_qt4-arthur.qdoc 6
+ \snippet doc/src/snippets/code/doc_src_qt4-arthur.cpp 6
Since the double-buffering is handled by QWidget internally this
now becomes:
- \snippet doc/src/snippets/code/doc_src_qt4-arthur.qdoc 7
+ \snippet doc/src/snippets/code/doc_src_qt4-arthur.cpp 7
Double-buffering is turned on by default, but can be turned off for
individual widgets by setting the widget attribute
Qt::WA_PaintOnScreen.
- \snippet doc/src/snippets/code/doc_src_qt4-arthur.qdoc 8
+ \snippet doc/src/snippets/code/doc_src_qt4-arthur.cpp 8
\section2 Pen and Brush Transformation
@@ -270,7 +270,7 @@
possible to specify both texture and gradient fills for both
text and outlines.
- \snippet doc/src/snippets/code/doc_src_qt4-arthur.qdoc 9
+ \snippet doc/src/snippets/code/doc_src_qt4-arthur.cpp 9
The code above produces the following output:
@@ -290,7 +290,7 @@
Painting on an image is as simple as drawing on any other paint device.
- \snippet doc/src/snippets/code/doc_src_qt4-arthur.qdoc 10
+ \snippet doc/src/snippets/code/doc_src_qt4-arthur.cpp 10
\section2 SVG Rendering Support
diff --git a/doc/src/porting/qt4-mainwindow.qdoc b/doc/src/porting/qt4-mainwindow.qdoc
index 1eff2c25ed..ebfbc8d2d5 100644
--- a/doc/src/porting/qt4-mainwindow.qdoc
+++ b/doc/src/porting/qt4-mainwindow.qdoc
@@ -86,7 +86,7 @@
the first time it is called. You can also call
QMainWindow::setMenuBar() to use a custom menu bar in the main window.
- \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.qdoc 0
+ \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.cpp 0
\dots
\snippet examples/mainwindows/menus/mainwindow.cpp 5
\dots
@@ -110,7 +110,7 @@
\snippet examples/mainwindows/sdi/mainwindow.cpp 0
\dots
- \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.qdoc 1
+ \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.cpp 1
In this example, the toolbar is restricted to the top and bottom
toolbar areas of the main window, and is initially placed in the
@@ -132,7 +132,7 @@
required, the default can be changed with the
QMainWindow::setCorner() function:
- \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.qdoc 2
+ \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.cpp 2
The following diagram shows the configuration produced by the above code.
Note that the left and right dock widgets will occupy the top and bottom
@@ -143,7 +143,7 @@
Once all of the main window components have been set up, the central widget
is created and installed by using code similar to the following:
- \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.qdoc 3
+ \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.cpp 3
The central widget can be any subclass of QWidget.
@@ -217,17 +217,17 @@
constructed using the general QMenu class.
Qt 3:
- \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.qdoc 4
+ \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.cpp 4
Qt 4:
- \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.qdoc 5
+ \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.cpp 5
Toolbars follow the same pattern as menus, with the new, more
consistent behavior:
Qt 3:
- \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.qdoc 6
+ \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.cpp 6
Qt 4:
- \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.qdoc 7
+ \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.cpp 7
The behavior of dock widgets is now configured through the member
functions of QDockWidget. For example, compare the old and new ways
@@ -235,7 +235,7 @@
main window.
In Qt 3:
- \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.qdoc 8
+ \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.cpp 8
In Qt 4:
- \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.qdoc 9
+ \snippet doc/src/snippets/code/doc_src_qt4-mainwindow.cpp 9
*/
diff --git a/doc/src/porting/qt4-sql.qdoc b/doc/src/porting/qt4-sql.qdoc
index bafaacb6b7..2a5a206825 100644
--- a/doc/src/porting/qt4-sql.qdoc
+++ b/doc/src/porting/qt4-sql.qdoc
@@ -104,12 +104,12 @@
The simplest way to present data from a database is to simply
combine a QSqlQueryModel with a QTableView:
- \snippet doc/src/snippets/code/doc_src_qt4-sql.qdoc 0
+ \snippet doc/src/snippets/code/doc_src_qt4-sql.cpp 0
To present the contents of a single table, we can use
QSqlTableModel instead:
- \snippet doc/src/snippets/code/doc_src_qt4-sql.qdoc 1
+ \snippet doc/src/snippets/code/doc_src_qt4-sql.cpp 1
In practice, it's common that we need to customize the rendering
of a field in the database. In that case, we can create our own
diff --git a/doc/src/porting/qt4-styles.qdoc b/doc/src/porting/qt4-styles.qdoc
index 76b0b1cbdf..7422f0641c 100644
--- a/doc/src/porting/qt4-styles.qdoc
+++ b/doc/src/porting/qt4-styles.qdoc
@@ -90,7 +90,7 @@
pointer type is correct. If the object isn't of the right type,
qstyleoption_cast() returns 0. For example:
- \snippet doc/src/snippets/code/doc_src_qt4-styles.qdoc 0
+ \snippet doc/src/snippets/code/doc_src_qt4-styles.cpp 0
For performance reasons, there are few member functions and the
access to the variables is direct. This "low-level" feel makes
@@ -108,7 +108,7 @@
The following code snippet illustrates how to use QStyle to
draw the focus rectangle from a custom widget's paintEvent():
- \snippet doc/src/snippets/code/doc_src_qt4-styles.qdoc 1
+ \snippet doc/src/snippets/code/doc_src_qt4-styles.cpp 1
The next example shows how to derive from an existing style to
customize the look of a graphical element:
@@ -130,11 +130,11 @@
For example, here's the signature of the QStyle::drawControl()
function in Qt 3:
- \snippet doc/src/snippets/code/doc_src_qt4-styles.qdoc 2
+ \snippet doc/src/snippets/code/doc_src_qt4-styles.cpp 2
Here's the signature of the same function in Qt 4:
- \snippet doc/src/snippets/code/doc_src_qt4-styles.qdoc 3
+ \snippet doc/src/snippets/code/doc_src_qt4-styles.cpp 3
In Qt 3, some of the information required to draw a graphical
element was stored in a QStyleOption parameter, while the rest
diff --git a/doc/src/porting/qt4-tulip.qdoc b/doc/src/porting/qt4-tulip.qdoc
index 161c373c07..c78ff96542 100644
--- a/doc/src/porting/qt4-tulip.qdoc
+++ b/doc/src/porting/qt4-tulip.qdoc
@@ -80,16 +80,16 @@
addition to the C++ language that is implemented using the standard
C++ preprocessor. The syntax is:
- \snippet doc/src/snippets/code/doc_src_qt4-tulip.qdoc 0
+ \snippet doc/src/snippets/code/doc_src_qt4-tulip.cpp 0
Example:
- \snippet doc/src/snippets/code/doc_src_qt4-tulip.qdoc 1
+ \snippet doc/src/snippets/code/doc_src_qt4-tulip.cpp 1
The iterator variable can also be defined outside the loop. For
example:
- \snippet doc/src/snippets/code/doc_src_qt4-tulip.qdoc 2
+ \snippet doc/src/snippets/code/doc_src_qt4-tulip.cpp 2
Just like standard \c for loops, foreach supports braces, \c
break, \c continue, and nested loops. Qt makes a copy of the
@@ -124,25 +124,25 @@
Traversing a container using a Java-style iterator:
- \snippet doc/src/snippets/code/doc_src_qt4-tulip.qdoc 3
+ \snippet doc/src/snippets/code/doc_src_qt4-tulip.cpp 3
Modifying items using a Java-style iterator:
- \snippet doc/src/snippets/code/doc_src_qt4-tulip.qdoc 4
+ \snippet doc/src/snippets/code/doc_src_qt4-tulip.cpp 4
Removing items using a Java-style iterator:
- \snippet doc/src/snippets/code/doc_src_qt4-tulip.qdoc 5
+ \snippet doc/src/snippets/code/doc_src_qt4-tulip.cpp 5
Iterating over items with a particular value using STL-style vs.
Java-style iterators:
- \snippet doc/src/snippets/code/doc_src_qt4-tulip.qdoc 6
+ \snippet doc/src/snippets/code/doc_src_qt4-tulip.cpp 6
Modifying and removing items using STL-style vs. Java-style
iterators:
- \snippet doc/src/snippets/code/doc_src_qt4-tulip.qdoc 7
+ \snippet doc/src/snippets/code/doc_src_qt4-tulip.cpp 7
The next group of examples show the API of the container classes
themselves. The API is similar to the QTL classes of Qt 3, but is nicer
@@ -151,16 +151,16 @@
Iterating over a QList using an index (which is fast even for large
lists, because QList is implemented as an array-list):
- \snippet doc/src/snippets/code/doc_src_qt4-tulip.qdoc 8
+ \snippet doc/src/snippets/code/doc_src_qt4-tulip.cpp 8
Retrieving a value from a map, using a default value if the key
doesn't exist:
- \snippet doc/src/snippets/code/doc_src_qt4-tulip.qdoc 9
+ \snippet doc/src/snippets/code/doc_src_qt4-tulip.cpp 9
Getting all the values for a particular key in a QMultiMap or QMultiHash:
- \snippet doc/src/snippets/code/doc_src_qt4-tulip.qdoc 10
+ \snippet doc/src/snippets/code/doc_src_qt4-tulip.cpp 10
\section1 Comparison with Qt 3