summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@digia.com>2013-12-12 12:43:04 +0200
committerMiikka Heikkinen <miikka.heikkinen@digia.com>2013-12-12 12:51:41 +0200
commitfd5507d50bff7e139865e4d6478910ba8ce36d20 (patch)
tree9ad202612fd5b17ca8b41e19710edd2973719245 /examples
parent9a1ea253d5816a70b2b0e23c952aee0aa26a194f (diff)
Fix customproxy and itemmodel examples docs
Task-number: QTRD-2635 Change-Id: Ibb187e5cf05efc6d7afa6ec03372346d08addc82 Reviewed-by: Tomi Korpipää <tomi.korpipaa@digia.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/customproxy/doc/src/customproxy.qdoc6
-rw-r--r--examples/itemmodel/doc/src/itemmodel.qdoc50
-rw-r--r--examples/itemmodel/main.cpp3
3 files changed, 29 insertions, 30 deletions
diff --git a/examples/customproxy/doc/src/customproxy.qdoc b/examples/customproxy/doc/src/customproxy.qdoc
index be2e2a96..dacedb80 100644
--- a/examples/customproxy/doc/src/customproxy.qdoc
+++ b/examples/customproxy/doc/src/customproxy.qdoc
@@ -37,7 +37,7 @@
of rainfall in that month.
The custom proxy we provide here is similar to item model based proxies provided by Qt
- Data Visualization in that it requires a mapping object to interpret the data.
+ Data Visualization in that it requires a mapping to interpret the data.
Let's take a closer look at the custom classes:
@@ -96,8 +96,8 @@
The primary way to use a \c VariantBarDataMapping object is to give the mappings already at the
constructor, though they can be set later individually or all together with the \c remap() method.
- A signal is emitted if mapping changes. It is basically a simplified version of
- QItemModelBarDataMapping adapted to work with variant lists instead of item models.
+ A signal is emitted if mapping changes. It is basically a simplified version of the mapping
+ functionality of QItemModelBarDataProxy adapted to work with variant lists instead of item models.
\section1 RainfallGraph
diff --git a/examples/itemmodel/doc/src/itemmodel.qdoc b/examples/itemmodel/doc/src/itemmodel.qdoc
index 14cc2637..6812c374 100644
--- a/examples/itemmodel/doc/src/itemmodel.qdoc
+++ b/examples/itemmodel/doc/src/itemmodel.qdoc
@@ -26,9 +26,9 @@
the data being drawn at run-time. The example shows how to:
\list
- \li How to create an application with Q3DBars and widgets
- \li How to use QItemModelBarDataProxy to set data to the graph
- \li How to use a table widget to modify the data in the graph
+ \li Create an application with Q3DBars and widgets
+ \li Use QItemModelBarDataProxy to set data to the graph
+ \li Use a table widget to modify the data in the graph
\endlist
For instructions about how to interact with the graph, see \l{Qt Data Visualization Interacting with Data}{this page}.
@@ -42,7 +42,7 @@
\snippet ../examples/itemmodel/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
+ (Q3DBars, Q3DScatter, and Q3DSurface) inherit QWindow. Any class inheriting QWindow cannot be used
as a widget any other way.
Then we'll create a layout and add the graph and the table widget into it:
@@ -52,18 +52,21 @@
The table widget is going to be used to display the numerical data being inserted into the
graph, and to modify it (See \l {Adding data to the graph} and \l {Interacting with the data}).
- We need to instantiate QItemModelBarDataProxy and give it to the graph:
+ We need to instantiate QItemModelBarDataProxy and a QBar3DSeries for it, and give the series
+ to the graph:
\snippet ../examples/itemmodel/main.cpp 2
Here we tell the proxy to directly map the model's rows and columns into the proxy's rows and
columns instead of defining row and column roles to map for them. Then we give the model from
- the table widget to the proxy. Finally we set the proxy to a series and add it to the graph.
+ the table widget to the proxy. We also create a series instance and set the proxy to it.
+ We customize the series visuals a bit by changing the object mesh to pyramids, and finally
+ add the series to the graph.
Next, let's create another class to handle the data addition and other interaction with the
- graph. Let's call it GraphDataGenerator (See \l {Setting up the graph} and
- \l {Adding data to the graph} for details) and connect some signals between Q3DBars,
- GraphDataGenerator, and QTableWidget (See \l {Interacting with the data} for a closer look):
+ graph. Let's call it \c GraphDataGenerator (See \l {Setting up the graph} and
+ \l {Adding data to the graph} for details) and connect some signals between QBar3DSeries,
+ \c GraphDataGenerator, and QTableWidget (See \l {Interacting with the data} for a closer look):
\snippet ../examples/itemmodel/main.cpp 3
@@ -73,7 +76,7 @@
\section1 Setting up the graph
- Let's set up the visual attributes for the graph in the constructor of GraphDataGenerator:
+ Let's set up the visual attributes for the graph in the constructor of \c GraphDataGenerator:
\snippet ../examples/itemmodel/main.cpp 5
\snippet ../examples/itemmodel/main.cpp 6
@@ -84,16 +87,17 @@
easily try how changing it affects the graph. The second line sets bar spacings to 0.2, which
means there will be a gap of 20% of the bar's thickness between the bars in both directions.
- Then, we set the bar type to flat pyramids, overriding the default bar type.
We want to be able to select rows of data for a closer inspection, so we set the selection mode
to slice row. This means that whenever we select a bar in the graph, the whole row will be
displayed separately.
+ We don't want to use the default colors, so we set one of the predefined themes as the active theme.
+
Next line sets the font to \c Impact. If your system doesn't have it, it will be replaced by
the system default.
- And finally, we set theme to \c Digia and camera position to \c {Preset Front}. Now the initial
- graph settings are done.
+ And finally, we set the camera position to one of the predefined camera positions.
+ Now the initial graph settings are done.
\note You do not need to set any of these in case you're happy with the defaults. You can
easily try them by commenting out the contents of the constructor.
@@ -117,8 +121,8 @@
The main thing \c start() does is set up the data model. It also activates a timer for getting
the accurate dimensions of the table widget after it's been filled with data. The reason we
do this is that the widget doesn't know its final visual domensions until all the data has been
- inserted to it and it has been shown. The whole data timer implementation is not vital for the
- application, so we won't take a closer look at it. It's just there to make the table look better.
+ inserted to it and it has been shown. The data timer usage is not vital for the
+ application, so we won't take a closer look at it. It's just there to make QTableWidget look better.
In \c setupModel() we first introduce the row and column labels, and the actual data:
@@ -128,10 +132,6 @@
\snippet ../examples/itemmodel/main.cpp 10
- The other lines there are pretty self-explanatory except for the one with the segment count.
- We're setting it to five as we want the value axis (the Y-axis) to show more values than just
- the lowest and the highest.
-
Next we will set up the table widget:
\snippet ../examples/itemmodel/main.cpp 11
@@ -149,8 +149,8 @@
We created QItemModelBarDataProxy instance, and gave the proxy the model of the table widget
we just created. The proxy maps the rows and the columns in the model of the table widget into
- rows and columns for itself directly, as we set the useModelCategories property to true, and
- the graph gets the data to be displayed via the series that owns the proxy.
+ rows and columns for itself directly, as we set the QItemModelBarDataProxy::useModelCategories
+ property to true, and the graph gets the data to be displayed via the series that owns the proxy.
\section1 Interacting with the data
@@ -160,19 +160,19 @@
Now we'll find out what these were for.
- The first one connects a signal from Q3DBars to the GraphDataGenerator. Signal
- Q3DBars::selectedBarChanged() is emitted when a bar is selected from the graph. We connect
+ The first one connects a signal from Q3DBars to the \c GraphDataGenerator. Signal
+ QBar3DSeries::selectedBarChanged() is emitted when a bar is selected from the series. We connect
that to a method in the data generator that selects the same data item in the table widget:
\snippet ../examples/itemmodel/main.cpp 13
The second connection does the opposite; it connects a signal from the table widget to a
- method in the data generator. The method then selects the corresponding bar in the graph:
+ method in the data generator. The method then selects the corresponding bar in the series:
\snippet ../examples/itemmodel/main.cpp 14
You can even select an item in the widget and change the value of it, and the new value is
- updated to the graph. This is handled again by the active proxy with mapping between the data
+ updated to the graph. This is handled again by the proxy with mapping between the data
in the table widget and itself.
\image itemmodel-example.png
diff --git a/examples/itemmodel/main.cpp b/examples/itemmodel/main.cpp
index 533264d8..46aa8bb8 100644
--- a/examples/itemmodel/main.cpp
+++ b/examples/itemmodel/main.cpp
@@ -169,7 +169,6 @@ void GraphDataGenerator::setupModel()
m_graph->rowAxis()->setTitle("Week of year");
m_graph->columnAxis()->setTitle("Day of week");
m_graph->valueAxis()->setTitle("Hours spent on the Internet");
- m_graph->valueAxis()->setSegmentCount(5);
m_graph->valueAxis()->setLabelFormat("%.1f h");
//! [10]
@@ -262,7 +261,7 @@ int main(int argc, char **argv)
//! [2]
// Since we are dealing with QTableWidget, the model will already have data sorted properly
- // in rows and columns, so we simply set useModelCategories property to true to utilize this.
+ // into rows and columns, so we simply set useModelCategories property to true to utilize this.
QItemModelBarDataProxy *proxy = new QItemModelBarDataProxy(tableWidget->model());
proxy->setUseModelCategories(true);
QBar3DSeries *series = new QBar3DSeries(proxy);