From d16c565ca6a55788435c52ad45647eda67854d80 Mon Sep 17 00:00:00 2001 From: Frederik Gladhorn Date: Tue, 18 Sep 2012 20:32:53 +0200 Subject: Move opengl/wid/net example docs to proper folders. Change-Id: I846439a9cf7ad965ed27a00f98dbc4ff97abe73b Reviewed-by: Jerome Pasion Reviewed-by: Martin Smith --- doc/src/examples/2dpainting.qdoc | 210 --------- doc/src/examples/applicationicon.qdoc | 67 --- doc/src/examples/bearermonitor.qdoc | 2 +- doc/src/examples/blockingfortuneclient.qdoc | 216 --------- doc/src/examples/books.qdoc | 2 +- doc/src/examples/broadcastreceiver.qdoc | 36 -- doc/src/examples/broadcastsender.qdoc | 36 -- doc/src/examples/cachedtable.qdoc | 197 -------- doc/src/examples/codecs.qdoc | 2 +- doc/src/examples/completer.qdoc | 2 +- doc/src/examples/complexpingpong.qdoc | 2 +- doc/src/examples/contiguouscache.qdoc | 2 +- doc/src/examples/cube.qdoc | 178 ------- doc/src/examples/customcompleter.qdoc | 187 -------- doc/src/examples/customtype.qdoc | 143 ------ doc/src/examples/draggableicons.qdoc | 90 ---- doc/src/examples/draggabletext.qdoc | 36 -- doc/src/examples/drilldown.qdoc | 536 ---------------------- doc/src/examples/fortuneclient.qdoc | 160 ------- doc/src/examples/fortuneserver.qdoc | 105 ----- doc/src/examples/framebufferobject2.qdoc | 37 -- doc/src/examples/googlesuggest.qdoc | 180 -------- doc/src/examples/grabber.qdoc | 35 -- doc/src/examples/hellogl.qdoc | 305 ------------ doc/src/examples/hellogl_es.qdoc | 128 ------ doc/src/examples/http.qdoc | 36 -- doc/src/examples/loopback.qdoc | 36 -- doc/src/examples/masterdetail.qdoc | 43 -- doc/src/examples/multicastreceiver.qdoc | 36 -- doc/src/examples/multicastsender.qdoc | 36 -- doc/src/examples/network-chat.qdoc | 37 -- doc/src/examples/overpainting.qdoc | 243 ---------- doc/src/examples/pbuffers.qdoc | 37 -- doc/src/examples/pbuffers2.qdoc | 37 -- doc/src/examples/querymodel.qdoc | 37 -- doc/src/examples/relationaltablemodel.qdoc | 36 -- doc/src/examples/samplebuffers.qdoc | 36 -- doc/src/examples/saxbookmarks.qdoc | 40 -- doc/src/examples/securesocketclient.qdoc | 39 -- doc/src/examples/sqlbrowser.qdoc | 36 -- doc/src/examples/sqlwidgetmapper.qdoc | 185 -------- doc/src/examples/tablemodel.qdoc | 36 -- doc/src/examples/textures.qdoc | 36 -- doc/src/examples/threadedfortuneserver.qdoc | 107 ----- doc/src/examples/torrent.qdoc | 69 --- doc/src/images/2dpainting-example.png | Bin 32682 -> 0 bytes doc/src/images/blockingfortuneclient-example.png | Bin 9199 -> 0 bytes doc/src/images/broadcastreceiver-example.png | Bin 7447 -> 0 bytes doc/src/images/broadcastsender-example.png | Bin 5688 -> 0 bytes doc/src/images/cachedtable-example.png | Bin 15908 -> 0 bytes doc/src/images/cube.png | Bin 40459 -> 0 bytes doc/src/images/cube_faces.png | Bin 63082 -> 0 bytes doc/src/images/drilldown-example.png | Bin 128081 -> 0 bytes doc/src/images/fortuneclient-example.png | Bin 8282 -> 0 bytes doc/src/images/fortuneserver-example.png | Bin 7883 -> 0 bytes doc/src/images/framebufferobject2-example.png | Bin 203754 -> 0 bytes doc/src/images/googlesuggest-example.png | Bin 9006 -> 0 bytes doc/src/images/grabber-example.png | Bin 9893 -> 0 bytes doc/src/images/hellogl-es-example.png | Bin 61110 -> 0 bytes doc/src/images/hellogl-example.png | Bin 9520 -> 0 bytes doc/src/images/http-example.png | Bin 7006 -> 0 bytes doc/src/images/loopback-example.png | Bin 6195 -> 0 bytes doc/src/images/masterdetail-example.png | Bin 104228 -> 0 bytes doc/src/images/multicastreceiver-example.png | Bin 13042 -> 0 bytes doc/src/images/multicastsender-example.png | Bin 21092 -> 0 bytes doc/src/images/network-chat-example.png | Bin 17453 -> 0 bytes doc/src/images/overpainting-example.png | Bin 67841 -> 0 bytes doc/src/images/pbuffers-example.png | Bin 192554 -> 0 bytes doc/src/images/pbuffers2-example.png | Bin 176171 -> 0 bytes doc/src/images/querymodel-example.png | Bin 30882 -> 0 bytes doc/src/images/relationaltablemodel-example.png | Bin 10188 -> 0 bytes doc/src/images/samplebuffers-example.png | Bin 16292 -> 0 bytes doc/src/images/saxbookmarks-example.png | Bin 26219 -> 0 bytes doc/src/images/securesocketclient.png | Bin 12056 -> 0 bytes doc/src/images/securesocketclient2.png | Bin 15532 -> 0 bytes doc/src/images/sql-widget-mapper.png | Bin 13040 -> 0 bytes doc/src/images/sqlbrowser-demo.png | Bin 20671 -> 0 bytes doc/src/images/tablemodel-example.png | Bin 20904 -> 0 bytes doc/src/images/textures-example.png | Bin 46640 -> 0 bytes doc/src/images/threadedfortuneserver-example.png | Bin 8528 -> 0 bytes doc/src/images/torrent-example.png | Bin 18915 -> 0 bytes doc/src/images/widgetmapper-sql-mapping-table.png | Bin 39681 -> 0 bytes doc/src/images/widgetmapper-sql-mapping.png | Bin 60265 -> 0 bytes 83 files changed, 6 insertions(+), 4086 deletions(-) delete mode 100644 doc/src/examples/2dpainting.qdoc delete mode 100644 doc/src/examples/applicationicon.qdoc delete mode 100644 doc/src/examples/blockingfortuneclient.qdoc delete mode 100644 doc/src/examples/broadcastreceiver.qdoc delete mode 100644 doc/src/examples/broadcastsender.qdoc delete mode 100644 doc/src/examples/cachedtable.qdoc delete mode 100644 doc/src/examples/cube.qdoc delete mode 100644 doc/src/examples/customcompleter.qdoc delete mode 100644 doc/src/examples/customtype.qdoc delete mode 100644 doc/src/examples/draggableicons.qdoc delete mode 100644 doc/src/examples/draggabletext.qdoc delete mode 100644 doc/src/examples/drilldown.qdoc delete mode 100644 doc/src/examples/fortuneclient.qdoc delete mode 100644 doc/src/examples/fortuneserver.qdoc delete mode 100644 doc/src/examples/framebufferobject2.qdoc delete mode 100644 doc/src/examples/googlesuggest.qdoc delete mode 100644 doc/src/examples/grabber.qdoc delete mode 100644 doc/src/examples/hellogl.qdoc delete mode 100644 doc/src/examples/hellogl_es.qdoc delete mode 100644 doc/src/examples/http.qdoc delete mode 100644 doc/src/examples/loopback.qdoc delete mode 100644 doc/src/examples/masterdetail.qdoc delete mode 100644 doc/src/examples/multicastreceiver.qdoc delete mode 100644 doc/src/examples/multicastsender.qdoc delete mode 100644 doc/src/examples/network-chat.qdoc delete mode 100644 doc/src/examples/overpainting.qdoc delete mode 100644 doc/src/examples/pbuffers.qdoc delete mode 100644 doc/src/examples/pbuffers2.qdoc delete mode 100644 doc/src/examples/querymodel.qdoc delete mode 100644 doc/src/examples/relationaltablemodel.qdoc delete mode 100644 doc/src/examples/samplebuffers.qdoc delete mode 100644 doc/src/examples/saxbookmarks.qdoc delete mode 100644 doc/src/examples/securesocketclient.qdoc delete mode 100644 doc/src/examples/sqlbrowser.qdoc delete mode 100644 doc/src/examples/sqlwidgetmapper.qdoc delete mode 100644 doc/src/examples/tablemodel.qdoc delete mode 100644 doc/src/examples/textures.qdoc delete mode 100644 doc/src/examples/threadedfortuneserver.qdoc delete mode 100644 doc/src/examples/torrent.qdoc delete mode 100644 doc/src/images/2dpainting-example.png delete mode 100644 doc/src/images/blockingfortuneclient-example.png delete mode 100644 doc/src/images/broadcastreceiver-example.png delete mode 100644 doc/src/images/broadcastsender-example.png delete mode 100644 doc/src/images/cachedtable-example.png delete mode 100644 doc/src/images/cube.png delete mode 100644 doc/src/images/cube_faces.png delete mode 100644 doc/src/images/drilldown-example.png delete mode 100644 doc/src/images/fortuneclient-example.png delete mode 100644 doc/src/images/fortuneserver-example.png delete mode 100644 doc/src/images/framebufferobject2-example.png delete mode 100644 doc/src/images/googlesuggest-example.png delete mode 100644 doc/src/images/grabber-example.png delete mode 100644 doc/src/images/hellogl-es-example.png delete mode 100644 doc/src/images/hellogl-example.png delete mode 100644 doc/src/images/http-example.png delete mode 100644 doc/src/images/loopback-example.png delete mode 100644 doc/src/images/masterdetail-example.png delete mode 100644 doc/src/images/multicastreceiver-example.png delete mode 100644 doc/src/images/multicastsender-example.png delete mode 100644 doc/src/images/network-chat-example.png delete mode 100644 doc/src/images/overpainting-example.png delete mode 100644 doc/src/images/pbuffers-example.png delete mode 100644 doc/src/images/pbuffers2-example.png delete mode 100644 doc/src/images/querymodel-example.png delete mode 100644 doc/src/images/relationaltablemodel-example.png delete mode 100644 doc/src/images/samplebuffers-example.png delete mode 100644 doc/src/images/saxbookmarks-example.png delete mode 100644 doc/src/images/securesocketclient.png delete mode 100644 doc/src/images/securesocketclient2.png delete mode 100644 doc/src/images/sql-widget-mapper.png delete mode 100644 doc/src/images/sqlbrowser-demo.png delete mode 100644 doc/src/images/tablemodel-example.png delete mode 100644 doc/src/images/textures-example.png delete mode 100644 doc/src/images/threadedfortuneserver-example.png delete mode 100644 doc/src/images/torrent-example.png delete mode 100644 doc/src/images/widgetmapper-sql-mapping-table.png delete mode 100644 doc/src/images/widgetmapper-sql-mapping.png (limited to 'doc') diff --git a/doc/src/examples/2dpainting.qdoc b/doc/src/examples/2dpainting.qdoc deleted file mode 100644 index d2d19b6e3b..0000000000 --- a/doc/src/examples/2dpainting.qdoc +++ /dev/null @@ -1,210 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example opengl/2dpainting - \title 2D Painting Example - - The 2D Painting example shows how QPainter and QGLWidget can be used - together to display accelerated 2D graphics on supported hardware. - - \image 2dpainting-example.png - - The QPainter class is used to draw 2D graphics primitives onto - paint devices provided by QPaintDevice subclasses, such as QWidget - and QImage. - - Since QGLWidget is a subclass of QWidget, it is possible - to reimplement its \l{QWidget::paintEvent()}{paintEvent()} and use - QPainter to draw on the device, just as you would with a QWidget. - The only difference is that the painting operations will be accelerated - in hardware if it is supported by your system's OpenGL drivers. - - In this example, we perform the same painting operations on a - QWidget and a QGLWidget. The QWidget is shown with anti-aliasing - enabled, and the QGLWidget will also use anti-aliasing if the - required extensions are supported by your system's OpenGL driver. - - \section1 Overview - - To be able to compare the results of painting onto a QGLWidget subclass - with native drawing in a QWidget subclass, we want to show both kinds - of widget side by side. To do this, we derive subclasses of QWidget and - QGLWidget, using a separate \c Helper class to perform the same painting - operations for each, and lay them out in a top-level widget, itself - provided a the \c Window class. - - \section1 Helper Class Definition - - In this example, the painting operations are performed by a helper class. - We do this because we want the same painting operations to be performed - for both our QWidget subclass and the QGLWidget subclass. - - The \c Helper class is minimal: - - \snippet examples/opengl/2dpainting/helper.h 0 - - Apart from the constructor, it only provides a \c paint() function to paint - using a painter supplied by one of our widget subclasses. - - \section1 Helper Class Implementation - - The constructor of the class sets up the resources it needs to paint - content onto a widget: - - \snippet examples/opengl/2dpainting/helper.cpp 0 - - The actual painting is performed in the \c paint() function. This takes - a QPainter that has already been set up to paint onto a paint device - (either a QWidget or a QGLWidget), a QPaintEvent that provides information - about the region to be painted, and a measure of the elapsed time (in - milliseconds) since the paint device was last updated. - - \snippet examples/opengl/2dpainting/helper.cpp 1 - - We begin painting by filling in the region contained in the paint event - before translating the origin of the coordinate system so that the rest - of the painting operations will be displaced towards the center of the - paint device. - - We draw a spiral pattern of circles, using the elapsed time specified to - animate them so that they appear to move outward and around the coordinate - system's origin: - - \snippet examples/opengl/2dpainting/helper.cpp 2 - - Since the coordinate system is rotated many times during - this process, we \l{QPainter::save()}{save()} the QPainter's state - beforehand and \l{QPainter::restore()}{restore()} it afterwards. - - \snippet examples/opengl/2dpainting/helper.cpp 3 - - We draw some text at the origin to complete the effect. - - \section1 Widget Class Definition - - The \c Widget class provides a basic custom widget that we use to - display the simple animation painted by the \c Helper class. - - \snippet examples/opengl/2dpainting/widget.h 0 - - Apart from the constructor, it only contains a - \l{QWidget::paintEvent()}{paintEvent()} function, that lets us draw - customized content, and a slot that is used to animate its contents. - One member variable keeps track of the \c Helper that the widget uses - to paint its contents, and the other records the elapsed time since - it was last updated. - - \section1 Widget Class Implementation - - The constructor only initializes the member variables, storing the - \c Helper object supplied and calling the base class's constructor, - and enforces a fixed size for the widget: - - \snippet examples/opengl/2dpainting/widget.cpp 0 - - The \c animate() slot is called whenever a timer, which we define later, times - out: - - \snippet examples/opengl/2dpainting/widget.cpp 1 - - Here, we determine the interval that has elapsed since the timer last - timed out, and we add it to any existing value before repainting the - widget. Since the animation used in the \c Helper class loops every second, - we can use the modulo operator to ensure that the \c elapsed variable is - always less than 1000. - - Since the \c Helper class does all of the actual painting, we only have - to implement a paint event that sets up a QPainter for the widget and calls - the helper's \c paint() function: - - \snippet examples/opengl/2dpainting/widget.cpp 2 - - \section1 GLWidget Class Definition - - The \c GLWidget class definition is basically the same as the \c Widget - class except that it is derived from QGLWidget. - - \snippet examples/opengl/2dpainting/glwidget.h 0 - - Again, the member variables record the \c Helper used to paint the - widget and the elapsed time since the previous update. - - \section1 GLWidget Class Implementation - - The constructor differs a little from the \c Widget class's constructor: - - \snippet examples/opengl/2dpainting/glwidget.cpp 0 - - As well as initializing the \c elapsed member variable and storing the - \c Helper object used to paint the widget, the base class's constructor - is called with the format that specifies the \l QGL::SampleBuffers flag. - This enables anti-aliasing if it is supported by your system's OpenGL - driver. - - The \c animate() slot is exactly the same as that provided by the \c Widget - class: - - \snippet examples/opengl/2dpainting/glwidget.cpp 1 - - The \c paintEvent() is almost the same as that found in the \c Widget class: - - \snippet examples/opengl/2dpainting/glwidget.cpp 2 - - Since anti-aliasing will be enabled if available, we only need to set up - a QPainter on the widget and call the helper's \c paint() function to display - the widget's contents. - - \section1 Window Class Definition - - The \c Window class has a basic, minimal definition: - - \snippet examples/opengl/2dpainting/window.h 0 - - It contains a single \c Helper object that will be shared between all - widgets. - - \section1 Window Class Implementation - - The constructor does all the work, creating a widget of each type and - inserting them with labels into a layout: - - \snippet examples/opengl/2dpainting/window.cpp 0 - - A timer with a 50 millisecond time out is constructed for animation purposes, - and connected to the \c animate() slots of the \c Widget and \c GLWidget objects. - Once started, the widgets should be updated at around 20 frames per second. - - \section1 Running the Example - - The example shows the same painting operations performed at the same time - in a \c Widget and a \c GLWidget. The quality and speed of rendering in the - \c GLWidget depends on the level of support for multisampling and hardware - acceleration that your system's OpenGL driver provides. If support for either - of these is lacking, the driver may fall back on a software renderer that - may trade quality for speed. -*/ diff --git a/doc/src/examples/applicationicon.qdoc b/doc/src/examples/applicationicon.qdoc deleted file mode 100644 index 6f54ff6bfd..0000000000 --- a/doc/src/examples/applicationicon.qdoc +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! \example widgets/applicationicon - \group all-examples - \title Application Icon Example - - The example shows how to add an application icon to a mobile application. - - \image appicon_screenshot.png The icon on a Nokia XPressMusic 5800 - - \section1 Creating an icon for Maemo - - Maemo expects the icon of an application to be a 64x64 PNG image file. The - file name of the icon should be the same as the executable with a \c .png - extension. You also need a \c .desktop file that gives the window manager - hints about the application, such as name, type and icon. - - \quotefile examples/widgets/applicationicon/applicationicon.desktop - - The \c Icon field should also contain the name of the executable. On the - device, application icons are stored in the - \c /usr/share/icons/hicolor/64x64/apps directory - and desktop files in the \c /usr/share/applications/hildon directory. - - \section1 Adding the icons to the project - - For Maemo, we need to add that the \c .desktop and icon file should be - installed. - - \quotefile examples/widgets/applicationicon/applicationicon.pro - - Currently, Qt Creator doesn't include the icon and desktop files in the - application package for Maemo, merely the executable file is included. As a - workaround for this, the files can be added manually in the Projects tab. - In the "Create Package" build step for the Maemo target, the \c .desktop - file and icon can be added to be a part of the package contents. - Unfortunately, these additions are only stored as a part of the - \c .pro.user file. This issue will be resolved in a future release of - Qt Creator. - - \image appicon_packagecontents.png Manual addition of files to the "Create Package" build step -*/ diff --git a/doc/src/examples/bearermonitor.qdoc b/doc/src/examples/bearermonitor.qdoc index 07c142a0e6..419fd87267 100644 --- a/doc/src/examples/bearermonitor.qdoc +++ b/doc/src/examples/bearermonitor.qdoc @@ -26,7 +26,7 @@ ****************************************************************************/ /*! - \example network/bearermonitor + \example bearermonitor \title Bearer Monitor Example The Bearer Monitor example shows how to use the Bearer Management API. diff --git a/doc/src/examples/blockingfortuneclient.qdoc b/doc/src/examples/blockingfortuneclient.qdoc deleted file mode 100644 index 6c3be78859..0000000000 --- a/doc/src/examples/blockingfortuneclient.qdoc +++ /dev/null @@ -1,216 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example network/blockingfortuneclient - \title Blocking Fortune Client Example - - The Blocking Fortune Client example shows how to create a client for a - network service using QTcpSocket's synchronous API in a non-GUI thread. - - \image blockingfortuneclient-example.png - - QTcpSocket supports two general approaches to network programming: - - \list - - \li \e{The asynchronous (non-blocking) approach.} Operations are scheduled - and performed when control returns to Qt's event loop. When the operation - is finished, QTcpSocket emits a signal. For example, - QTcpSocket::connectToHost() returns immediately, and when the connection - has been established, QTcpSocket emits - \l{QTcpSocket::connected()}{connected()}. - - \li \e{The synchronous (blocking) approach.} In non-GUI and multithreaded - applications, you can call the \c waitFor...() functions (e.g., - QTcpSocket::waitForConnected()) to suspend the calling thread until the - operation has completed, instead of connecting to signals. - - \endlist - - The implementation is very similar to the - \l{network/fortuneclient}{Fortune Client} example, but instead of having - QTcpSocket as a member of the main class, doing asynchronous networking in - the main thread, we will do all network operations in a separate thread - and use QTcpSocket's blocking API. - - The purpose of this example is to demonstrate a pattern that you can use - to simplify your networking code, without losing responsiveness in your - user interface. Use of Qt's blocking network API often leads to - simpler code, but because of its blocking behavior, it should only be used - in non-GUI threads to prevent the user interface from freezing. But - contrary to what many think, using threads with QThread does not - necessarily add unmanagable complexity to your application. - - We will start with the FortuneThread class, which handles the network - code. - - \snippet examples/network/blockingfortuneclient/fortunethread.h 0 - - FortuneThread is a QThread subclass that provides an API for scheduling - requests for fortunes, and it has signals for delivering fortunes and - reporting errors. You can call requestNewFortune() to request a new - fortune, and the result is delivered by the newFortune() signal. If any - error occurs, the error() signal is emitted. - - It's important to notice that requestNewFortune() is called from the main, - GUI thread, but the host name and port values it stores will be accessed - from FortuneThread's thread. Because we will be reading and writing - FortuneThread's data members from different threads concurrently, we use - QMutex to synchronize access. - - \snippet examples/network/blockingfortuneclient/fortunethread.cpp 2 - - The requestNewFortune() function stores the host name and port of the - fortune server as member data, and we lock the mutex with QMutexLocker to - protect this data. We then start the thread, unless it is already - running. We will come back to the QWaitCondition::wakeOne() call later. - - \snippet examples/network/blockingfortuneclient/fortunethread.cpp 4 - \snippet examples/network/blockingfortuneclient/fortunethread.cpp 5 - - In the run() function, we start by acquiring the mutex lock, fetching the - host name and port from the member data, and then releasing the lock - again. The case that we are protecting ourselves against is that \c - requestNewFortune() could be called at the same time as we are fetching - this data. QString is \l reentrant but \e not \l{thread-safe}, and we must - also avoid the unlikely risk of reading the host name from one request, - and port of another. And as you might have guessed, FortuneThread can only - handle one request at a time. - - The run() function now enters a loop: - - \snippet examples/network/blockingfortuneclient/fortunethread.cpp 6 - - The loop will continue requesting fortunes for as long as \e quit is - false. We start our first request by creating a QTcpSocket on the stack, - and then we call \l{QTcpSocket::connectToHost()}{connectToHost()}. This - starts an asynchronous operation which, after control returns to Qt's - event loop, will cause QTcpSocket to emit - \l{QTcpSocket::connected()}{connected()} or - \l{QTcpSocket::error()}{error()}. - - \snippet examples/network/blockingfortuneclient/fortunethread.cpp 8 - - But since we are running in a non-GUI thread, we do not have to worry - about blocking the user interface. So instead of entering an event loop, - we simply call QTcpSocket::waitForConnected(). This function will wait, - blocking the calling thread, until QTcpSocket emits connected() or an - error occurs. If connected() is emitted, the function returns true; if the - connection failed or timed out (which in this example happens after 5 - seconds), false is returned. QTcpSocket::waitForConnected(), like the - other \c waitFor...() functions, is part of QTcpSocket's \e{blocking - API}. - - After this statement, we have a connected socket to work with. Now it's - time to see what the fortune server has sent us. - - \snippet examples/network/blockingfortuneclient/fortunethread.cpp 9 - \snippet examples/network/blockingfortuneclient/fortunethread.cpp 10 - - This step is to read the size of the packet. Although we are only reading - two bytes here, and the \c while loop may seem to overdo it, we present this - code to demonstrate a good pattern for waiting for data using - QTcpSocket::waitForReadyRead(). It goes like this: For as long as we still - need more data, we call waitForReadyRead(). If it returns false, - we abort the operation. After this statement, we know that we have received - enough data. - - \snippet examples/network/blockingfortuneclient/fortunethread.cpp 11 - - Now we can create a QDataStream object, passing the socket to - QDataStream's constructor, and as in the other client examples we set - the stream protocol version to QDataStream::Qt_4_0, and read the size - of the packet. - - \snippet examples/network/blockingfortuneclient/fortunethread.cpp 12 - \snippet examples/network/blockingfortuneclient/fortunethread.cpp 13 - - Again, we'll use a loop that waits for more data by calling - QTcpSocket::waitForReadyRead(). In this loop, we're waiting until - QTcpSocket::bytesAvailable() returns the full packet size. - - \snippet examples/network/blockingfortuneclient/fortunethread.cpp 14 - - Now that we have all the data that we need, we can use QDataStream to - read the fortune string from the packet. The resulting fortune is - delivered by emitting newFortune(). - - \snippet examples/network/blockingfortuneclient/fortunethread.cpp 15 - - The final part of our loop is that we acquire the mutex so that we can - safely read from our member data. We then let the thread go to sleep by - calling QWaitCondition::wait(). At this point, we can go back to - requestNewFortune() and look closed at the call to wakeOne(): - - \snippet examples/network/blockingfortuneclient/fortunethread.cpp 1 - \dots - \snippet examples/network/blockingfortuneclient/fortunethread.cpp 3 - - What happened here was that because the thread falls asleep waiting for a - new request, we needed to wake it up again when a new request - arrives. QWaitCondition is often used in threads to signal a wakeup call - like this. - - \snippet examples/network/blockingfortuneclient/fortunethread.cpp 0 - - Finishing off the FortuneThread walkthrough, this is the destructor that - sets \e quit to true, wakes up the thread and waits for the thread to exit - before returning. This lets the \c while loop in run() will finish its current - iteration. When run() returns, the thread will terminate and be destroyed. - - Now for the BlockingClient class: - - \snippet examples/network/blockingfortuneclient/blockingclient.h 0 - - BlockingClient is very similar to the Client class in the - \l{network/fortuneclient}{Fortune Client} example, but in this class - we store a FortuneThread member instead of a pointer to a QTcpSocket. - When the user clicks the "Get Fortune" button, the same slot is called, - but its implementation is slightly different: - - \snippet examples/network/blockingfortuneclient/blockingclient.cpp 0 - \snippet examples/network/blockingfortuneclient/blockingclient.cpp 1 - - We connect our FortuneThread's two signals newFortune() and error() (which - are somewhat similar to QTcpSocket::readyRead() and QTcpSocket::error() in - the previous example) to requestNewFortune() and displayError(). - - \snippet examples/network/blockingfortuneclient/blockingclient.cpp 2 - - The requestNewFortune() slot calls FortuneThread::requestNewFortune(), - which \e shedules the request. When the thread has received a new fortune - and emits newFortune(), our showFortune() slot is called: - - \snippet examples/network/blockingfortuneclient/blockingclient.cpp 3 - \codeline - \snippet examples/network/blockingfortuneclient/blockingclient.cpp 4 - - Here, we simply display the fortune we received as the argument. - - \sa {Fortune Client Example}, {Fortune Server Example} -*/ diff --git a/doc/src/examples/books.qdoc b/doc/src/examples/books.qdoc index 2b6ce1e45b..135cecafea 100644 --- a/doc/src/examples/books.qdoc +++ b/doc/src/examples/books.qdoc @@ -26,7 +26,7 @@ ****************************************************************************/ /*! - \example sql/books + \example books \title Books The Books example shows how Qt's SQL classes can be used with the model/view diff --git a/doc/src/examples/broadcastreceiver.qdoc b/doc/src/examples/broadcastreceiver.qdoc deleted file mode 100644 index ec8bbd7cc4..0000000000 --- a/doc/src/examples/broadcastreceiver.qdoc +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example network/broadcastreceiver - \title Broadcast Receiver Example - - The Broadcast Receiver example shows how to receive information that is broadcasted - over a local network. - - \image broadcastreceiver-example.png -*/ diff --git a/doc/src/examples/broadcastsender.qdoc b/doc/src/examples/broadcastsender.qdoc deleted file mode 100644 index 91a3080712..0000000000 --- a/doc/src/examples/broadcastsender.qdoc +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example network/broadcastsender - \title Broadcast Sender Example - - The Broadcast Sender example shows how to broadcast information to multiple clients - on a local network. - - \image broadcastsender-example.png -*/ diff --git a/doc/src/examples/cachedtable.qdoc b/doc/src/examples/cachedtable.qdoc deleted file mode 100644 index e3c0e40f8f..0000000000 --- a/doc/src/examples/cachedtable.qdoc +++ /dev/null @@ -1,197 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example sql/cachedtable - \title Cached Table Example - - The Cached Table example shows how a table view can be used to access a database, - caching any changes to the data until the user explicitly submits them using a - push button. - - \image cachedtable-example.png - - The example consists of a single class, \c TableEditor, which is a - custom dialog widget that allows the user to modify data stored in - a database. We will first review the class definiton and how to - use the class, then we will take a look at the implementation. - - \section1 TableEditor Class Definition - - The \c TableEditor class inherits QDialog making the table editor - widget a top-level dialog window. - - \snippet examples/sql/cachedtable/tableeditor.h 0 - - The \c TableEditor constructor takes two arguments: The first is a - pointer to the parent widget and is passed on to the base class - constructor. The other is a reference to the database table the \c - TableEditor object will operate on. - - Note the QSqlTableModel variable declaration: As we will see in - this example, the QSqlTableModel class can be used to provide data - to view classes such as QTableView. The QSqlTableModel class - provides an editable data model making it possible to read and - write database records from a single table. It is build on top of - the lower-level QSqlQuery class which provides means of executing - and manipulating SQL statements. - - We are also going to show how a table view can be used to cache - any changes to the data until the user explicitly requests to - submit them. For that reason we need to declare a \c submit() slot - in additon to the model and the editor's buttons. - - \table 100% - \header \li Connecting to a Database - \row - \li - - Before we can use the \c TableEditor class, we must create a - connection to the database containing the table we want to edit: - - \snippet examples/sql/cachedtable/main.cpp 0 - - The \c createConnection() function is a helper function provided - for convenience. It is defined in the \c connection.h file which - is located in the \c sql example directory (all the examples in - the \c sql directory use this function to connect to a database). - - \snippet examples/sql/connection.h 0 - - The \c createConnection function opens a connection to an - in-memory SQLITE database and creates a test table. If you want - to use another database, simply modify this function's code. - \endtable - - \section1 TableEditor Class Implementation - - The class implementation consists of only two functions, the - constructor and the \c submit() slot. In the constructor we create - and customize the data model and the various window elements: - - \snippet examples/sql/cachedtable/tableeditor.cpp 0 - - First we create the data model and set the SQL database table we - want the model to operate on. Note that the - QSqlTableModel::setTable() function does not select data from the - table; it only fetches its field information. For that reason we - call the QSqlTableModel::select() function later on, populating - the model with data from the table. The selection can be - customized by specifying filters and sort conditions (see the - QSqlTableModel class documentation for more details). - - We also set the model's edit strategy. The edit strategy dictates - when the changes done by the user in the view, are actually - applied to the database. Since we want to cache the changes in the - table view (i.e. in the model) until the user explicitly submits - them, we choose the QSqlTableModel::OnManualSubmit strategy. The - alternatives are QSqlTableModel::OnFieldChange and - QSqlTableModel::OnRowChange. - - Finally, we set up the labels displayed in the view header using - the \l {QSqlQueryModel::setHeaderData()}{setHeaderData()} function - that the model inherits from the QSqlQueryModel class. - - \snippet examples/sql/cachedtable/tableeditor.cpp 1 - - Then we create a table view. The QTableView class provides a - default model/view implementation of a table view, i.e. it - implements a table view that displays items from a model. It also - allows the user to edit the items, storing the changes in the - model. To create a read only view, set the proper flag using the - \l {QAbstractItemView::editTriggers}{editTriggers} property the - view inherits from the QAbstractItemView class. - - To make the view present our data, we pass our model to the view - using the \l {QAbstractItemView::setModel()}{setModel()} function. - - \snippet examples/sql/cachedtable/tableeditor.cpp 2 - - The \c {TableEditor}'s buttons are regular QPushButton objects. We - add them to a button box to ensure that the buttons are presented - in a layout that is appropriate to the current widget style. The - rationale for this is that dialogs and message boxes typically - present buttons in a layout that conforms to the interface - guidelines for that platform. Invariably, different platforms have - different layouts for their dialogs. QDialogButtonBox allows a - developer to add buttons to it and will automatically use the - appropriate layout for the user's desktop environment. - - Most buttons for a dialog follow certain roles. When adding a - button to a button box using the \l - {QDialogButtonBox}{addButton()} function, the button's role must - be specified using the QDialogButtonBox::ButtonRole - enum. Alternatively, QDialogButtonBox provides several standard - buttons (e.g. \uicontrol OK, \uicontrol Cancel, \uicontrol Save) that you can - use. They exist as flags so you can OR them together in the - constructor. - - \snippet examples/sql/cachedtable/tableeditor.cpp 3 - - We connect the \uicontrol Quit button to the table editor's \l - {QWidget::close()}{close()} slot, and the \uicontrol Submit button to - our private \c submit() slot. The latter slot will take care of - the data transactions. Finally, we connect the \uicontrol Revert button - to our model's \l {QSqlTableModel::revertAll()}{revertAll()} slot, - reverting all pending changes (i.e., restoring the original data). - - \snippet examples/sql/cachedtable/tableeditor.cpp 4 - - In the end we add the button box and the table view to a layout, - install the layout on the table editor widget, and set the - editor's window title. - - \snippet examples/sql/cachedtable/tableeditor.cpp 5 - - The \c submit() slot is called whenever the users hit the \uicontrol - Submit button to save their changes. - - First, we begin a transaction on the database using the - QSqlDatabase::transaction() function. A database transaction is a - unit of interaction with a database management system or similar - system that is treated in a coherent and reliable way independent - of other transactions. A pointer to the used database can be - obtained using the QSqlTableModel::database() function. - - Then, we try to submit all the pending changes, i.e. the model's - modified items. If no error occurs, we commit the transaction to - the database using the QSqlDatabase::commit() function (note that - on some databases, this function will not work if there is an - active QSqlQuery on the database). Otherwise we perform a rollback - of the transaction using the QSqlDatabase::rollback() function and - post a warning to the user. - - \table 100% - \row - \li - \b {See also:} - - A complete list of Qt's SQL \l {Database Classes}, and the \l - {Model/View Programming} documentation. - - \endtable -*/ diff --git a/doc/src/examples/codecs.qdoc b/doc/src/examples/codecs.qdoc index e54981abb3..84b80b63f6 100644 --- a/doc/src/examples/codecs.qdoc +++ b/doc/src/examples/codecs.qdoc @@ -26,7 +26,7 @@ ****************************************************************************/ /*! - \example tools/codecs + \example codecs \title Codecs Example The Codecs example demonstrates the principles behind importing and exporting text diff --git a/doc/src/examples/completer.qdoc b/doc/src/examples/completer.qdoc index df832de4d6..0e635e3fb0 100644 --- a/doc/src/examples/completer.qdoc +++ b/doc/src/examples/completer.qdoc @@ -26,7 +26,7 @@ ****************************************************************************/ /*! - \example tools/completer + \example completer \title Completer Example The Completer example shows how to provide string-completion facilities diff --git a/doc/src/examples/complexpingpong.qdoc b/doc/src/examples/complexpingpong.qdoc index 0c6880826f..00e648b8fd 100644 --- a/doc/src/examples/complexpingpong.qdoc +++ b/doc/src/examples/complexpingpong.qdoc @@ -26,7 +26,7 @@ ****************************************************************************/ /*! - \example dbus/complexpingpong + \example complexpingpong \title Complex Ping Pong Example The Complex Ping Pong example improves on the \l{D-Bus Ping Pong Example} by providing diff --git a/doc/src/examples/contiguouscache.qdoc b/doc/src/examples/contiguouscache.qdoc index 02f333054e..b187997bf0 100644 --- a/doc/src/examples/contiguouscache.qdoc +++ b/doc/src/examples/contiguouscache.qdoc @@ -26,7 +26,7 @@ ****************************************************************************/ /*! - \example tools/contiguouscache + \example contiguouscache \title Contiguous Cache Example The Contiguous Cache example shows how to use QContiguousCache to manage memory usage for diff --git a/doc/src/examples/cube.qdoc b/doc/src/examples/cube.qdoc deleted file mode 100644 index ec40be0f45..0000000000 --- a/doc/src/examples/cube.qdoc +++ /dev/null @@ -1,178 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example opengl/cube - \group all-examples - \title Cube OpenGL ES 2.0 example - - The Cube OpenGL ES 2.0 example shows how to write mouse rotateable - textured 3D cube using OpenGL ES 2.0 with Qt. It shows how to handle - polygon geometries efficiently and how to write simple vertex and - fragment shader for programmable graphics pipeline. In addition it - shows how to use quaternions for representing 3D object orientation. - - This example has been written for OpenGL ES 2.0 but it works also on - desktop OpenGL because this example is simple enough and for the - most parts desktop OpenGL API is same. It compiles also without OpenGL - support but then it just shows a label stating that OpenGL support is - required. - - \image cube.png Screenshot of the Cube example running on N900 - - The example consist of two classes: - - \list - \li \c MainWidget extends QGLWidget and contains OpenGL ES 2.0 - initialization and drawing and mouse and timer event handling - \li \c GeometryEngine handles polygon geometries. Transfers polygon geometry - to vertex buffer objects and draws geometries from vertex buffer objects. - \endlist - - We'll start by initializing OpenGL ES 2.0 in \c MainWidget. - - \tableofcontents - - \section1 Initializing OpenGL ES 2.0 - - Since OpenGL ES 2.0 doesn't support fixed graphics pipeline anymore it has to - be implemented by ourselves. This makes graphics pipeline very flexible but - in the same time it becomes more difficult because user has to implement graphics - pipeline to get even the simplest example running. It also makes graphics pipeline - more efficient because user can decide what kind of pipeline is needed for the - application. - - First we have to implement vertex shader. It gets vertex data and - model-view-projection matrix (MVP) as parameters. It transforms vertex position - using MVP matrix to screen space and passes texture coordinate to - fragment shader. Texture coordinate will be automatically interpolated on polygon - faces. - - \snippet examples/opengl/cube/vshader.glsl 0 - - After that we need to implement second part of the graphics pipeline - fragment - shader. For this exercise we need to implement fragment shader that handles - texturing. It gets interpolated texture coordinate as a parameter and looks up - fragment color from the given texture. - - \snippet examples/opengl/cube/fshader.glsl 0 - - Using \c QGLShaderProgram we can compile, link and bind shader code to - graphics pipeline. This code uses Qt Resource files to access shader source code. - - \snippet examples/opengl/cube/mainwidget.cpp 3 - - The following code enables depth buffering and back face culling. - - \snippet examples/opengl/cube/mainwidget.cpp 2 - - \section1 Loading textures from Qt Resource files - - \c QGLWidget interface implements methods for loading textures from QImage to GL - texture memory. We still need to use OpenGL provided functions for specifying - the GL texture unit and configuring texture filtering options. - - \snippet examples/opengl/cube/mainwidget.cpp 4 - - \section1 Cube Geometry - - There are many ways to render polygons in OpenGL but the most efficient way is - to use only triangle strip primitives and render vertices from graphics hardware - memory. OpenGL has a mechanism to create buffer objects to this memory area and - transfer vertex data to these buffers. In OpenGL terminology these are referred - as Vertex Buffer Objects (VBO). - - \image cube_faces.png Cube faces and vertices - - This is how cube faces break down to triangles. Vertices are ordered this way - to get vertex ordering correct using triangle strips. OpenGL determines triangle - front and back face based on vertex ordering. By default OpenGL uses - counter-clockwise order for front faces. This information is used by back face - culling which improves rendering performance by not rendering back faces of the - triangles. This way graphics pipeline can omit rendering sides of the triangle that - aren't facing towards screen. - - Creating vertex buffer objects and transferring data to them is quite simple using - OpenGL provided functions. - - \snippet examples/opengl/cube/geometryengine.cpp 0 - - \snippet examples/opengl/cube/geometryengine.cpp 1 - - Drawing primitives from VBOs and telling programmable graphics pipeline how to - locate vertex data requires few steps. First we need to bind VBOs to be used. - After that we bind shader program attribute names and configure what - kind of data it has in the bound VBO. Finally we'll draw triangle - strip primitives using indices from the other VBO. - - \snippet examples/opengl/cube/geometryengine.cpp 2 - - \section1 Perspective projection - - Using \c QMatrix4x4 helper methods it's really easy to calculate perpective - projection matrix. This matrix is used to project vertices to screen space. - - \snippet examples/opengl/cube/mainwidget.cpp 5 - - \section1 Orientation of the 3D object - - Quaternions are handy way to represent orientation of the 3D object. Quaternions - involve quite complex mathematics but fortunately all the necessary mathematics - behind quaternions is implemented in \c QQuaternion. That allows us to store - cube orientation in quaternion and rotating cube around given axis is quite - simple. - - The following code calculates rotation axis and angular speed based on mouse events. - - \snippet examples/opengl/cube/mainwidget.cpp 0 - - \c QBasicTimer is used to animate scene and update cube orientation. Rotations - can be concatenated simply by multiplying quaternions. - - \snippet examples/opengl/cube/mainwidget.cpp 1 - - Model-view matrix is calculated using the quaternion and by moving world by Z axis. - This matrix is multiplied with the projection matrix to get MVP matrix for shader - program. - - \snippet examples/opengl/cube/mainwidget.cpp 6 - -*/ diff --git a/doc/src/examples/customcompleter.qdoc b/doc/src/examples/customcompleter.qdoc deleted file mode 100644 index b46d747e02..0000000000 --- a/doc/src/examples/customcompleter.qdoc +++ /dev/null @@ -1,187 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example tools/customcompleter - \title Custom Completer Example - - The Custom Completer example shows how to provide string-completion - facilities for an input widget based on data provided by a model. The - completer pops up suggestions for possible words based on the first three - characters input by the user and the user's choice of word is inserted - into the \c TextEdit using QTextCursor. - - \image customcompleter-example.png - - \section1 Setting Up The Resource File - - The Custom Completer example requires a resource file, \e wordlist.txt, - that has a list of words to help QCompleter complete words. This file - contains the following: - - \quotefile examples/tools/customcompleter/customcompleter.qrc - - \section1 TextEdit Class Definition - - The \c TextEdit class is a subclass of QTextEdit with a custom - \c insertCompletion() slot and it reimplements the - \l{QAbstractScrollArea::keyPressEvent()}{keyPressEvent()} and the - \l{QWidget::focusInEvent()}{focusInEvent()} functions. \c TextEdit also - contains a private function \c textUnderCursor() and a private instance - of QCompleter, \c c. - - \snippet examples/tools/customcompleter/textedit.h 0 - - \section1 TextEdit Class Implementation - - The constructor for \c TextEdit constructs a \c TextEdit with a parent and - initializes \c c. The instructions to use the completer is displayed on - the \c TextEdit object, using the - \l{QTextEdit::setPlainText()}{setPlainText()} function. - - \snippet examples/tools/customcompleter/textedit.cpp 0 - - In addition, \c TextEdit also includes a default destructor: - - \snippet examples/tools/customcompleter/textedit.cpp 1 - - The \c setCompleter() function accepts a \a completer and sets it up. - We use \c{if (c)} to check if \c c has been initialized. If it has been - initialized, the QObject::disconnect() function is invoked to disconnect - the signal from the slot. This is to ensure that no previous completer - object is still connected to the slot. - - \snippet examples/tools/customcompleter/textedit.cpp 2 - - We then instantiate \c c with \a completer and set it as \c{TextEdit}'s - widget. The completion mode and case sensitivity are also set and then - we connect the \l{QCompleter::activated()}{activated()} signal to the - \c insertCompletion() slot. - - The \c completer() function is a getter function that returns \c c. - - \snippet examples/tools/customcompleter/textedit.cpp 3 - - The completer pops up the options available, based on the contents of - \e wordlist.txt, but the text cursor is responsible for filling in the - missing characters, according to the user's choice of word. - - Suppose the user inputs "ACT" and accepts the completer's suggestion of - "ACTUAL". The \c completion string is then sent to \c insertCompletion() - by the completer's \l{QCompleter::activated()}{activated()} signal. - - The \c insertCompletion() function is responsible for completing the word - using a QTextCursor object, \c tc. It validates to ensure that the - completer's widget is \c TextEdit before using \c tc to insert the extra - characters to complete the word. - - \snippet examples/tools/customcompleter/textedit.cpp 4 - - The figure below illustrates this process: - - \image customcompleter-insertcompletion.png - - \c{completion.length()} = 6 - - \c{c->completionPrefix().length()}=3 - - The difference between these two values is \c extra, which is 3. This - means that the last three characters from the right, "U", "A", and "L", - will be inserted by \c tc. - - The \c textUnderCursor() function uses a QTextCursor, \c tc, to select a - word under the cursor and return it. - - \snippet examples/tools/customcompleter/textedit.cpp 5 - - The \c TextEdit class reimplements \l{QWidget::focusInEvent()} - {focusInEvent()} function, which is an event handler used to receive - keyboard focus events for the widget. - - \snippet examples/tools/customcompleter/textedit.cpp 6 - - The \l{QAbstractScrollArea::keyPressEvent()}{keyPressEvent()} is - reimplemented to ignore key events like Qt::Key_Enter, Qt::Key_Return, - Qt::Key_Escape, Qt::Key_Tab, and Qt::Key_Backtab so the completer can - handle them. - - If there is an active completer, we cannot process the shortcut, Ctrl+E. - - \snippet examples/tools/customcompleter/textedit.cpp 7 - - We also handle other modifiers and shortcuts for which we do not want the - completer to respond to. - - \snippet examples/tools/customcompleter/textedit.cpp 8 - - Finally, we pop up the completer. - - \section1 MainWindow Class Definition - - The \c MainWindow class is a subclass of QMainWindow and implements a - private slot, \c about(). This class also has two private functions, - \c createMenu() and \c modelFromFile() as well as private instances of - QCompleter and \c TextEdit. - - \snippet examples/tools/customcompleter/mainwindow.h 0 - - \section1 MainWindow Class Implementation - - The constructor constructs a \c MainWindow with a parent and initializes - the \c completer. It also instantiates a \c TextEdit and sets its - completer. A QStringListModel, obtained from \c modelFromFile(), is used - to populate the \c completer. The \c{MainWindow}'s central widget is set - to \c TextEdit and its size is set to 500 x 300. - - \snippet examples/tools/customcompleter/mainwindow.cpp 0 - - The \c createMenu() function creates the necessary QAction objects needed - for the "File" and "Help" menu and their \l{QAction::triggered()} - {triggered()} signals are connected to the \c quit(), \c about(), and - \c aboutQt() slots respectively. - - \snippet examples/tools/customcompleter/mainwindow.cpp 1 - - The \c modelFromFile() function accepts a \a fileName and attempts to - extract the contents of this file into a QStringListModel. We display the - Qt::WaitCursor when we are populating the QStringList, \c words, and - restore the mouse cursor when we are done. - - \snippet examples/tools/customcompleter/mainwindow.cpp 2 - - The \c about() function provides a brief description about the Custom - Completer example. - - \snippet examples/tools/customcompleter/mainwindow.cpp 3 - - \section1 \c main() Function - - The \c main() function instantiates \c MainWindow and invokes the - \l{QWidget::show()}{show()} function. - - \snippet examples/tools/customcompleter/main.cpp 0 -*/ diff --git a/doc/src/examples/customtype.qdoc b/doc/src/examples/customtype.qdoc deleted file mode 100644 index b2f86d6890..0000000000 --- a/doc/src/examples/customtype.qdoc +++ /dev/null @@ -1,143 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example tools/customtype - \title Custom Type Example - - The Custom Type example shows how to integrate a custom type into Qt's - meta-object system. - - Contents: - - \tableofcontents - - \section1 Overview - - Qt provides a range of standard value types that are used to provide - rich and meaningful APIs. These types are integrated with the meta-object - system, enabling them to be stored in QVariant objects, written out in - debugging information and sent between components in signal-slot - communication. - - Custom types can also be integrated with the meta-object system as long as - they are written to conform to some simple guidelines. In this example, we - introduce a simple \c Message class, we describe how we make it work with - QVariant, and we show how it can be extended to generate a printable - representation of itself for use in debugging output. - - \section1 The Message Class Definition - - The \c Message class is a simple value class that contains two pieces - of information (a QString and a QStringList), each of which can be read - using trivial getter functions: - - \snippet examples/tools/customtype/message.h custom type definition - - The default constructor, copy constructor and destructor are - all required, and must be public, if the type is to be integrated into the - meta-object system. Other than this, we are free to implement whatever we - need to make the type do what we want, so we also include a constructor - that lets us set the type's data members. - - To enable the type to be used with QVariant, we declare it using the - Q_DECLARE_METATYPE() macro: - - \snippet examples/tools/customtype/message.h custom type meta-type declaration - - We do not need to write any additional code to accompany this macro. - - To allow us to see a readable description of each \c Message object when it - is sent to the debug output stream, we define a streaming operator: - - \snippet examples/tools/customtype/message.h custom type streaming operator - - This facility is useful if you need to insert tracing statements in your - code for debugging purposes. - - \section1 The Message Class Implementation - - The implementation of the default constructor, copy constructor and destructor - are straightforward for the \c Message class: - - \snippet examples/tools/customtype/message.cpp Message class implementation - - The streaming operator is implemented in the following way: - - \snippet examples/tools/customtype/message.cpp custom type streaming operator - - Here, we want to represent each value depending on how many lines are stored - in the message body. We stream text to the QDebug object passed to the - operator and return the QDebug object obtained from its maybeSpace() member - function; this is described in more detail in the - \l{Creating Custom Qt Types#Making the Type Printable}{Creating Custom Qt Types} - document. - - We include the code for the getter functions for completeness: - - \snippet examples/tools/customtype/message.cpp getter functions - - With the type fully defined, implemented, and integrated with the - meta-object system, we can now use it. - - \section1 Using the Message - - In the example's \c{main()} function, we show how a \c Message object can - be printed to the console by sending it to the debug stream: - - \snippet examples/tools/customtype/main.cpp printing a custom type - - You can use the type with QVariant in exactly the same way as you would - use standard Qt value types. Here's how to store a value using the - QVariant::setValue() function: - - \snippet examples/tools/customtype/main.cpp storing a custom value - - Alternatively, the QVariant::fromValue() and qVariantSetValue() functions - can be used if you are using a compiler without support for member template - functions. - - The value can be retrieved using the QVariant::value() member template - function: - - \snippet examples/tools/customtype/main.cpp retrieving a custom value - - Alternatively, the qVariantValue() template function can be used if - you are using a compiler without support for member template functions. - - \section1 Further Reading - - The custom \c Message type can also be used with direct signal-slot - connections; see the \l{Custom Type Sending Example} for a demonstration - of this. - To register a custom type for use with queued signals and slots, such as - those used in cross-thread communication, see the - \l{Queued Custom Type Example}. - - More information on using custom types with Qt can be found in the - \l{Creating Custom Qt Types} document. -*/ diff --git a/doc/src/examples/draggableicons.qdoc b/doc/src/examples/draggableicons.qdoc deleted file mode 100644 index f69dbc4b3d..0000000000 --- a/doc/src/examples/draggableicons.qdoc +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example draganddrop/draggableicons - \title Draggable Icons Example - - The Draggable Icons example shows how to drag and drop image data between widgets - in the same application, and between different applications. - - \image draggableicons-example.png - - In many situations where drag and drop is used, the user starts dragging from - a particular widget and drops the payload onto another widget. In this example, - we subclass QLabel to create labels that we use as drag sources, and place them - inside \l{QWidget}s that serve as both containers and drop sites. - - In addition, when a drag and drop operation occurs, we want to send more than - just an image. We also want to send information about where the user clicked in - the image so that the user can place it precisely on the drop target. This level - of detail means that we must create a custom MIME type for our data. - - \section1 DragWidget Class Definition - - The icon widgets that we use to display icons are subclassed from QLabel: - - \snippet examples/draganddrop/draggableicons/dragwidget.h 0 - - Since the QLabel class provides most of what we require for the icon, we - only need to reimplement the \l QWidget::mousePressEvent() to provide - drag and drop facilities. - - \section1 DragWidget Class Implementation - - The \c DragWidget constructor sets an attribute on the widget that ensures - that it will be deleted when it is closed: - - \snippet examples/draganddrop/draggableicons/dragwidget.cpp 0 - - To enable dragging from the icon, we need to act on a mouse press event. - We do this by reimplementing \l QWidget::mousePressEvent() and setting up - a QDrag object. - - \snippet examples/draganddrop/draggableicons/dragwidget.cpp 1 - - Since we will be sending pixmap data for the icon and information about the - user's click in the icon widget, we construct a QByteArray and package up the - details using a QDataStream. - - For interoperability, drag and drop operations describe the data they contain - using MIME types. In Qt, we describe this data using a QMimeData object: - - \snippet examples/draganddrop/draggableicons/dragwidget.cpp 2 - - We choose an unofficial MIME type for this purpose, and supply the QByteArray - to the MIME data object. - - The drag and drop operation itself is handled by a QDrag object: - - \snippet examples/draganddrop/draggableicons/dragwidget.cpp 3 - - Here, we pass the data to the drag object, set a pixmap that will be shown - alongside the cursor during the operation, and define the position of a hot - spot that places the position of this pixmap under the cursor. - -*/ diff --git a/doc/src/examples/draggabletext.qdoc b/doc/src/examples/draggabletext.qdoc deleted file mode 100644 index d497206f8b..0000000000 --- a/doc/src/examples/draggabletext.qdoc +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example draganddrop/draggabletext - \title Draggable Text Example - - The Draggable Text example shows how to drag and drop textual data between widgets - in the same application, and between different applications. - - \image draggabletext-example.png -*/ diff --git a/doc/src/examples/drilldown.qdoc b/doc/src/examples/drilldown.qdoc deleted file mode 100644 index f8086c193e..0000000000 --- a/doc/src/examples/drilldown.qdoc +++ /dev/null @@ -1,536 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example sql/drilldown - \title Drill Down Example - - The Drill Down example shows how to read data from a database as - well as submit changes, using the QSqlRelationalTableModel and - QDataWidgetMapper classes. - - \image drilldown-example.png Screenshot of the Drill Down Example - - When running the example application, a user can retrieve - information about each of Nokia's Qt offices by clicking the - corresponding image. The application pops up an information window - displaying the data, and allows the users to alter the location - description as well as the image. The main view will be updated - when the users submit their changes. - - The example consists of three classes: - - \list - \li \c ImageItem is a custom graphics item class used to - display the office images. - - \li \c View is the main application widget allowing the user to - browse through the various locations. - - \li \c InformationWindow displays the requested information, - allowing the users to alter it and submit their changes to the - database. - \endlist - - We will first take a look at the \c InformationWindow class to see - how you can read and modify data from a database. Then we will - review the main application widget, i.e., the \c View class, and - the associated \c ImageItem class. - - \section1 InformationWindow Class Definition - - The \c InformationWindow class is a custom widget inheriting - QWidget: - - \snippet examples/sql/drilldown/informationwindow.h 0 - - When we create an information window, we pass the associated - location ID, a parent, and a pointer to the database, to the - constructor. We will use the database pointer to populate our - window with data, while passing the parent parameter on to the - base class. The ID is stored for future reference. - - Once a window is created, we will use the public \c id() function - to locate it whenever information for the given location is - requested. We will also use the ID to update the main application - widget when the users submit their changes to the database, i.e., - we will emit a signal carrying the ID and file name as parameters - whenever the users changes the associated image. - - \snippet examples/sql/drilldown/informationwindow.h 1 - - Since we allow the users to alter some of the location data, we - must provide functionality for reverting and submitting their - changes. The \c enableButtons() slot is provided for convenience - to enable and disable the various buttons when required. - - \snippet examples/sql/drilldown/informationwindow.h 2 - - The \c createButtons() function is also a convenience function, - provided to simplify the constructor. As mentioned above we store - the location ID for future reference. We also store the name of - the currently displayed image file to be able to determine when to - emit the \c imageChanged() signal. - - The information window uses the QLabel class to display the office - location and the country. The associated image file is displayed - using a QComboBox instance while the description is displayed using - QTextEdit. In addition, the window has three buttons to control - the data flow and whether the window is shown or not. - - Finally, we declare a \e mapper. The QDataWidgetMapper class - provides mapping between a section of a data model to widgets. We - will use the mapper to extract data from the given database, - updating the database whenever the user modifies the data. - - \section1 InformationWindow Class Implementation - - The constructor takes three arguments: a location ID, a database - pointer and a parent widget. The database pointer is actually a - pointer to a QSqlRelationalTableModel object providing an editable - data model (with foreign key support) for our database table. - - \snippet examples/sql/drilldown/informationwindow.cpp 0 - \snippet examples/sql/drilldown/informationwindow.cpp 1 - - First we create the various widgets required to display the data - contained in the database. Most of the widgets are created in a - straight forward manner. But note the combobox displaying the - name of the image file: - - \snippet examples/sql/drilldown/informationwindow.cpp 2 - - In this example, the information about the offices are stored in a - database table called "offices". When creating the model, - we will use a foreign key to establish a relation between this - table and a second data base table, "images", containing the names - of the available image files. We will get back to how this is done - when reviewing the \c View class. The rationale for creating such - a relation though, is that we want to ensure that the user only - can choose between predefined image files. - - The model corresponding to the "images" database table, is - available through the QSqlRelationalTableModel's \l - {QSqlRelationalTableModel::}{relationModel()} function, requiring - the foreign key (in this case the "imagefile" column number) as - argument. We use QComboBox's \l {QComboBox::}{setModel()} function - to make the combobox use the "images" model. And, since this model - has two columns ("locationid" and "file"), we also specify which - column we want to be visible using the QComboBox::setModelColumn() - function. - - \snippet examples/sql/drilldown/informationwindow.cpp 3 - - Then we create the mapper. The QDataWidgetMapper class allows us - to create data-aware widgets by mapping them to sections of an - item model. - - The \l {QDataWidgetMapper::}{addMapping()} function adds a mapping - between the given widget and the specified section of the - model. If the mapper's orientation is horizontal (the default) the - section is a column in the model, otherwise it is a row. We call - the \l {QDataWidgetMapper::}{setCurrentIndex()} function to - initialize the widgets with the data associated with the given - location ID. Every time the current index changes, all the widgets - are updated with the contents from the model. - - We also set the mapper's submit policy to - QDataWidgetMapper::ManualSubmit. This means that no data is - submitted to the database until the user expliclity requests a - submit (the alternative is QDataWidgetMapper::AutoSubmit, - automatically submitting changes when the corresponding widget - looses focus). Finally, we specify the item delegate the mapper - view should use for its items. The QSqlRelationalDelegate class - represents a delegate that unlike the default delegate, enables - combobox functionality for fields that are foreign keys into other - tables (like "imagefile" in our "trolltechoffices" table). - - \snippet examples/sql/drilldown/informationwindow.cpp 4 - - Finally, we connect the "something's changed" signals in the - editors to our custom \c enableButtons() slot, enabling the users - to either submit or revert their changes. We add all the widgets - into a layout, store the location ID and the name of the displayed - image file for future reference, and set the window title and - initial size. - - Note that we also set the Qt::Window window flag to indicate that - our widget is in fact a window, with a window system frame and a - title bar. - - \snippet examples/sql/drilldown/informationwindow.cpp 5 - - When a window is created, it is not deleted until the main - application exits (i.e., if the user closes the information - window, it is only hidden). For this reason we do not want to - create more than one \c InformationWindow object for each - location, and we provide the public \c id() function to be able to - determine whether a window already exists for a given location - when the user requests information about it. - - \snippet examples/sql/drilldown/informationwindow.cpp 6 - - The \c revert() slot is triggered whenever the user hits the \uicontrol - Revert button. - - Since we set the QDataWidgetMapper::ManualSubmit submit policy, - none of the user's changes are written back to the model unless - the user expliclity choose to submit all of them. Nevertheless, we - can use the QDataWidgetMapper's \l {QDataWidgetMapper::}{revert()} - slot to reset the editor widgets, repopulating all widgets with - the current data of the model. - - \snippet examples/sql/drilldown/informationwindow.cpp 7 - - Likewise, the \c submit() slot is triggered whenever the users - decide to submit their changes by pressing the \uicontrol Submit button. - - We use QDataWidgetMapper's \l {QDataWidgetMapper::}{submit()} slot - to submit all changes from the mapped widgets to the model, - i.e. to the database. For every mapped section, the item delegate - will then read the current value from the widget and set it in the - model. Finally, the \e model's \l {QAbstractItemModel::}{submit()} - function is invoked to let the model know that it should submit - whatever it has cached to the permanent storage. - - Note that before any data is submitted, we check if the user has - chosen another image file using the previously stored \c - displayedImage variable as reference. If the current and stored - file names differ, we store the new file name and emit the \c - imageChanged() signal. - - \snippet examples/sql/drilldown/informationwindow.cpp 8 - - The \c createButtons() function is provided for convenience, i.e., - to simplify the constructor. - - We make the \uicontrol Close button the default button, i.e., the button - that is pressed when the user presses \uicontrol Enter, and connect its - \l {QPushButton::}{clicked()} signal to the widget's \l - {QWidget::}{close()} slot. As mentioned above closing the window - only hides the widget; it is not deleted. We also connect the \uicontrol - Submit and \uicontrol Revert buttons to the corresponding \c submit() - and \c revert() slots. - - \snippet examples/sql/drilldown/informationwindow.cpp 9 - - The QDialogButtonBox class is a widget that presents buttons in a - layout that is appropriate to the current widget style. Dialogs - like our information window, typically present buttons in a layout - that conforms to the interface guidelines for that - platform. Invariably, different platforms have different layouts - for their dialogs. QDialogButtonBox allows us to add buttons, - automatically using the appropriate layout for the user's desktop - environment. - - Most buttons for a dialog follow certain roles. We give the \uicontrol - Submit and \uicontrol Revert buttons the \l - {QDialogButtonBox::ButtonRole}{reset} role, i.e., indicating that - pressing the button resets the fields to the default values (in - our case the information contained in the database). The \l - {QDialogButtonBox::ButtonRole}{reject} role indicates that - clicking the button causes the dialog to be rejected. On the other - hand, since we only hide the information window, any changes that - the user has made wil be preserved until the user expliclity - revert or submit them. - - \snippet examples/sql/drilldown/informationwindow.cpp 10 - - The \c enableButtons() slot is called to enable the buttons - whenever the user changes the presented data. Likewise, when the - data the user choose to submit the changes, the buttons are - disabled to indicate that the current data is stored in the - database. - - This completes the \c InformationWindow class. Let's take a look - at how we have used it in our example application. - - \section1 View Class Definition - - The \c View class represents the main application window and - inherits QGraphicsView: - - \snippet examples/sql/drilldown/view.h 0 - \codeline - \snippet examples/sql/drilldown/view.h 1 - - The QGraphicsView class is part of the \l {Graphics View - Framework} which we will use to display the images of Nokia's - Qt offices. To be able to respond to user interaction; - i.e., showing the - appropriate information window whenever the user clicks one of the - office images, we reimplement QGraphicsView's \l - {QGraphicsView::}{mouseReleaseEvent()} function. - - Note that the constructor expects the names of two database - tables: One containing the detailed information about the offices, - and another containing the names of the available image files. We - also provide a private \c updateImage() slot to catch \c - {InformationWindow}'s \c imageChanged() signal that is emitted - whenever the user changes a location's image. - - \snippet examples/sql/drilldown/view.h 2 - - The \c addItems() function is a convenience function provided to - simplify the constructor. It is called only once, creating the - various items and adding them to the view. - - The \c findWindow() function, on the other hand, is frequently - used. It is called from the \c showInformation() function to - detemine whether a window is already created for the given - location (whenever we create an \c InformationWindow object, we - store a reference to it in the \c informationWindows list). The - latter function is in turn called from our custom \c - mouseReleaseEvent() implementation. - - \snippet examples/sql/drilldown/view.h 3 - - Finally we declare a QSqlRelationalTableModel pointer. As - previously mentioned, the QSqlRelationalTableModel class provides - an editable data model with foreign key support. There are a - couple of things you should keep in mind when using the - QSqlRelationalTableModel class: The table must have a primary key - declared and this key cannot contain a relation to another table, - i.e., it cannot be a foreign key. Note also that if a relational - table contains keys that refer to non-existent rows in the - referenced table, the rows containing the invalid keys will not be - exposed through the model. It is the user's or the database's - responsibility to maintain referential integrity. - - \section1 View Class Implementation - - Although the constructor requests the names of both the table - containing office details as well as the table containing the - names of the available image files, we only have to create a - QSqlRelationalTableModel object for the office table: - - \snippet examples/sql/drilldown/view.cpp 0 - - The reason is that once we have a model with the office details, - we can create a relation to the available image files using - QSqlRelationalTableModel's \l - {QSqlRelationalTableModel::}{setRelation()} function. This - function creates a foreign key for the given model column. The key - is specified by the provided QSqlRelation object constructed by - the name of the table the key refers to, the field the key is - mapping to and the field that should be presented to the user. - - Note that setting the table only specifies which table the model - operates on, i.e., we must explicitly call the model's \l - {QSqlRelationalTableModel::}{select()} function to populate our - model. - - \snippet examples/sql/drilldown/view.cpp 1 - - Then we create the contents of our view, i.e., the scene and its - items. The location labels are regular QGraphicsTextItem objects, - and the "Qt" logo is represented by a QGraphicsPixmapItem - object. The images, on the other hand, are instances of the \c - ImageItem class (derived from QGraphicsPixmapItem). We will get - back to this shortly when reviewing the \c addItems() function. - - Finally, we set the main application widget's size constraints and - window title. - - \snippet examples/sql/drilldown/view.cpp 3 - - The \c addItems() function is called only once, i.e., when - creating the main application window. For each row in the database - table, we first extract the corresponding record using the model's - \l {QSqlRelationalTableModel::}{record()} function. The QSqlRecord - class encapsulates both the functionality and characteristics of a - database record, and supports adding and removing fields as well - as setting and retrieving field values. The QSqlRecord::value() - function returns the value of the field with the given name or - index as a QVariant object. - - For each record, we create a label item as well as an image item, - calculate their position and add them to the scene. The image - items are represented by instances of the \c ImageItem class. The - reason we must create a custom item class is that we want to catch - the item's hover events, animating the item when the mouse cursor - is hovering over the image (by default, no items accept hover - events). Please see the \l{Graphics View Framework} documentation - and the \l{Graphics View Examples} for more details. - - \snippet examples/sql/drilldown/view.cpp 5 - - We reimplement QGraphicsView's \l - {QGraphicsView::}{mouseReleaseEvent()} event handler to respond to - user interaction. If the user clicks any of the image items, this - function calls the private \c showInformation() function to pop up - the associated information window. - - The \l {Graphics View Framework} provides the qgraphicsitem_cast() - function to determine whether the given QGraphicsItem instance is - of a given type. Note that if the event is not related to any of - our image items, we pass it on to the base class implementation. - - \snippet examples/sql/drilldown/view.cpp 6 - - The \c showInformation() function is given an \c ImageItem object - as argument, and starts off by extracting the item's location - ID. Then it determines if there already is created an information - window for this location. If it is, and the window is visible, it - ensures that the window is raised to the top of the widget stack - and activated. If the window exists but is hidden, calling its \l - {QWidget::}{show()} slot gives the same result. - - If no window for the given location exists, we create one by - passing the location ID, a pointer to the model, and our view as a - parent, to the \c InformationWindow constructor. Note that we - connect the information window's \c imageChanged() signal to \e - this widget's \c updateImage() slot, before we give it a suitable - position and add it to the list of existing windows. - - \snippet examples/sql/drilldown/view.cpp 7 - - The \c updateImage() slot takes a location ID and the name of an - image files as arguments. It filters out the image items, and - updates the one that correspond to the given location ID, with the - provided image file. - - \snippet examples/sql/drilldown/view.cpp 8 - - The \c findWindow() function simply searches through the list of - existing windows, returning a pointer to the window that matches - the given location ID, or 0 if the window doesn't exists. - - Finally, let's take a quick look at our custom \c ImageItem class: - - \section1 ImageItem Class Definition - - The \c ImageItem class is provided to facilitate animation of the - image items. It inherits QGraphicsPixmapItem and reimplements its - hover event handlers: - - \snippet examples/sql/drilldown/imageitem.h 0 - - In addition, we implement a public \c id() function to be able to - identify the associated location and a public \c adjust() function - that can be called to ensure that the image item is given the - preferred size regardless of the original image file. - - The animation is implemented using the QTimeLine class together - with the event handlers and the private \c setFrame() slot: The - image item will expand when the mouse cursor hovers over it, - returning back to its original size when the cursor leaves its - borders. - - Finally, we store the location ID that this particular record is - associated with as well as a z-value. In the \l {Graphics View - Framework}, an item's z-value determines its position in the item - stack. An item of high z-value will be drawn on top of an item - with a lower z-value if they share the same parent item. We also - provide an \c updateItemPosition() function to refresh the view - when required. - - \section1 ImageItem Class Implementation - - The \c ImageItem class is really only a QGraphicsPixmapItem with - some additional features, i.e., we can pass most of the - constructor's arguments (the pixmap, parent and scene) on to the - base class constructor: - - \snippet examples/sql/drilldown/imageitem.cpp 0 - - Then we store the ID for future reference, and ensure that our - item will accept hover events. Hover events are delivered when - there is no current mouse grabber item. They are sent when the - mouse cursor enters an item, when it moves around inside the item, - and when the cursor leaves an item. As we mentioned earlier, none - of the \l {Graphics View Framework}'s items accept hover - event's by default. - - The QTimeLine class provides a timeline for controlling - animations. Its \l {QTimeLine::}{duration} property holds the - total duration of the timeline in milliseconds. By default, the - time line runs once from the beginning and towards the end. The - QTimeLine::setFrameRange() function sets the timeline's frame - counter; when the timeline is running, the \l - {QTimeLine::}{frameChanged()} signal is emitted each time the - frame changes. We set the duration and frame range for our - animation, and connect the time line's \l - {QTimeLine::}{frameChanged()} and \l {QTimeLine::}{finished()} - signals to our private \c setFrame() and \c updateItemPosition() - slots. - - Finally, we call \c adjust() to ensure that the item is given the - preferred size. - - \snippet examples/sql/drilldown/imageitem.cpp 1 - \codeline - \snippet examples/sql/drilldown/imageitem.cpp 2 - - Whenever the mouse cursor enters or leave the image item, the - corresponding event handlers are triggered: We first set the time - line's direction, making the item expand or shrink, - respectively. Then we alter the item's z-value if it is not already - set to the expected value. - - In the case of hover \e enter events, we immediately update the - item's position since we want the item to appear on top of all - other items as soon as it starts expanding. In the case of hover - \e leave events, on the other hand, we postpone the actual update - to achieve the same result. But remember that when we constructed - our item, we connected the time line's \l - {QTimeLine::}{finished()} signal to the \c updateItemPosition() - slot. In this way the item is given the correct position in the - item stack once the animation is completed. Finally, if the time - line is not already running, we start it. - - \snippet examples/sql/drilldown/imageitem.cpp 3 - - When the time line is running, it triggers the \c setFrame() slot - whenever the current frame changes due to the connection we - created in the item constructor. It is this slot that controls the - animation, expanding or shrinking the image item step by step. - - We first call the \c adjust() function to ensure that we start off - with the item's original size. Then we scale the item with a - factor depending on the animation's progress (using the \c frame - parameter). Note that by default, the transformation will be - relative to the item's top-left corner. Since we want the item to - be transformed relative to its center, we must translate the - coordinate system before we scale the item. - - In the end, only the following convenience functions remain: - - \snippet examples/sql/drilldown/imageitem.cpp 4 - \codeline - \snippet examples/sql/drilldown/imageitem.cpp 5 - \codeline - \snippet examples/sql/drilldown/imageitem.cpp 6 - - The \c adjust() function defines and applies a transformation - matrix, ensuring that our image item appears with the preferred - size regardless of the size of the source image. The \c id() - function is trivial, and is simply provided to be able to identify - the item. In the \c updateItemPosition() slot we call the - QGraphicsItem::setZValue() function, setting the elevation (i.e., - the position) of the item. -*/ diff --git a/doc/src/examples/fortuneclient.qdoc b/doc/src/examples/fortuneclient.qdoc deleted file mode 100644 index 3b43682899..0000000000 --- a/doc/src/examples/fortuneclient.qdoc +++ /dev/null @@ -1,160 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example network/fortuneclient - \title Fortune Client Example - - The Fortune Client example shows how to create a client for a simple - network service using QTcpSocket. It is intended to be run alongside the - \l{network/fortuneserver}{Fortune Server} example or - the \l{network/threadedfortuneserver}{Threaded Fortune Server} example. - - \image fortuneclient-example.png Screenshot of the Fortune Client example - - This example uses a simple QDataStream-based data transfer protocol to - request a line of text from a fortune server (from the - \l{network/fortuneserver}{Fortune Server} example). The client requests a - fortune by simply connecting to the server. The server then responds with - a 16-bit (quint16) integer containing the length of the fortune text, - followed by a QString. - - QTcpSocket supports two general approaches to network programming: - - \list - - \li \e{The asynchronous (non-blocking) approach.} Operations are scheduled - and performed when control returns to Qt's event loop. When the operation - is finished, QTcpSocket emits a signal. For example, - QTcpSocket::connectToHost() returns immediately, and when the connection - has been established, QTcpSocket emits - \l{QTcpSocket::connected()}{connected()}. - - \li \e{The synchronous (blocking) approach.} In non-GUI and multithreaded - applications, you can call the \c waitFor...() functions (e.g., - QTcpSocket::waitForConnected()) to suspend the calling thread until the - operation has completed, instead of connecting to signals. - - \endlist - - In this example, we will demonstrate the asynchronous approach. The - \l{network/blockingfortuneclient}{Blocking Fortune Client} example - illustrates the synchronous approach. - - Our class contains some data and a few private slots: - - \snippet examples/network/fortuneclient/client.h 0 - - Other than the widgets that make up the GUI, the data members include a - QTcpSocket pointer, a copy of the fortune text currently displayed, and - the size of the packet we are currently reading (more on this later). - - The socket is initialized in the Client constructor. We'll pass the main - widget as parent, so that we won't have to worry about deleting the - socket: - - \snippet examples/network/fortuneclient/client.cpp 0 - \dots - \snippet examples/network/fortuneclient/client.cpp 1 - - The only QTcpSocket signals we need in this example are - QTcpSocket::readyRead(), signifying that data has been received, and - QTcpSocket::error(), which we will use to catch any connection errors: - - \dots - \snippet examples/network/fortuneclient/client.cpp 3 - \dots - \snippet examples/network/fortuneclient/client.cpp 5 - - Clicking the \uicontrol{Get Fortune} button will invoke the \c - requestNewFortune() slot: - - \snippet examples/network/fortuneclient/client.cpp 6 - - In this slot, we initialize \c blockSize to 0, preparing to read a new block - of data. Because we allow the user to click \uicontrol{Get Fortune} before the - previous connection finished closing, we start off by aborting the - previous connection by calling QTcpSocket::abort(). (On an unconnected - socket, this function does nothing.) We then proceed to connecting to the - fortune server by calling QTcpSocket::connectToHost(), passing the - hostname and port from the user interface as arguments. - - As a result of calling \l{QTcpSocket::connectToHost()}{connectToHost()}, - one of two things can happen: - - \list - \li \e{The connection is established.} In this case, the server will send us a - fortune. QTcpSocket will emit \l{QTcpSocket::readyRead()}{readyRead()} - every time it receives a block of data. - - \li \e{An error occurs.} We need to inform the user if the connection - failed or was broken. In this case, QTcpSocket will emit - \l{QTcpSocket::error()}{error()}, and \c Client::displayError() will be - called. - \endlist - - Let's go through the \l{QTcpSocket::error()}{error()} case first: - - \snippet examples/network/fortuneclient/client.cpp 13 - - We pop up all errors in a dialog using - QMessageBox::information(). QTcpSocket::RemoteHostClosedError is silently - ignored, because the fortune server protocol ends with the server closing - the connection. - - Now for the \l{QTcpSocket::readyRead()}{readyRead()} alternative. This - signal is connected to \c Client::readFortune(): - - \snippet examples/network/fortuneclient/client.cpp 8 - \codeline - \snippet examples/network/fortuneclient/client.cpp 10 - - The protocol is based on QDataStream, so we start by creating a stream - object, passing the socket to QDataStream's constructor. We then - explicitly set the protocol version of the stream to QDataStream::Qt_4_0 - to ensure that we're using the same version as the fortune server, no - matter which version of Qt the client and server use. - - Now, TCP is based on sending a stream of data, so we cannot expect to get - the entire fortune in one go. Especially on a slow network, the data can - be received in several small fragments. QTcpSocket buffers up all incoming - data and emits \l{QTcpSocket::readyRead()}{readyRead()} for every new - block that arrives, and it is our job to ensure that we have received all - the data we need before we start parsing. The server's response starts - with the size of the packet, so first we need to ensure that we can read - the size, then we will wait until QTcpSocket has received the full packet. - - \snippet examples/network/fortuneclient/client.cpp 11 - \codeline - \snippet examples/network/fortuneclient/client.cpp 12 - - We proceed by using QDataStream's streaming operator to read the fortune - from the socket into a QString. Once read, we can call QLabel::setText() - to display the fortune. - - \sa {Fortune Server Example}, {Blocking Fortune Client Example} -*/ diff --git a/doc/src/examples/fortuneserver.qdoc b/doc/src/examples/fortuneserver.qdoc deleted file mode 100644 index 1f6def6c20..0000000000 --- a/doc/src/examples/fortuneserver.qdoc +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example network/fortuneserver - \title Fortune Server Example - - The Fortune Server example shows how to create a server for a simple - network service. It is intended to be run alongside the - \l{network/fortuneclient}{Fortune Client} example or the - \l{network/blockingfortuneclient}{Blocking Fortune Client} example. - - \image fortuneserver-example.png Screenshot of the Fortune Server example - - This example uses QTcpServer to accept incoming TCP connections, and a - simple QDataStream based data transfer protocol to write a fortune to the - connecting client (from the \l{network/fortuneclient}{Fortune Client} - example), before closing the connection. - - \snippet examples/network/fortuneserver/server.h 0 - - The server is implemented using a simple class with only one slot, for - handling incoming connections. - - \snippet examples/network/fortuneserver/server.cpp 1 - - In its constructor, our Server object calls QTcpServer::listen() to set up - a QTcpServer to listen on all addresses, on an arbitrary port. In then - displays the port QTcpServer picked in a label, so that user knows which - port the fortune client should connect to. - - \snippet examples/network/fortuneserver/server.cpp 2 - - Our server generates a list of random fortunes that is can send to - connecting clients. - - \snippet examples/network/fortuneserver/server.cpp 3 - - When a client connects to our server, QTcpServer will emit - QTcpServer::newConnection(). In turn, this will invoke our - sendFortune() slot: - - \snippet examples/network/fortuneserver/server.cpp 4 - - The purpose of this slot is to select a random line from our list of - fortunes, encode it into a QByteArray using QDataStream, and then write it - to the connecting socket. This is a common way to transfer binary data - using QTcpSocket. First we create a QByteArray and a QDataStream object, - passing the bytearray to QDataStream's constructor. We then explicitly set - the protocol version of QDataStream to QDataStream::Qt_4_0 to ensure that - we can communicate with clients from future versions of Qt. (See - QDataStream::setVersion().) - - \snippet examples/network/fortuneserver/server.cpp 6 - - At the start of our QByteArray, we reserve space for a 16 bit integer that - will contain the total size of the data block we are sending. We continue - by streaming in a random fortune. Then we seek back to the beginning of - the QByteArray, and overwrite the reserved 16 bit integer value with the - total size of the array. By doing this, we provide a way for clients to - verify how much data they can expect before reading the whole packet. - - \snippet examples/network/fortuneserver/server.cpp 7 - - We then call QTcpServer::newPendingConnection(), which returns the - QTcpSocket representing the server side of the connection. By connecting - QTcpSocket::disconnected() to QObject::deleteLater(), we ensure that the - socket will be deleted after disconnecting. - - \snippet examples/network/fortuneserver/server.cpp 8 - - The encoded fortune is written using QTcpSocket::write(), and we finally - call QTcpSocket::disconnectFromHost(), which will close the connection - after QTcpSocket has finished writing the fortune to the network. Because - QTcpSocket works asynchronously, the data will be written after this - function returns, and control goes back to Qt's event loop. The socket - will then close, which in turn will cause QObject::deleteLater() to delete - it. - - \sa {Fortune Client Example}, {Threaded Fortune Server Example} - */ diff --git a/doc/src/examples/framebufferobject2.qdoc b/doc/src/examples/framebufferobject2.qdoc deleted file mode 100644 index 9be0557f16..0000000000 --- a/doc/src/examples/framebufferobject2.qdoc +++ /dev/null @@ -1,37 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example opengl/framebufferobject2 - \title Framebuffer Object 2 Example - - The Framebuffer Object 2 example demonstrates how to use the - QGLFramebufferObject class to render into an off-screen buffer and - use the contents as a texture in a QGLWidget. - - \image framebufferobject2-example.png -*/ diff --git a/doc/src/examples/googlesuggest.qdoc b/doc/src/examples/googlesuggest.qdoc deleted file mode 100644 index 3af12456b0..0000000000 --- a/doc/src/examples/googlesuggest.qdoc +++ /dev/null @@ -1,180 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example network/googlesuggest - \title Google Suggest Example - - The Google Suggest example demonstrates how to use the QNetworkAccessManager - class to obtain a list of suggestions from the Google search engine as the - user types into a QLineEdit. - - \image googlesuggest-example.png - - The application makes use of the \c get function in - QNetworkAccessManager to post a request and obtain the result of the search - query sent to the Google search engine. The results returned are listed as - clickable links appearing below the search box as a drop-down menu. - - The widget is built up by a QLineEdit as the search box, and a QTreeView - used as a popup menu below the search box. - - \section1 GSuggestCompletion Class Declaration - - This class implements an event filter and a number of functions to display - the search results and to determent when and how to perform the search. - - \snippet examples/network/googlesuggest/googlesuggest.h 1 - - The class connects to a QLineEdit and uses a QTreeWidget to display the - results. A QTimer controls the start of the network requests that are - executed using a QNetworkAccessManager. - - \section1 GSuggestCompletion Class Implementation - - We start by defining a constant containing the URL to be used in the Google - queries. This is the basis for the query. The letters typed into the search - box will be added to the query to perform the search itself. - - \snippet examples/network/googlesuggest/googlesuggest.cpp 1 - - In the constructor, we set the parent of this GSuggestCompletion instance - to be the QLineEdit passed in. For simplicity, the QLineEdit is also stored - in the explicit \c editor member variable. - - We then create a QTreeWidget as a toplevel widget and configure the various - properties to give it the look of a popup widget. - - The popup will be populated by the results returned from Google. We set - the number of columns to be two, since we want to display both the - suggested search term and the number of hits it will trigger in the search - engine. - - Furthermore, we install the GSuggestCompletion instance as an event filter - on the QTreeWidget, and connect the \c itemClicked() signal with the \c - doneCompletion() slot. - - A single-shot QTimer is used to start the request when the user has stopped - typing for 500 ms. - - Finally, we connect the networkManagers \c finished() signal with the \c - handleNetworkData() slot to handle the incoming data. - - \snippet examples/network/googlesuggest/googlesuggest.cpp 2 - - Since the QTreeWidget popup has been instantiated as a toplevel widget, the - destructor has to delete it explicitly from memory to avoid a memory leak. - - \snippet examples/network/googlesuggest/googlesuggest.cpp 3 - - The event filter handles mouse press and key press events that are - delivered to the popup. For mouse press events we just hide the popup and - return focus to the editor widget, and then return true to prevent further - event processing. - - Key event handling is implemented so that Enter and Return execute the - selected link, while the Escape key hides the popup. Since we want to be - able to navigate the list of suggestions using the different navigation - keys on the keyboard we let Qt continue regular event processing for those - by returning false from the eventFilter reimplementation. - - For all other keys, the event will be passed on to the editor widget and the - popup is hidden. This way the user's typing will not be interrupted by the - popping up of the completion list. - - \snippet examples/network/googlesuggest/googlesuggest.cpp 4 - - The \c showCompletion() function populates the QTreeWidget with the results - returned from the query. It takes two QStringLists, one with the suggested - search terms and the other with the corresponding number of hits. - - \snippet examples/network/googlesuggest/googlesuggest.cpp 5 - - A QTreeWidgetItem is created for each index in the list and inserted into - the QTreeWidget. Finally, we adjust position and size of the popup to make - sure that it pops up in the correct position below the editor, and show it. - - The \c doneCompletion() function, which is called by the event filter when - either Enter or Return keys are pressed, stops the timer to prevent further - requests and passes the text of the selected item to the editor. We then - make the \c editor QLineEdit emit the returnPressed() signal, to which the - application can connect to open the respective web page. - - \snippet examples/network/googlesuggest/googlesuggest.cpp 6 - - The \c autoSuggest() slot is called when the timer times out, and uses the - text in the editor to build the complete search query. The query is then - passed to the QNetworkAccessManager's \c get() function to start the - request. - - \snippet examples/network/googlesuggest/googlesuggest.cpp 7 - - The function \c preventSuggest() stops the timer to prevent further - requests from being started. - - \snippet examples/network/googlesuggest/googlesuggest.cpp 8 - - When the network request is finished, the QNetworkAccessManager delivers the - data received from the server through the networkReply object. - - \snippet examples/network/googlesuggest/googlesuggest.cpp 9 - - To extract the data from the reply we use the \c readAll() function, which - is inherited from QIODevice and returns a QByteArray. Since this data is - encoded in XML we can use a QXmlStreamReader to traverse the data and - extract the search result as QStrings, which we can stream into two - QStringLists used to populate the popup. - - Finally, we schedule the QNetworkReply object for deletion using the \c - deleteLater function. - - \section1 SearchBox Class Declaration - - The SearchBox class inherits QLineEdit and adds the protected slot \c - doSearch(). - - A \c GSuggestCompletion member provides the SearchBox with the request - functionality and the suggestions returned from the Google search engine. - - \snippet examples/network/googlesuggest/searchbox.h 1 - - \section1 SearchBox Class Implementation - - The search box constructor instantiates the GSuggestCompletion object and - connects the returnPressed() signal to the doSearch() slot. - - \snippet examples/network/googlesuggest/searchbox.cpp 1 - - The function \c doSearch() stops the completer from sending any further - queries to the search engine. - - Further, the function extracts the selected search phrase and opens it - in the default web browser using QDesktopServices. - - \snippet examples/network/googlesuggest/searchbox.cpp 2 - -*/ diff --git a/doc/src/examples/grabber.qdoc b/doc/src/examples/grabber.qdoc deleted file mode 100644 index 8cdd9ef1a1..0000000000 --- a/doc/src/examples/grabber.qdoc +++ /dev/null @@ -1,35 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example opengl/grabber - \title Grabber Example - - The Grabber examples shows how to retrieve the contents of an OpenGL framebuffer. - - \image grabber-example.png -*/ diff --git a/doc/src/examples/hellogl.qdoc b/doc/src/examples/hellogl.qdoc deleted file mode 100644 index f6f8591ad0..0000000000 --- a/doc/src/examples/hellogl.qdoc +++ /dev/null @@ -1,305 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example opengl/hellogl - \title Hello GL Example - - The Hello GL example demonstrates the basic use of the OpenGL-related classes - provided with Qt. - - \image hellogl-example.png - - Qt provides the QGLWidget class to enable OpenGL graphics to be rendered within - a standard application user interface. By subclassing this class, and providing - reimplementations of event handler functions, 3D scenes can be displayed on - widgets that can be placed in layouts, connected to other objects using signals - and slots, and manipulated like any other widget. - - \tableofcontents - - \section1 GLWidget Class Definition - - The \c GLWidget class contains some standard public definitions for the - constructor, destructor, \l{QWidget::sizeHint()}{sizeHint()}, and - \l{QWidget::minimumSizeHint()}{minimumSizeHint()} functions: - - \snippet examples/opengl/hellogl/glwidget.h 0 - - We use a destructor to ensure that any OpenGL-specific data structures - are deleted when the widget is no longer needed (although in this case nothing - needs cleaning up). - - \snippet examples/opengl/hellogl/glwidget.h 1 - - The signals and slots are used to allow other objects to interact with the - 3D scene. - - \snippet examples/opengl/hellogl/glwidget.h 2 - - OpenGL initialization, viewport resizing, and painting are handled by - reimplementing the QGLWidget::initializeGL(), QGLWidget::resizeGL(), and - QGLWidget::paintGL() handler functions. To enable the user to interact - directly with the scene using the mouse, we reimplement - QWidget::mousePressEvent() and QWidget::mouseMoveEvent(). - - \snippet examples/opengl/hellogl/glwidget.h 3 - - The rest of the class contains utility functions and variables that are - used to construct and hold orientation information for the scene. The - \c logo variable will be used to hold a pointer to the QtLogo object which - contains all the geometry. - - \section1 GLWidget Class Implementation - - In this example, we split the class into groups of functions and describe - them separately. This helps to illustrate the differences between subclasses - of native widgets (such as QWidget and QFrame) and QGLWidget subclasses. - - \section2 Widget Construction and Sizing - - The constructor provides default rotation angles for the scene, sets - the pointer to the QtLogo object to null, and sets up some colors for - later use. - - \snippet examples/opengl/hellogl/glwidget.cpp 0 - - We also implement a destructor to release OpenGL-related resources when the - widget is deleted: - - \snippet examples/opengl/hellogl/glwidget.cpp 1 - - In this case nothing requires cleaning up. - - We provide size hint functions to ensure that the widget is shown at a - reasonable size: - - \snippet examples/opengl/hellogl/glwidget.cpp 2 - \codeline - \snippet examples/opengl/hellogl/glwidget.cpp 3 - \snippet examples/opengl/hellogl/glwidget.cpp 4 - - The widget provides three slots that enable other components in the - example to change the orientation of the scene: - - \snippet examples/opengl/hellogl/glwidget.cpp 5 - - In the above slot, the \c xRot variable is updated only if the new angle - is different to the old one, the \c xRotationChanged() signal is emitted to - allow other components to be updated, and the widget's - \l{QGLWidget::updateGL()}{updateGL()} handler function is called. - - The \c setYRotation() and \c setZRotation() slots perform the same task for - rotations measured by the \c yRot and \c zRot variables. - - \section2 OpenGL Initialization - - The \l{QGLWidget::initializeGL()}{initializeGL()} function is used to - perform useful initialization tasks that are needed to render the 3D scene. - These often involve defining colors and materials, enabling and disabling - certain rendering flags, and setting other properties used to customize the - rendering process. - - \snippet examples/opengl/hellogl/glwidget.cpp 6 - - In this example, we reimplement the function to set the background color, - create a QtLogo object instance which will contain all the geometry to - display, and set up the rendering process to use a particular shading model - and rendering flags. - - \section2 Resizing the Viewport - - The \l{QGLWidget::resizeGL()}{resizeGL()} function is used to ensure that - the OpenGL implementation renders the scene onto a viewport that matches the - size of the widget, using the correct transformation from 3D coordinates to - 2D viewport coordinates. - - The function is called whenever the widget's dimensions change, and is - supplied with the new width and height. Here, we define a square viewport - based on the length of the smallest side of the widget to ensure that - the scene is not distorted if the widget has sides of unequal length: - - \snippet examples/opengl/hellogl/glwidget.cpp 8 - - A discussion of the projection transformation used is outside the scope of - this example. Please consult the OpenGL reference documentation for an - explanation of projection matrices. - - \section2 Painting the Scene - - The \l{QGLWidget::paintGL()}{paintGL()} function is used to paint the - contents of the scene onto the widget. For widgets that only need to be - decorated with pure OpenGL content, we reimplement QGLWidget::paintGL() - \e instead of reimplementing QWidget::paintEvent(): - - \snippet examples/opengl/hellogl/glwidget.cpp 7 - - In this example, we clear the widget using the background color that - we defined in the \l{QGLWidget::initializeGL()}{initializeGL()} function, - set up the frame of reference for the geometry we want to display, and - call the draw method of the QtLogo object to render the scene. - - \section2 Mouse Handling - - Just as in subclasses of native widgets, mouse events are handled by - reimplementing functions such as QWidget::mousePressEvent() and - QWidget::mouseMoveEvent(). - - The \l{QWidget::mousePressEvent()}{mousePressEvent()} function simply - records the position of the mouse when a button is initially pressed: - - \snippet examples/opengl/hellogl/glwidget.cpp 9 - - The \l{QWidget::mouseMoveEvent()}{mouseMoveEvent()} function uses the - previous location of the mouse cursor to determine how much the object - in the scene should be rotated, and in which direction: - - \snippet examples/opengl/hellogl/glwidget.cpp 10 - - Since the user is expected to hold down the mouse button and drag the - cursor to rotate the object, the cursor's position is updated every time - a move event is received. - - \section1 QtLogo Class - - This class encapsulates the OpenGL geometry data which will be rendered - in the basic 3D scene. - - \snippet examples/opengl/shared/qtlogo.h 0 - - The geometry is divided into a list of parts which may be rendered in - different ways. The data itself is contained in a Geometry structure that - includes the vertices, their lighting normals and index values which - point into the vertices, grouping them into faces. - - \snippet examples/opengl/shared/qtlogo.cpp 0 - - The data in the Geometry class is stored in QVector members - which are convenient for use with OpenGL because they expose raw - contiguous floating point values via the constData() method. Methods - are included for adding new vertex data, either with smooth normals, or - facetted normals; and for enabling the geometry ready for rendering. - - \snippet examples/opengl/shared/qtlogo.cpp 1 - - The higher level Patch class has methods for accumulating the geometry - one face at a time, and treating collections of faces or "patches" with - transformations, applying different colors or smoothing. Although faces - may be added as triangles or quads, at the OpenGL level all data is - treated as triangles for compatibility with OpenGL/ES. - - \snippet examples/opengl/shared/qtlogo.cpp 2 - - Drawing a Patch is simply acheived by applying any transformation, - and material effect, then drawing the data using the index range for - the patch. The model-view matrix is saved and then restored so that - any transformation does not affect other parts of the scene. - - \snippet examples/opengl/shared/qtlogo.cpp 3 - - The geometry is built once on construction of the QtLogo, and it is - paramaterized on a number of divisions - which controls how "chunky" the - curved section of the logo looks - and on a scale, so larger and smaller - QtLogo objects can be created without having to use OpenGL scaling - (which would force normal recalculation). - - The building process is done by helper classes (read the source for full - details) which only exist during the build phase, to assemble the parts - of the scene. - - \snippet examples/opengl/shared/qtlogo.cpp 4 - - Finally the complete QtLogo scene is simply drawn by enabling the data arrays - and then iterating over the parts, calling draw() on each one. - - \section1 Window Class Definition - - The \c Window class is used as a container for the \c GLWidget used to - display the scene: - - \snippet examples/opengl/hellogl/window.h 0 - - In addition, it contains sliders that are used to change the orientation - of the object in the scene. - - \section1 Window Class Implementation - - The constructor constructs an instance of the \c GLWidget class and some - sliders to manipulate its contents. - - \snippet examples/opengl/hellogl/window.cpp 0 - - We connect the \l{QAbstractSlider::valueChanged()}{valueChanged()} signal - from each of the sliders to the appropriate slots in \c{glWidget}. - This allows the user to change the orientation of the object by dragging - the sliders. - - We also connect the \c xRotationChanged(), \c yRotationChanged(), and - \c zRotationChanged() signals from \c glWidget to the - \l{QAbstractSlider::setValue()}{setValue()} slots in the - corresponding sliders. - - \snippet examples/opengl/hellogl/window.cpp 1 - - The sliders are placed horizontally in a layout alongside the \c GLWidget, - and initialized with suitable default values. - - The \c createSlider() utility function constructs a QSlider, and ensures - that it is set up with a suitable range, step value, tick interval, and - page step value before returning it to the calling function: - - \snippet examples/opengl/hellogl/window.cpp 2 - - \section1 Summary - - The \c GLWidget class implementation shows how to subclass QGLWidget for - the purposes of rendering a 3D scene using OpenGL calls. Since QGLWidget - is a subclass of QWidget, subclasses of QGLWidget can be placed in layouts - and provided with interactive features just like normal custom widgets. - - We ensure that the widget is able to correctly render the scene using OpenGL - by reimplementing the following functions: - - \list - \li QGLWidget::initializeGL() sets up resources needed by the OpenGL implementation - to render the scene. - \li QGLWidget::resizeGL() resizes the viewport so that the rendered scene fits onto - the widget, and sets up a projection matrix to map 3D coordinates to 2D viewport - coordinates. - \li QGLWidget::paintGL() performs painting operations using OpenGL calls. - \endlist - - Since QGLWidget is a subclass of QWidget, it can also be used - as a normal paint device, allowing 2D graphics to be drawn with QPainter. - This use of QGLWidget is discussed in the \l{2D Painting Example}{2D Painting} - example. - - More advanced users may want to paint over parts of a scene rendered using - OpenGL. QGLWidget allows pure OpenGL rendering to be mixed with QPainter - calls, but care must be taken to maintain the state of the OpenGL implementation. - See the \l{Overpainting Example}{Overpainting} example for more information. -*/ diff --git a/doc/src/examples/hellogl_es.qdoc b/doc/src/examples/hellogl_es.qdoc deleted file mode 100644 index 212e760542..0000000000 --- a/doc/src/examples/hellogl_es.qdoc +++ /dev/null @@ -1,128 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example opengl/hellogl_es - \title Hello GL ES Example - - The Hello GL ES example is the \l{Hello GL Example} ported to OpenGL ES. - It also included some effects from the OpenGL \l{Overpainting Example}. - - \image hellogl-es-example.png - - A complete introduction to OpenGL ES and a description of all differences - between OpenGL and OpenGL ES is out of the scope of this document; but - we will describe some of the major issues and differences. - - Since Hello GL ES is a direct port of standard OpenGL code, it is a fairly - good example for porting OpenGL code to OpenGL ES. - - \tableofcontents - - \section1 Using QGLWidget - - QGLWidget can be used for OpenGL ES similar to the way it is used with - standard OpenGL; but there are some differences. We use EGL 1.0 to embedd - the OpenGL ES window within the native window manager. In - QGLWidget::initializeGL() we initialize OpenGL ES. - - \section1 Porting OpenGL to OpenGL ES - - Since OpenGL ES is missing the immediate mode and does not support quads, - we have to create triangle arrays. - - We create a quad by adding vertices to a QList of vertices. We create both - sides of the quad and hardcode a distance of 0.05f. We also compute the - correct normal for each face and store them in another QList. - - \snippet examples/opengl/hellogl_es/glwidget.cpp 0 - - And then we convert the complete list of vertexes and the list of normals - into the native OpenGL ES format that we can use with the OpenGL ES API. - - \snippet examples/opengl/hellogl_es/glwidget.cpp 1 - - In \c paintQtLogo() we draw the triangle array using OpenGL ES. We use - q_vertexTypeEnum to abstract the fact that our vertex and normal arrays - are either in float or in fixed point format. - - \snippet examples/opengl/hellogl_es/glwidget.cpp 2 - - \section1 Using QGLPainter - - Since the \c QGLPainter is slower for OpenGL ES we paint the bubbles with - the rasterizer and cache them in a QImage. This happends only once during - the initialiazation. - - \snippet examples/opengl/hellogl_es/bubble.cpp 0 - - For each bubble this QImage is then drawn to the QGLWidget by using the - according QPainter with transparency enabled. - - \snippet examples/opengl/hellogl_es/bubble.cpp 1 - - Another difference beetwen OpenGL and OpenGL ES is that OpenGL ES does not - support glPushAttrib(GL_ALL_ATTRIB_BITS). So we have to restore all the - OpenGL states ourselves, after we created the QPainter in - GLWidget::paintGL(). - - \snippet examples/opengl/hellogl_es/glwidget.cpp 3 - - Setting up up the model view matrix and setting the right OpenGL states is - done in the same way as for standard OpenGL. - - \snippet examples/opengl/hellogl_es/glwidget.cpp 4 - - Now we have to restore the OpenGL state for the QPainter. This is not done - automatically for OpenGL ES. - - \snippet examples/opengl/hellogl_es/glwidget.cpp 5 - - Now we use the QPainter to draw the transparent bubbles. - - \snippet examples/opengl/hellogl_es/glwidget.cpp 6 - - In the end, we calculate the framerate and display it using the QPainter - again. - - \snippet examples/opengl/hellogl_es/glwidget.cpp 7 - - After we finished all the drawing operations we swap the screen buffer. - - \snippet examples/opengl/hellogl_es/glwidget.cpp 8 - - \section1 Summary - - Similar to the \l{Hello GL Example}, we subclass QGLWidget to render - a 3D scene using OpenGL ES calls. QGLWidget is a subclass of QWidget. - Hence, its \l{QGLWidget}'s subclasses can be placed in layouts and - provided with interactive features just like normal custom widgets. - - QGLWidget allows pure OpenGL ES rendering to be mixed with QPainter calls, - but care must be taken to maintain the state of the OpenGL ES - implementation. -*/ diff --git a/doc/src/examples/http.qdoc b/doc/src/examples/http.qdoc deleted file mode 100644 index 7ca474b385..0000000000 --- a/doc/src/examples/http.qdoc +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example network/http - \title HTTP Example - - The HTTP example demonstrates a simple HTTP client that shows how to fetch files - specified by URLs from remote hosts. - - \image http-example.png -*/ diff --git a/doc/src/examples/loopback.qdoc b/doc/src/examples/loopback.qdoc deleted file mode 100644 index 5f684447ca..0000000000 --- a/doc/src/examples/loopback.qdoc +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example network/loopback - \title Loopback Example - - The Loopback example shows how to communicate between simple clients and servers on a local - host. - - \image loopback-example.png -*/ diff --git a/doc/src/examples/masterdetail.qdoc b/doc/src/examples/masterdetail.qdoc deleted file mode 100644 index 2b9e270b03..0000000000 --- a/doc/src/examples/masterdetail.qdoc +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example sql/masterdetail - \title Master Detail Example - - The Master Detail Example shows how to present data from different - data sources in the same application. The album titles, and the - corresponding artists and release dates, are kept in a - database, while each album's tracks are stored in an XML - file. - - The example also shows how to add as well as remove data from both - the database and the associated XML file using the API provided by - the QtSql and QtXml modules, respectively. - - \image masterdetail-example.png -*/ diff --git a/doc/src/examples/multicastreceiver.qdoc b/doc/src/examples/multicastreceiver.qdoc deleted file mode 100644 index 7e306d232c..0000000000 --- a/doc/src/examples/multicastreceiver.qdoc +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example network/multicastreceiver - \title Multicast Receiver Example - - The Multicast Receiever example shows how to receive information that is - sent to a multicast group. - - \image multicastreceiver-example.png -*/ diff --git a/doc/src/examples/multicastsender.qdoc b/doc/src/examples/multicastsender.qdoc deleted file mode 100644 index 687f760a38..0000000000 --- a/doc/src/examples/multicastsender.qdoc +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example network/multicastsender - \title Multicast Sender Example - - The Multicast Sender example shows how to send information to multiple - clients in a multicast group. - - \image multicastsender-example.png -*/ diff --git a/doc/src/examples/network-chat.qdoc b/doc/src/examples/network-chat.qdoc deleted file mode 100644 index e79a521c3d..0000000000 --- a/doc/src/examples/network-chat.qdoc +++ /dev/null @@ -1,37 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example network/network-chat - \title Network Chat Example - - The Network Chat example demonstrates a stateful peer-to-peer Chat client - that uses broadcasting with QUdpSocket and QNetworkInterface to discover - its peers. - - \image network-chat-example.png -*/ diff --git a/doc/src/examples/overpainting.qdoc b/doc/src/examples/overpainting.qdoc deleted file mode 100644 index d20ee64698..0000000000 --- a/doc/src/examples/overpainting.qdoc +++ /dev/null @@ -1,243 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example opengl/overpainting - \title Overpainting Example - - The Overpainting example shows how QPainter can be used - to overpaint a scene rendered using OpenGL in a QGLWidget. - - \image overpainting-example.png - - QGLWidget provides a widget with integrated OpenGL graphics support - that enables 3D graphics to be displayed using normal OpenGL calls, - yet also behaves like any other standard Qt widget with support for - signals and slots, properties, and Qt's action system. - - Usually, QGLWidget is subclassed to display a pure 3D scene. The - developer reimplements \l{QGLWidget::initializeGL()}{initializeGL()} - to initialize any required resources, \l{QGLWidget::resizeGL()}{resizeGL()} - to set up the projection and viewport, and - \l{QGLWidget::paintGL()}{paintGL()} to perform the OpenGL calls needed - to render the scene. However, it is possible to subclass QGLWidget - differently to allow 2D graphics, drawn using QPainter, to be - painted over a scene rendered using OpenGL. - - In this example, we demonstrate how this is done by reusing the code - from the \l{Hello GL Example}{Hello GL} example to provide a 3D scene, - and painting over it with some translucent 2D graphics. Instead of - examining each class in detail, we only cover the parts of the - \c GLWidget class that enable overpainting, and provide more detailed - discussion in the final section of this document. - - \section1 GLWidget Class Definition - - The \c GLWidget class is a subclass of QGLWidget, based on the one used - in the \l{Hello GL Example}{Hello GL} example. Rather than describe the - class as a whole, we show the first few lines of the class and only - discuss the changes we have made to the rest of it: - - \snippet examples/opengl/overpainting/glwidget.h 0 - \dots - \snippet examples/opengl/overpainting/glwidget.h 1 - \dots - \snippet examples/opengl/overpainting/glwidget.h 4 - - As usual, the widget uses \l{QGLWidget::initializeGL()}{initializeGL()} - to set up geometry for our scene and perform OpenGL initialization tasks. - The \l{QGLWidget::resizeGL()}{resizeGL()} function is used to ensure that - the 3D graphics in the scene are transformed correctly to the 2D viewport - displayed in the widget. - - Instead of implementing \l{QGLWidget::paintGL()}{paintGL()} to handle updates - to the widget, we implement a normal QWidget::paintEvent(). This - allows us to mix OpenGL calls and QPainter operations in a controlled way. - - In this example, we also implement QWidget::showEvent() to help with the - initialization of the 2D graphics used. - - The new private member functions and variables relate exclusively to the - 2D graphics and animation. The \c animate() slot is called periodically by the - \c animationTimer to update the widget; the \c createBubbles() function - initializes the \c bubbles list with instances of a helper class used to - draw the animation; the \c drawInstructions() function is responsible for - a semi-transparent message that is also overpainted onto the OpenGL scene. - - \section1 GLWidget Class Implementation - - Again, we only show the parts of the \c GLWidget implementation that are - relevant to this example. In the constructor, we initialize a QTimer to - control the animation: - - \snippet examples/opengl/overpainting/glwidget.cpp 0 - - We turn off the widget's \l{QWidget::autoFillBackground}{autoFillBackground} property to - instruct OpenGL not to paint a background for the widget when - \l{QPainter::begin()}{QPainter::begin()} is called. - - As in the \l{Hello GL Example}{Hello GL} example, the destructor is responsible - for freeing any OpenGL-related resources: - - \snippet examples/opengl/overpainting/glwidget.cpp 1 - - The \c initializeGL() function is fairly minimal, only setting up the QtLogo - object used in the scene. See the \l{Hello GL Example}{Hello GL} example - for details of the QtLogo class. - - \snippet examples/opengl/overpainting/glwidget.cpp 2 - - To cooperate fully with QPainter, we defer matrix stack operations and attribute - initialization until the widget needs to be updated. - - In this example, we implement \l{QWidget::paintEvent()}{paintEvent()} rather - than \l{QGLWidget::paintGL()}{paintGL()} to render - our scene. When drawing on a QGLWidget, the paint engine used by QPainter - performs certain operations that change the states of the OpenGL - implementation's matrix and property stacks. Therefore, it is necessary to - make all the OpenGL calls to display the 3D graphics before we construct - a QPainter to draw the 2D overlay. - - We render a 3D scene by setting up model and projection transformations - and other attributes. We use an OpenGL stack operation to preserve the - original matrix state, allowing us to recover it later: - - \snippet examples/opengl/overpainting/glwidget.cpp 4 - - We define a color to use for the widget's background, and set up various - attributes that define how the scene will be rendered. - - \snippet examples/opengl/overpainting/glwidget.cpp 6 - - We call the \c setupViewport() private function to set up the - projection used for the scene. This is unnecessary in OpenGL - examples that implement the \l{QGLWidget::paintGL()}{paintGL()} - function because the matrix stacks are usually unmodified between - calls to \l{QGLWidget::resizeGL()}{resizeGL()} and - \l{QGLWidget::paintGL()}{paintGL()}. - - Since the widget's background is not drawn by the system or by Qt, we use - an OpenGL call to paint it before positioning the object defined earlier - in the scene: - - \snippet examples/opengl/overpainting/glwidget.cpp 7 - - Once the QtLogo object's draw method has been executed, the GL - states we changed and the matrix stack needs to be restored to its - original state at the start of this function before we can begin - overpainting: - - \snippet examples/opengl/overpainting/glwidget.cpp 8 - - With the 3D graphics done, we construct a QPainter for use on the widget - and simply overpaint the widget with 2D graphics; in this case, using a - helper class to draw a number of translucent bubbles onto the widget, - and calling \c drawInstructions() to overlay some instructions: - - \snippet examples/opengl/overpainting/glwidget.cpp 10 - - When QPainter::end() is called, suitable OpenGL-specific calls are made to - write the scene, and its additional contents, onto the widget. - - With \l{QGLWidget::paintGL()}{paintGL()} the - \l{QGLWidget::swapBuffers()}{swapBuffers()} call is done for us. But an explicit - call to swapBuffers() is still not required because in the - \l{QWidget::paintEvent()}{paintEvent()} method the QPainter on the OpenGL - widget takes care of this for us. - - The implementation of the \l{QGLWidget::resizeGL()}{resizeGL()} function - sets up the dimensions of the viewport and defines a projection - transformation: - - \snippet examples/opengl/overpainting/glwidget.cpp 11 - - Ideally, we want to arrange the 2D graphics to suit the widget's dimensions. - To achieve this, we implement the \l{QWidget::showEvent()}{showEvent()} handler, - creating new graphic elements (bubbles) if necessary at appropriate positions - in the widget. - - \snippet examples/opengl/overpainting/glwidget.cpp 12 - - This function only has an effect if less than 20 bubbles have already been - created. - - The \c animate() slot is called every time the widget's \c animationTimer emits - the \l{QTimer::timeout()}{timeout()} signal. This keeps the bubbles moving - around. - - \snippet examples/opengl/overpainting/glwidget.cpp 13 - - We simply iterate over the bubbles in the \c bubbles list, updating the - widget before and after each of them is moved. - - The \c setupViewport() function is called from \c paintEvent() - and \c resizeGL(). - - \snippet examples/opengl/overpainting/glwidget.cpp 14 - - The \c drawInstructions() function is used to prepare some basic - instructions that will be painted with the other 2D graphics over - the 3D scene. - - \snippet examples/opengl/overpainting/glwidget.cpp 15 - - \section1 Summary - - When overpainting 2D content onto 3D content, we need to use a QPainter - \e and make OpenGL calls to achieve the desired effect. Since QPainter - itself uses OpenGL calls when used on a QGLWidget subclass, we need to - preserve the state of various OpenGL stacks when we perform our own - calls, using the following approach: - - \list - \li Reimplement QGLWidget::initializeGL(), but only perform minimal - initialization. QPainter will perform its own initialization - routines, modifying the matrix and property stacks, so it is better - to defer certain initialization tasks until just before you render - the 3D scene. - \li Reimplement QGLWidget::resizeGL() as in the pure 3D case. - \li Reimplement QWidget::paintEvent() to draw both 2D and 3D graphics. - \endlist - - The \l{QWidget::paintEvent()}{paintEvent()} implementation performs the - following tasks: - - \list - \li Push the current OpenGL modelview matrix onto a stack. - \li Perform initialization tasks usually done in the - \l{QGLWidget::initializeGL()}{initializeGL()} function. - \li Perform code that would normally be located in the widget's - \l{QGLWidget::resizeGL()}{resizeGL()} function to set the correct - perspective transformation and set up the viewport. - \li Render the scene using OpenGL calls. - \li Pop the OpenGL modelview matrix off the stack. - \li Construct a QPainter object. - \li Initialize it for use on the widget with the QPainter::begin() function. - \li Draw primitives using QPainter's member functions. - \li Call QPainter::end() to finish painting. - \endlist -*/ diff --git a/doc/src/examples/pbuffers.qdoc b/doc/src/examples/pbuffers.qdoc deleted file mode 100644 index d87427b56a..0000000000 --- a/doc/src/examples/pbuffers.qdoc +++ /dev/null @@ -1,37 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example opengl/pbuffers - \title Pixel Buffers Example - - The Pixel Buffers example demonstrates how to use the - QGLPixelBuffer class to render into an off-screen buffer and use - the contents as a dynamic texture in a QGLWidget. - - \image pbuffers-example.png -*/ diff --git a/doc/src/examples/pbuffers2.qdoc b/doc/src/examples/pbuffers2.qdoc deleted file mode 100644 index f05b2dd13b..0000000000 --- a/doc/src/examples/pbuffers2.qdoc +++ /dev/null @@ -1,37 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example opengl/pbuffers2 - \title Pixel Buffers 2 Example - - The Pixel Buffers 2 example demonstrates how to use the - QGLPixelBuffer class to render into an off-screen buffer and use - the contents as a dynamic texture in a QGLWidget. - - \image pbuffers2-example.png -*/ diff --git a/doc/src/examples/querymodel.qdoc b/doc/src/examples/querymodel.qdoc deleted file mode 100644 index 88ac0d7297..0000000000 --- a/doc/src/examples/querymodel.qdoc +++ /dev/null @@ -1,37 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example sql/querymodel - \title Query Model Example - - The Query Model example shows how to make customized versions of - data obtained from a SQL query, using a model that encapsulates - the query and table views to display the results. - - \image querymodel-example.png -*/ diff --git a/doc/src/examples/relationaltablemodel.qdoc b/doc/src/examples/relationaltablemodel.qdoc deleted file mode 100644 index b1b9492a23..0000000000 --- a/doc/src/examples/relationaltablemodel.qdoc +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example sql/relationaltablemodel - \title Relational Table Model Example - - The Relational Table Model example shows how to use table views with a relational - model to visualize the relations between items in a database. - - \image relationaltablemodel-example.png -*/ diff --git a/doc/src/examples/samplebuffers.qdoc b/doc/src/examples/samplebuffers.qdoc deleted file mode 100644 index 3b3c0c564b..0000000000 --- a/doc/src/examples/samplebuffers.qdoc +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example opengl/samplebuffers - \title Sample Buffers Example - - The Sample Buffers example demonstrates how to use and enable - sample buffers in a QGLWidget. - - \image samplebuffers-example.png -*/ diff --git a/doc/src/examples/saxbookmarks.qdoc b/doc/src/examples/saxbookmarks.qdoc deleted file mode 100644 index f41ce5c363..0000000000 --- a/doc/src/examples/saxbookmarks.qdoc +++ /dev/null @@ -1,40 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example xml/saxbookmarks - \title SAX Bookmarks Example - - The SAX Bookmarks example provides a reader for XML Bookmark Exchange Language (XBEL) - files that uses Qt's SAX-based API to read and parse the files. The DOM Bookmarks - example provides an alternative way to read this type of file. - - \image saxbookmarks-example.png - - See the \l{XML Bookmark Exchange Language Resource Page} for more - information about XBEL files. -*/ diff --git a/doc/src/examples/securesocketclient.qdoc b/doc/src/examples/securesocketclient.qdoc deleted file mode 100644 index 11d9aaefcc..0000000000 --- a/doc/src/examples/securesocketclient.qdoc +++ /dev/null @@ -1,39 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example network/securesocketclient - \title Secure Socket Client Example - - The Secure Socket Client example shows how to use QSslSocket to - communicate over an encrypted (SSL) connection. It also demonstrates how - to deal with authenticity problems, and how to display security and - certificate information. - - \image securesocketclient.png - \image securesocketclient2.png -*/ diff --git a/doc/src/examples/sqlbrowser.qdoc b/doc/src/examples/sqlbrowser.qdoc deleted file mode 100644 index 81cf2d049d..0000000000 --- a/doc/src/examples/sqlbrowser.qdoc +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example sql/sqlbrowser - \title SQL Browser - - The SQL Browser example shows how a data browser can be used to visualize - the results of SQL statements on a live database. - - \image sqlbrowser-demo.png -*/ diff --git a/doc/src/examples/sqlwidgetmapper.qdoc b/doc/src/examples/sqlwidgetmapper.qdoc deleted file mode 100644 index b9ea28849e..0000000000 --- a/doc/src/examples/sqlwidgetmapper.qdoc +++ /dev/null @@ -1,185 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example sql/sqlwidgetmapper - \title SQL Widget Mapper Example - - The SQL Widget Mapper example shows how to use a map information from a - database to widgets on a form. - - \image sql-widget-mapper.png - - In the \l{Combo Widget Mapper Example}, we showed how to use a named - mapping between a widget mapper and a QComboBox widget with a special - purpose model to relate values in the model to a list of choices. - - Again, we create a \c Window class with an almost identical user interface, - providing a combo box to allow their addresses to be classified as "Home", - "Work" or "Other". However, instead of using a separate model to hold these - address types, we use one database table to hold the example data and - another to hold the address types. In this way, we store all the - information in the same place. - - \section1 Window Class Definition - - The class provides a constructor, a slot to keep the buttons up to date, - and a private function to set up the model: - - \snippet examples/sql/sqlwidgetmapper/window.h Window definition - - In addition to the QDataWidgetMapper object and the controls used to make - up the user interface, we use a QStandardItemModel to hold our data and - a QStringListModel to hold information about the types of address that - can be applied to each person's data. - - \section1 Window Class Implementation - - The first act performed by the \c Window class constructor is to set up - the model used to hold the example data. Since this is a key part of the - example, we will look at this first. - - The model is initialized in the window's \c{setupModel()} function. Here, - we create a SQLite database containing a "person" table with primary key, - name, address and type fields. - - \snippet examples/sql/sqlwidgetmapper/window.cpp Set up the main table - - On each row of the table, we insert default values for these fields, - including values for the address types that correspond to the address - types are stored in a separate table. - - \image widgetmapper-sql-mapping-table.png - - We create an "addresstype" table containing the identifiers used in the - "person" table and the corresponding strings: - - \snippet examples/sql/sqlwidgetmapper/window.cpp Set up the address type table - - The "typeid" field in the "person" table is related to the contents of - the "addresstype" table via a relation in a QSqlRelationalTableModel. - This kind of model performs all the necessary work to store the data in - a database and also allows any relations to be used as models in their - own right. - - In this case, we have defined a relation for the "typeid" field in the - "person" table that relates it to the "id" field in the "addresstype" - table and which causes the contents of the "description" field to be - used wherever the "typeid" is presented to the user. (See the - QSqlRelationalTableModel::setRelation() documentation for details.) - - \image widgetmapper-sql-mapping.png - - The constructor of the \c Window class can be explained in three parts. - In the first part, we set up the model used to hold the data, then we set - up the widgets used for the user interface: - - \snippet examples/sql/sqlwidgetmapper/window.cpp Set up widgets - - We obtain a model for the combo box from the main model, based on the - relation we set up for the "typeid" field. The call to the combo box's - \l{QComboBox::}{setModelColumn()} selects the field in the field in the - model to display. - - Note that this approach is similar to the one used in the - \l{Combo Widget Mapper Example} in that we set up a model for the - combo box. However, in this case, we obtain a model based on a relation - in the QSqlRelationalTableModel rather than create a separate one. - - Next, we set up the widget mapper, relating each input widget to a field - in the model: - - \snippet examples/sql/sqlwidgetmapper/window.cpp Set up the mapper - - For the combo box, we already know the index of the field in the model - from the \c{setupModel()} function. We use a QSqlRelationalDelegate as - a proxy between the mapper and the input widgets to match up the "typeid" - values in the model with those in the combo box's model and populate the - combo box with descriptions rather than integer values. - - As a result, the user is able to select an item from the combo box, - and the associated value is written back to the model. - - The rest of the constructor is very similar to that of the - \l{Simple Widget Mapper Example}: - - \snippet examples/sql/sqlwidgetmapper/window.cpp Set up connections and layouts - - We show the implementation of the \c{updateButtons()} slot for - completeness: - - \snippet examples/sql/sqlwidgetmapper/window.cpp Slot for updating the buttons - - \omit - \section1 Delegate Class Definition and Implementation - - The delegate we use to mediate interaction between the widget mapper and - the input widgets is a small QItemDelegate subclass: - - \snippet examples/sql/sqlwidgetmapper/delegate.h Delegate class definition - - This provides implementations of the two standard functions used to pass - data between editor widgets and the model (see the \l{Delegate Classes} - documentation for a more general description of these functions). - - Since we only provide an empty implementation of the constructor, we - concentrate on the other two functions. - - The \l{QItemDelegate::}{setEditorData()} implementation takes the data - referred to by the model index supplied and processes it according to - the presence of a \c currentIndex property in the editor widget: - - \snippet examples/sql/sqlwidgetmapper/delegate.cpp setEditorData implementation - - If, like QComboBox, the editor widget has this property, it is set using - the value from the model. Since we are passing around QVariant values, - the strings stored in the model are automatically converted to the integer - values needed for the \c currentIndex property. - - As a result, instead of showing "0", "1" or "2" in the combo box, one of - its predefined set of items is shown. We call QItemDelegate::setEditorData() - for widgets without the \c currentIndex property. - - The \l{QItemDelegate::}{setModelData()} implementation performs the reverse - process, taking the value stored in the widget's \c currentIndex property - and storing it back in the model: - - \snippet examples/sql/sqlwidgetmapper/delegate.cpp setModelData implementation - \endomit - - \section1 Summary and Further Reading - - The use of a separate model for the combo box and a special delegate for the - widget mapper allows us to present a menu of choices to the user. Although - the choices are stored in the same database as the user's data, they are held - in a separate table. Using this approach, we can reconstructed complete records - at a later time while using database features appropriately. - - If SQL models are not being used, it is still possible to use more than - one model to present choices to the user. This is covered by the - \l{Combo Widget Mapper Example}. -*/ diff --git a/doc/src/examples/tablemodel.qdoc b/doc/src/examples/tablemodel.qdoc deleted file mode 100644 index c0b0d596b5..0000000000 --- a/doc/src/examples/tablemodel.qdoc +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example sql/tablemodel - \title Table Model Example - - The Table Model example shows how to use a specialized SQL table model with table - views to edit information in a database. - - \image tablemodel-example.png -*/ diff --git a/doc/src/examples/textures.qdoc b/doc/src/examples/textures.qdoc deleted file mode 100644 index 79e664b305..0000000000 --- a/doc/src/examples/textures.qdoc +++ /dev/null @@ -1,36 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example opengl/textures - \title Textures Example - - The Textures example demonstrates the use of Qt's image classes as textures in - applications that use both OpenGL and Qt to display graphics. - - \image textures-example.png -*/ diff --git a/doc/src/examples/threadedfortuneserver.qdoc b/doc/src/examples/threadedfortuneserver.qdoc deleted file mode 100644 index 6b84be85c8..0000000000 --- a/doc/src/examples/threadedfortuneserver.qdoc +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example network/threadedfortuneserver - \title Threaded Fortune Server Example - - The Threaded Fortune Server example shows how to create a server for a - simple network service that uses threads to handle requests from different - clients. It is intended to be run alongside the Fortune Client example. - - \image threadedfortuneserver-example.png - - The implementation of this example is similar to that of the - \l{network/fortuneserver}{Fortune Server} example, but here we will - implement a subclass of QTcpServer that starts each connection in a - different thread. - - For this we need two classes: FortuneServer, a QTcpServer subclass, and - FortuneThread, which inherits QThread. - - \snippet examples/network/threadedfortuneserver/fortuneserver.h 0 - - FortuneServer inherits QTcpServer and reimplements - QTcpServer::incomingConnection(). We also use it for storing the list of - random fortunes. - - \snippet examples/network/threadedfortuneserver/fortuneserver.cpp 0 - - We use FortuneServer's constructor to simply generate the list of - fortunes. - - \snippet examples/network/threadedfortuneserver/fortuneserver.cpp 1 - - Our implementation of QTcpServer::incomingConnection() creates a - FortuneThread object, passing the incoming socket descriptor and a random - fortune to FortuneThread's constructor. By connecting FortuneThread's - finished() signal to QObject::deleteLater(), we ensure that the thread - gets deleted once it has finished. We can then call QThread::start(), - which starts the thread. - - \snippet examples/network/threadedfortuneserver/fortunethread.h 0 - - Moving on to the FortuneThread class, this is a QThread subclass whose job - is to write the fortune to the connected socket. The class reimplements - QThread::run(), and it has a signal for reporting errors. - - \snippet examples/network/threadedfortuneserver/fortunethread.cpp 0 - - FortuneThread's constructor simply stores the socket descriptor and - fortune text, so that they are available for run() later on. - - \snippet examples/network/threadedfortuneserver/fortunethread.cpp 1 - - The first thing our run() function does is to create a QTcpSocket object - on the stack. What's worth noticing is that we are creating this object - inside the thread, which automatically associates the socket to the - thread's event loop. This ensures that Qt will not try to deliver events - to our socket from the main thread while we are accessing it from - FortuneThread::run(). - - \snippet examples/network/threadedfortuneserver/fortunethread.cpp 2 - - The socket is initialized by calling QTcpSocket::setSocketDescriptor(), - passing our socket descriptor as an argument. We expect this to succeed, - but just to be sure, (although unlikely, the system may run out of - resources,) we catch the return value and report any error. - - \snippet examples/network/threadedfortuneserver/fortunethread.cpp 3 - - As with the \l{network/fortuneserver}{Fortune Server} example, we encode - the fortune into a QByteArray using QDataStream. - - \snippet examples/network/threadedfortuneserver/fortunethread.cpp 4 - - But unlike the previous example, we finish off by calling - QTcpSocket::waitForDisconnected(), which blocks the calling thread until - the socket has disconnected. Because we are running in a separate thread, - the GUI will remain responsive. - - \sa {Fortune Server Example}, {Fortune Client Example}, {Blocking Fortune - Client Example} -*/ diff --git a/doc/src/examples/torrent.qdoc b/doc/src/examples/torrent.qdoc deleted file mode 100644 index 9e9750e842..0000000000 --- a/doc/src/examples/torrent.qdoc +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** GNU Free Documentation License -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms -** and conditions contained in a signed written agreement between you -** and Nokia. -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example network/torrent - \title Torrent Example - - The Torrent example is a functional BitTorrent client that - illustrates how to write a complex TCP/IP application using Qt. - - \image torrent-example.png - - \section1 License Information - - The implementation of the US Secure Hash Algorithm 1 (SHA1) in this example is - derived from the original description in \l{RFC 3174}. - - \legalese - Copyright (C) The Internet Society (2001). All Rights Reserved. - - This document and translations of it may be copied and furnished to - others, and derivative works that comment on or otherwise explain it - or assist in its implementation may be prepared, copied, published - and distributed, in whole or in part, without restriction of any - kind, provided that the above copyright notice and this paragraph are - included on all such copies and derivative works. However, this - document itself may not be modified in any way, such as by removing - the copyright notice or references to the Internet Society or other - Internet organizations, except as needed for the purpose of - developing Internet standards in which case the procedures for - copyrights defined in the Internet Standards process must be - followed, or as required to translate it into languages other than - English. - - The limited permissions granted above are perpetual and will not be - revoked by the Internet Society or its successors or assigns. - - This document and the information contained herein is provided on an - "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING - TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING - BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION - HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF - MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - \endlegalese -*/ diff --git a/doc/src/images/2dpainting-example.png b/doc/src/images/2dpainting-example.png deleted file mode 100644 index 2a77e7d7d5..0000000000 Binary files a/doc/src/images/2dpainting-example.png and /dev/null differ diff --git a/doc/src/images/blockingfortuneclient-example.png b/doc/src/images/blockingfortuneclient-example.png deleted file mode 100644 index cdb7cac0d3..0000000000 Binary files a/doc/src/images/blockingfortuneclient-example.png and /dev/null differ diff --git a/doc/src/images/broadcastreceiver-example.png b/doc/src/images/broadcastreceiver-example.png deleted file mode 100644 index b83789523c..0000000000 Binary files a/doc/src/images/broadcastreceiver-example.png and /dev/null differ diff --git a/doc/src/images/broadcastsender-example.png b/doc/src/images/broadcastsender-example.png deleted file mode 100644 index bf7ccbeb9e..0000000000 Binary files a/doc/src/images/broadcastsender-example.png and /dev/null differ diff --git a/doc/src/images/cachedtable-example.png b/doc/src/images/cachedtable-example.png deleted file mode 100644 index db770dfdf2..0000000000 Binary files a/doc/src/images/cachedtable-example.png and /dev/null differ diff --git a/doc/src/images/cube.png b/doc/src/images/cube.png deleted file mode 100644 index 95dfc984dd..0000000000 Binary files a/doc/src/images/cube.png and /dev/null differ diff --git a/doc/src/images/cube_faces.png b/doc/src/images/cube_faces.png deleted file mode 100644 index 2c7102a94c..0000000000 Binary files a/doc/src/images/cube_faces.png and /dev/null differ diff --git a/doc/src/images/drilldown-example.png b/doc/src/images/drilldown-example.png deleted file mode 100644 index 68353f704a..0000000000 Binary files a/doc/src/images/drilldown-example.png and /dev/null differ diff --git a/doc/src/images/fortuneclient-example.png b/doc/src/images/fortuneclient-example.png deleted file mode 100644 index b34a98736d..0000000000 Binary files a/doc/src/images/fortuneclient-example.png and /dev/null differ diff --git a/doc/src/images/fortuneserver-example.png b/doc/src/images/fortuneserver-example.png deleted file mode 100644 index 73f27d5653..0000000000 Binary files a/doc/src/images/fortuneserver-example.png and /dev/null differ diff --git a/doc/src/images/framebufferobject2-example.png b/doc/src/images/framebufferobject2-example.png deleted file mode 100644 index bafb05a08b..0000000000 Binary files a/doc/src/images/framebufferobject2-example.png and /dev/null differ diff --git a/doc/src/images/googlesuggest-example.png b/doc/src/images/googlesuggest-example.png deleted file mode 100644 index 477d444cbd..0000000000 Binary files a/doc/src/images/googlesuggest-example.png and /dev/null differ diff --git a/doc/src/images/grabber-example.png b/doc/src/images/grabber-example.png deleted file mode 100644 index 6a05b94bec..0000000000 Binary files a/doc/src/images/grabber-example.png and /dev/null differ diff --git a/doc/src/images/hellogl-es-example.png b/doc/src/images/hellogl-es-example.png deleted file mode 100644 index 7e55f09a7a..0000000000 Binary files a/doc/src/images/hellogl-es-example.png and /dev/null differ diff --git a/doc/src/images/hellogl-example.png b/doc/src/images/hellogl-example.png deleted file mode 100644 index ecb3a3a7b0..0000000000 Binary files a/doc/src/images/hellogl-example.png and /dev/null differ diff --git a/doc/src/images/http-example.png b/doc/src/images/http-example.png deleted file mode 100644 index 16b0539b1b..0000000000 Binary files a/doc/src/images/http-example.png and /dev/null differ diff --git a/doc/src/images/loopback-example.png b/doc/src/images/loopback-example.png deleted file mode 100644 index 2b1bd4a0f2..0000000000 Binary files a/doc/src/images/loopback-example.png and /dev/null differ diff --git a/doc/src/images/masterdetail-example.png b/doc/src/images/masterdetail-example.png deleted file mode 100644 index bc282b7a78..0000000000 Binary files a/doc/src/images/masterdetail-example.png and /dev/null differ diff --git a/doc/src/images/multicastreceiver-example.png b/doc/src/images/multicastreceiver-example.png deleted file mode 100644 index 8de11cda63..0000000000 Binary files a/doc/src/images/multicastreceiver-example.png and /dev/null differ diff --git a/doc/src/images/multicastsender-example.png b/doc/src/images/multicastsender-example.png deleted file mode 100644 index a619b047e3..0000000000 Binary files a/doc/src/images/multicastsender-example.png and /dev/null differ diff --git a/doc/src/images/network-chat-example.png b/doc/src/images/network-chat-example.png deleted file mode 100644 index 949bb07d87..0000000000 Binary files a/doc/src/images/network-chat-example.png and /dev/null differ diff --git a/doc/src/images/overpainting-example.png b/doc/src/images/overpainting-example.png deleted file mode 100644 index 0368dcabc8..0000000000 Binary files a/doc/src/images/overpainting-example.png and /dev/null differ diff --git a/doc/src/images/pbuffers-example.png b/doc/src/images/pbuffers-example.png deleted file mode 100644 index c34a6fd02b..0000000000 Binary files a/doc/src/images/pbuffers-example.png and /dev/null differ diff --git a/doc/src/images/pbuffers2-example.png b/doc/src/images/pbuffers2-example.png deleted file mode 100644 index 4a9c7175a3..0000000000 Binary files a/doc/src/images/pbuffers2-example.png and /dev/null differ diff --git a/doc/src/images/querymodel-example.png b/doc/src/images/querymodel-example.png deleted file mode 100644 index 908d500e1f..0000000000 Binary files a/doc/src/images/querymodel-example.png and /dev/null differ diff --git a/doc/src/images/relationaltablemodel-example.png b/doc/src/images/relationaltablemodel-example.png deleted file mode 100644 index 44fc858562..0000000000 Binary files a/doc/src/images/relationaltablemodel-example.png and /dev/null differ diff --git a/doc/src/images/samplebuffers-example.png b/doc/src/images/samplebuffers-example.png deleted file mode 100644 index b751c143b3..0000000000 Binary files a/doc/src/images/samplebuffers-example.png and /dev/null differ diff --git a/doc/src/images/saxbookmarks-example.png b/doc/src/images/saxbookmarks-example.png deleted file mode 100644 index 54d793be56..0000000000 Binary files a/doc/src/images/saxbookmarks-example.png and /dev/null differ diff --git a/doc/src/images/securesocketclient.png b/doc/src/images/securesocketclient.png deleted file mode 100644 index 8736cbc264..0000000000 Binary files a/doc/src/images/securesocketclient.png and /dev/null differ diff --git a/doc/src/images/securesocketclient2.png b/doc/src/images/securesocketclient2.png deleted file mode 100644 index 23db851e61..0000000000 Binary files a/doc/src/images/securesocketclient2.png and /dev/null differ diff --git a/doc/src/images/sql-widget-mapper.png b/doc/src/images/sql-widget-mapper.png deleted file mode 100644 index dfa64aba9e..0000000000 Binary files a/doc/src/images/sql-widget-mapper.png and /dev/null differ diff --git a/doc/src/images/sqlbrowser-demo.png b/doc/src/images/sqlbrowser-demo.png deleted file mode 100644 index 101ec5a0a3..0000000000 Binary files a/doc/src/images/sqlbrowser-demo.png and /dev/null differ diff --git a/doc/src/images/tablemodel-example.png b/doc/src/images/tablemodel-example.png deleted file mode 100644 index 3ae2a8c05c..0000000000 Binary files a/doc/src/images/tablemodel-example.png and /dev/null differ diff --git a/doc/src/images/textures-example.png b/doc/src/images/textures-example.png deleted file mode 100644 index b583ede063..0000000000 Binary files a/doc/src/images/textures-example.png and /dev/null differ diff --git a/doc/src/images/threadedfortuneserver-example.png b/doc/src/images/threadedfortuneserver-example.png deleted file mode 100644 index 57c66a5605..0000000000 Binary files a/doc/src/images/threadedfortuneserver-example.png and /dev/null differ diff --git a/doc/src/images/torrent-example.png b/doc/src/images/torrent-example.png deleted file mode 100644 index 1032716e04..0000000000 Binary files a/doc/src/images/torrent-example.png and /dev/null differ diff --git a/doc/src/images/widgetmapper-sql-mapping-table.png b/doc/src/images/widgetmapper-sql-mapping-table.png deleted file mode 100644 index 98734b34b6..0000000000 Binary files a/doc/src/images/widgetmapper-sql-mapping-table.png and /dev/null differ diff --git a/doc/src/images/widgetmapper-sql-mapping.png b/doc/src/images/widgetmapper-sql-mapping.png deleted file mode 100644 index 88718c6a8b..0000000000 Binary files a/doc/src/images/widgetmapper-sql-mapping.png and /dev/null differ -- cgit v1.2.3