diff options
author | Liang Qi <liang.qi@qt.io> | 2017-08-15 12:22:16 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2017-08-15 13:06:48 +0200 |
commit | 0168fe1f95d56850734447b118cdcf1847da1c51 (patch) | |
tree | 55763c374af875fc7228dc8d1f3771ef74c083cb /examples/charts/chartthemes | |
parent | ac79bf382a9fabed940b8f9be20feeb58ac205aa (diff) | |
parent | 1f47b1a7ae58702dccc57a9ccbaa905441f4fecb (diff) |
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
.qmake.conf
examples/charts/dynamicspline/chart.cpp
examples/charts/piechartdrilldown/main.cpp
Change-Id: I839e97bf377c7823f2f464c097656d58f279ed77
Diffstat (limited to 'examples/charts/chartthemes')
-rw-r--r-- | examples/charts/chartthemes/themewidget.cpp | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/examples/charts/chartthemes/themewidget.cpp b/examples/charts/chartthemes/themewidget.cpp index 6f408c75..f1f28af4 100644 --- a/examples/charts/chartthemes/themewidget.cpp +++ b/examples/charts/chartthemes/themewidget.cpp @@ -94,7 +94,8 @@ ThemeWidget::ThemeWidget(QWidget *parent) : m_charts << chartView; chartView = new QChartView(createPieChart()); - chartView->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); // funny things happen if the pie slice labels no not fit the screen... + // Funny things happen if the pie slice labels do not fit the screen, so we ignore size policy + chartView->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored); baseLayout->addWidget(chartView, 2, 0); m_charts << chartView; @@ -119,10 +120,16 @@ ThemeWidget::~ThemeWidget() void ThemeWidget::connectSignals() { - connect(m_themeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI())); - connect(m_antialiasCheckBox, SIGNAL(toggled(bool)), this, SLOT(updateUI())); - connect(m_animatedComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI())); - connect(m_legendComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateUI())); + connect(m_themeComboBox, + static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), + this, &ThemeWidget::updateUI); + connect(m_antialiasCheckBox, &QCheckBox::toggled, this, &ThemeWidget::updateUI); + connect(m_animatedComboBox, + static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), + this, &ThemeWidget::updateUI); + connect(m_legendComboBox, + static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), + this, &ThemeWidget::updateUI); } DataTable ThemeWidget::generateRandomData(int listCount, int valueMax, int valueCount) const @@ -223,7 +230,7 @@ QChart *ThemeWidget::createBarChart(int valueCount) const QStackedBarSeries *series = new QStackedBarSeries(chart); for (int i(0); i < m_dataTable.count(); i++) { QBarSet *set = new QBarSet("Bar set " + QString::number(i)); - foreach (Data data, m_dataTable[i]) + for (const Data &data : m_dataTable[i]) *set << data.first.y(); series->append(set); } @@ -240,9 +247,9 @@ QChart *ThemeWidget::createLineChart() const QString name("Series "); int nameIndex = 0; - foreach (DataList list, m_dataTable) { + for (const DataList &list : m_dataTable) { QLineSeries *series = new QLineSeries(chart); - foreach (Data data, list) + for (const Data &data : list) series->append(data.first); series->setName(name + QString::number(nameIndex)); nameIndex++; @@ -261,7 +268,7 @@ QChart *ThemeWidget::createPieChart() const qreal pieSize = 1.0 / m_dataTable.count(); for (int i = 0; i < m_dataTable.count(); i++) { QPieSeries *series = new QPieSeries(chart); - foreach (Data data, m_dataTable[i]) { + for (const Data &data : m_dataTable[i]) { QPieSlice *slice = series->append(data.second, data.first.y()); if (data == m_dataTable[i].first()) { slice->setLabelVisible(); @@ -285,9 +292,9 @@ QChart *ThemeWidget::createSplineChart() const chart->setTitle("Spline chart"); QString name("Series "); int nameIndex = 0; - foreach (DataList list, m_dataTable) { + for (const DataList &list : m_dataTable) { QSplineSeries *series = new QSplineSeries(chart); - foreach (Data data, list) + for (const Data &data : list) series->append(data.first); series->setName(name + QString::number(nameIndex)); nameIndex++; @@ -304,9 +311,9 @@ QChart *ThemeWidget::createScatterChart() const chart->setTitle("Scatter chart"); QString name("Series "); int nameIndex = 0; - foreach (DataList list, m_dataTable) { + for (const DataList &list : m_dataTable) { QScatterSeries *series = new QScatterSeries(chart); - foreach (Data data, list) + for (const Data &data : list) series->append(data.first); series->setName(name + QString::number(nameIndex)); nameIndex++; @@ -318,10 +325,12 @@ QChart *ThemeWidget::createScatterChart() const void ThemeWidget::updateUI() { - QChart::ChartTheme theme = (QChart::ChartTheme) m_themeComboBox->itemData(m_themeComboBox->currentIndex()).toInt(); + QChart::ChartTheme theme = static_cast<QChart::ChartTheme>( + m_themeComboBox->itemData(m_themeComboBox->currentIndex()).toInt()); + const auto charts = m_charts; if (m_charts.at(0)->chart()->theme() != theme) { - foreach (QChartView *chartView, m_charts) + for (QChartView *chartView : charts) chartView->chart()->setTheme(theme); QPalette pal = window()->palette(); @@ -354,22 +363,23 @@ void ThemeWidget::updateUI() } bool checked = m_antialiasCheckBox->isChecked(); - foreach (QChartView *chart, m_charts) + for (QChartView *chart : charts) chart->setRenderHint(QPainter::Antialiasing, checked); - QChart::AnimationOptions options(m_animatedComboBox->itemData(m_animatedComboBox->currentIndex()).toInt()); + QChart::AnimationOptions options( + m_animatedComboBox->itemData(m_animatedComboBox->currentIndex()).toInt()); if (m_charts.at(0)->chart()->animationOptions() != options) { - foreach (QChartView *chartView, m_charts) + for (QChartView *chartView : charts) chartView->chart()->setAnimationOptions(options); } Qt::Alignment alignment(m_legendComboBox->itemData(m_legendComboBox->currentIndex()).toInt()); if (!alignment) { - foreach (QChartView *chartView, m_charts) + for (QChartView *chartView : charts) chartView->chart()->legend()->hide(); } else { - foreach (QChartView *chartView, m_charts) { + for (QChartView *chartView : charts) { chartView->chart()->legend()->setAlignment(alignment); chartView->chart()->legend()->show(); } |