examples-legend.qdoc
32 lines
| 1.8 KiB
| text/plain
|
TextLexer
sauimone
|
r1300 | /*! | ||
\example examples/legend | ||||
\title Legend Example | ||||
\subtitle | ||||
Nico Vertriest
|
r2610 | This example shows how to detach the legend from the chart and how to attach it back. By default the chart | ||
draws the legend inside the same view with the chart. In some cases the user may want to draw the legend to somewhere else. To make this possible the legend can be detached from the chart. Detaching means that the chart doesn't draw the legend or try to change its layout. Detached legend can then be drawn wherever the user wishes, for example, in a different graphics scene. The behavior of the legend can be inspected by running the legend example. | ||||
In the example we use the bar series where we add or remove the bar sets. The legend reflects the changes in series. The legend can be detached or attached back to the chart and its alignment can be modified. | ||||
When the legend is detached, it can be resized and positioned freely. | ||||
Tero Ahola
|
r1380 | |||
Tero Ahola
|
r2034 | \table | ||
\row | ||||
\o \inlineimage examples_legend_detach.png | ||||
\o \inlineimage examples_legend_detach2.png | ||||
\endtable | ||||
Tero Ahola
|
r1380 | |||
Nico Vertriest
|
r2610 | Here we turn the legend visible and set its alignment to the bottom of the chart. | ||
sauimone
|
r1300 | \snippet ../examples/legend/mainwidget.cpp 1 | ||
Nico Vertriest
|
r2610 | |||
This snippet shows how to detach the legend from the chart. After detaching, we turn its background to visible and set a different color to it. This makes it easier to see how the items inside the legend are arranged in detached mode. | ||||
sauimone
|
r1447 | |||
sauimone
|
r1300 | \snippet ../examples/legend/mainwidget.cpp 2 | ||
Nico Vertriest
|
r2610 | Here we attach the legend back to the chart. The background is turned invisible. | ||
sauimone
|
r1300 | \snippet ../examples/legend/mainwidget.cpp 3 | ||
Nico Vertriest
|
r2610 | This shows how we set the detached legend dimensions. After setting the new values, we call update to show changes on screen. | ||
sauimone
|
r1300 | \snippet ../examples/legend/mainwidget.cpp 4 | ||
*/ | ||||