diff options
author | Marek Rosa <marek.rosa@digia.com> | 2012-04-05 15:37:15 +0300 |
---|---|---|
committer | Marek Rosa <marek.rosa@digia.com> | 2012-04-06 13:11:22 +0300 |
commit | f71e8606604408067c6d80dadbba4d79cd27bf73 (patch) | |
tree | a846afaa88ea6f2b3919039c2d03472d77375619 /demos | |
parent | 284eb2f28726e098253f5099ba88f3f8ed0bfb0d (diff) |
modeldata example documented with explanations.
Some more fixes to the docs.
Diffstat (limited to 'demos')
-rw-r--r-- | demos/gdpbarchart/widget.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/demos/gdpbarchart/widget.cpp b/demos/gdpbarchart/widget.cpp index caef645a..daf3abee 100644 --- a/demos/gdpbarchart/widget.cpp +++ b/demos/gdpbarchart/widget.cpp @@ -25,6 +25,7 @@ #include <QChartAxis> #include <QBarSet> #include <QBarSeries> +#include <QLegend> #include <QGridLayout> #include <QPushButton> @@ -60,7 +61,7 @@ Widget::Widget(QWidget *parent) QPushButton* refreshButton = new QPushButton(tr("Refresh")); connect(refreshButton, SIGNAL(clicked()), this, SLOT(refreshChart())); - QPushButton* printButton = new QPushButton(tr("Print chart")); + QPushButton* printButton = new QPushButton(tr("Print to pdf")); connect(printButton, SIGNAL(clicked()), this, SLOT(printChart())); QVBoxLayout* rightPanelLayout = new QVBoxLayout; @@ -75,6 +76,7 @@ Widget::Widget(QWidget *parent) QChart *chart = new QChart(); chart->setTitle("GDP by country"); + chart->legend()->setVisible(true); // main layout chartView = new QChartView(chart); @@ -101,13 +103,6 @@ Widget::Widget(QWidget *parent) while (query.next()) { countrieslist->addItem(query.value(0).toString()); } - - // hide axis X labels - //QChartAxis* axis = chartArea->axisX(); -// axis-> - // axis->setLabelsVisible(false); - // newAxis.setLabelsOrientation(QChartAxis::LabelsOrientationSlide); - } Widget::~Widget() @@ -136,7 +131,7 @@ void Widget::refreshChart() QList<QListWidgetItem*> selectedYearsItems = yearslist->selectedItems(); for (int i = 0; i < selectedYearsItems.size(); i++) selectedYearsInts.append(selectedYearsItems[i]->text().toInt()); - qSort(selectedYearsInts.begin(), selectedYearsInts.end(), qGreater<int>()); + qSort(selectedYearsInts.begin(), selectedYearsInts.end()); if (barChartRadioButton->isChecked()) { @@ -162,7 +157,7 @@ void Widget::refreshChart() for (int i = 0; i < selectedYearsInts.size(); i++) { query.exec("SELECT country,gdpvalue FROM gdp2 where year=" + QString("%1").arg(selectedYearsInts[i]) + " AND " + countriesQuery); - QBarSet* barSet = new QBarSet("Barset" + QString::number(i)); + QBarSet* barSet = new QBarSet(QString::number(selectedYearsInts[i])); // while (query.next()) { // qDebug() << query.value(0).toString() << " : " << query.value(1).toString(); @@ -210,6 +205,7 @@ void Widget::refreshChart() query.first(); QScatterSeries* series = new QScatterSeries; + series->setName(selectedCountriesStrings[i]); // the data for some of the coutries for some years might be missing. for (int k = 0; k < selectedYearsInts.size(); k++) { |