diff --git a/example/piechart/customslice.cpp b/example/piechart/customslice.cpp deleted file mode 100644 index 4132a55..0000000 --- a/example/piechart/customslice.cpp +++ /dev/null @@ -1,22 +0,0 @@ -#include "customslice.h" - -CustomSlice::CustomSlice(qreal value, QObject* parent) - :QPieSlice(parent) -{ - setValue(value); - setLabelVisible(true); - setExploded(true); - connect(this, SIGNAL(changed()), this, SLOT(updateLabel())); - connect(this, SIGNAL(hoverEnter()), this, SLOT(toggleExploded())); - connect(this, SIGNAL(hoverLeave()), this, SLOT(toggleExploded())); -} - -void CustomSlice::updateLabel() -{ - setLabel(QString::number(this->percentage()*100) + "%"); -} - -void CustomSlice::toggleExploded() -{ - setExploded(!isExploded()); -} diff --git a/example/piechart/customslice.h b/example/piechart/customslice.h deleted file mode 100644 index 3c6ccf4..0000000 --- a/example/piechart/customslice.h +++ /dev/null @@ -1,15 +0,0 @@ -#include - -QTCOMMERCIALCHART_USE_NAMESPACE - -class CustomSlice : public QPieSlice -{ - Q_OBJECT - -public: - CustomSlice(qreal value, QObject* parent = 0); - -public Q_SLOTS: - void updateLabel(); - void toggleExploded(); -}; diff --git a/example/piechart/main.cpp b/example/piechart/main.cpp index ebb9058..d33c198 100644 --- a/example/piechart/main.cpp +++ b/example/piechart/main.cpp @@ -4,7 +4,6 @@ #include #include #include -#include "customslice.h" QTCOMMERCIALCHART_USE_NAMESPACE @@ -14,23 +13,17 @@ int main(int argc, char *argv[]) QMainWindow window; + QChartView* chartView = new QChartView(&window); + + //! [1] QPieSeries *series = new QPieSeries(); - series->add(5, "Slice 1"); + series->add(1, "Slice 1"); series->add(2, "Slice 2"); series->add(3, "Slice 3"); series->add(4, "Slice 4"); series->add(5, "Slice 5"); - series->add(6, "Slice 6"); - series->add(7, "Slice 7"); - series->add(new CustomSlice(8)); - series->enableClickExplodes(true); - series->enableHoverHighlight(true); - - QChartView* chartView = new QChartView(&window); - chartView->setRenderHint(QPainter::Antialiasing); - chartView->setChartTheme(QChart::ChartThemeIcy); - chartView->setChartTitle("Simple piechart"); chartView->addSeries(series); + //! [1] window.setCentralWidget(chartView); window.resize(600, 600); diff --git a/example/piechart/piechart.pro b/example/piechart/piechart.pro index 85c2b35..a8bed67 100644 --- a/example/piechart/piechart.pro +++ b/example/piechart/piechart.pro @@ -2,7 +2,7 @@ error( "Couldn't find the example.pri file!" ) } TARGET = piechart -SOURCES += main.cpp customslice.cpp -HEADERS += customslice.h +SOURCES += main.cpp +HEADERS += diff --git a/src/piechart/qpieseries.cpp b/src/piechart/qpieseries.cpp index 3be2d29..552ede4 100644 --- a/src/piechart/qpieseries.cpp +++ b/src/piechart/qpieseries.cpp @@ -113,6 +113,9 @@ bool QPieSeries::ChangeSet::isEmpty() const By default the pie is defined as full but it can be a partial pie. This can be done by setting a starting angle and angle span to the series. + + Example on how to create a chart with pie series: + \snippet ../example/piechart/main.cpp 1 */ /*!