diff options
Diffstat (limited to 'examples/scatter/doc/src/scatter.qdoc')
-rw-r--r-- | examples/scatter/doc/src/scatter.qdoc | 154 |
1 files changed, 154 insertions, 0 deletions
diff --git a/examples/scatter/doc/src/scatter.qdoc b/examples/scatter/doc/src/scatter.qdoc new file mode 100644 index 00000000..90410bc6 --- /dev/null +++ b/examples/scatter/doc/src/scatter.qdoc @@ -0,0 +1,154 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the QtDataVisualization module. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ + +/*! + \example scatter + \title Scatter Example + \ingroup qtdatavisualization_examples + \brief Using Q3DScatter in a widget application. + + The scatter example shows how to make a simple 3D scatter graph using Q3DScatter and + combining the use of widgets for adjusting several adjustable qualities. The example shows + how to: + + \list + \li Create an application with Q3DScatter and some widgets + \li Use QScatterDataProxy to set data to the graph + \li Adjust some graph properties using widget controls + \endlist + + \image scatter-example.png + + \section1 Creating the application + + First, in main.cpp, we create a QApplication, instantiate Q3DScatter and a window container + for it: + + \snippet ../examples/scatter/main.cpp 0 + + The call to QWidget::createWindowContainer is required, as all data visualization types + (Q3DBars, Q3DScatter, Q3DSurface) inherit QWindow. Any class inheriting QWindow cannot be used + as a widget any other way. + + Then we'll create horizontal and vertical layouts. We'll add the graph and the vertical + layout into the horizontal one: + + \snippet ../examples/scatter/main.cpp 1 + + We're not using the vertical layout for anything yet, but we'll get back to it in + \l {Using widgets to control the graph} + + Next, let's create another class to handle the data addition and other interaction with the + graph. Let's call it ScatterDataModifier (See \l {Setting up the graph} and + \l {Adding data to the graph} for details): + + \snippet ../examples/scatter/main.cpp 2 + + The application main is done and we can show the graph and start the event loop: + + \snippet ../examples/scatter/main.cpp 3 + + \section1 Setting up the graph + + Let's set up some visual qualities for the graph in the constructor of the ScatterDataModifier + class we instantiated in the application main: + + \snippet ../examples/scatter/scatterdatamodifier.cpp 0 + + None of these are required, but are used to override graph defaults. You can try how it looks + with the preset defaults by commenting the block above out. + + Then we'll set axes for the graph: + + \snippet ../examples/scatter/scatterdatamodifier.cpp 1 + + And finally we create a QScatterDataProxy, set a label format for it and set it as the active + proxy for the graph: + + \snippet ../examples/scatter/scatterdatamodifier.cpp 2 + + That concludes setting up the graph. + + \section1 Adding data to the graph + + In application main, we called \c {modifier->start()} after constructing all the necessary + objects. This is how it looks like: + + \snippet ../examples/scatter/scatterdatamodifier.cpp 3 + + There is nothing in it except a call to another method. There is actually no need for a + separate \c start() method, but we keep it here in case we want to add some more functionality + in it that can be done only after all construction in application main is done. + + The actual data addition is done in \c addData() method. First we configure the axes we created + in constructor: + + \snippet ../examples/scatter/scatterdatamodifier.cpp 4 + + This could have been done in the ScatterDataModifier's constructor, but we added it here + to keep the constructor simpler and the axes configuration near the data. + + Next we create a data array: + + \snippet ../examples/scatter/scatterdatamodifier.cpp 5 + + And populate it: + + \snippet ../examples/scatter/scatterdatamodifier.cpp 6 + + Finally we tell the proxy to start using the data we gave it: + + \snippet ../examples/scatter/scatterdatamodifier.cpp 7 + + Now our graph has the data and is ready to be used. There isn't much interaction yet, though, + so let's continue by adding some widgets to play with. + + \section1 Using widgets to control the graph + + First, back in the application main, we'll create some widgets: + + \snippet ../examples/scatter/main.cpp 4 + + And add them to the vertical layout we created earlier: + + \snippet ../examples/scatter/main.cpp 5 + + Now, let's connect them to methods in ScatterDataModifier: + + \snippet ../examples/scatter/main.cpp 6 + + Here are the methods in ScatterDataModifier the signals were connected to: + + \snippet ../examples/scatter/scatterdatamodifier.cpp 8 + + And so we have an application in which we can control: + + \list + \li Label style + \li Camera preset + \li Background visibility + \li Grid visibility + \li Dot shading smoothness + \li Dot style + \li Theme + \li Shadow quality + \li Font + \endlist + + \section1 Example contents +*/ |