diff options
author | Tomi Korpipää <tomi.korpipaa@digia.com> | 2013-10-08 13:59:47 +0300 |
---|---|---|
committer | Tomi Korpipää <tomi.korpipaa@digia.com> | 2013-10-08 14:01:33 +0300 |
commit | d93981d49d0c4ac7dbc98e089387b4e483b19297 (patch) | |
tree | 6846057392c79cbda1b6e35787c1affcde682f88 /examples/scatter/doc/src | |
parent | 84ec19e6e8ebc563b577f78b9f58cf6fa907271b (diff) |
Scatter example documentation
Task-number: QTRD-2400
Change-Id: Ic6e67298c493ac2b92ad03c6f3746a5481ae1e97
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@digia.com>
Diffstat (limited to 'examples/scatter/doc/src')
-rw-r--r-- | examples/scatter/doc/src/scatter.qdoc | 127 |
1 files changed, 125 insertions, 2 deletions
diff --git a/examples/scatter/doc/src/scatter.qdoc b/examples/scatter/doc/src/scatter.qdoc index 5053d77a..90410bc6 100644 --- a/examples/scatter/doc/src/scatter.qdoc +++ b/examples/scatter/doc/src/scatter.qdoc @@ -23,9 +23,132 @@ \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. + 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 - TODO + \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 */ |