##// END OF EJS Templates
Fix QNX build issue...
Fix QNX build issue Use qmath and cmath methods instead of math.h methods. Change-Id: I7c853f2e1218a1d3cde15a089192c24a6b0b1395 Reviewed-by: Miikka Heikkinen <miikka.heikkinen@theqtcompany.com>

File last commit:

r2740:377e4516d036
r2775:143be951b1fe
Show More
main.cpp
90 lines | 2.5 KiB | text/x-c | CppLexer
Marek Rosa
Multiaxis support...
r2093 /****************************************************************************
**
Titta Heikkala
Update copyright year...
r2688 ** Copyright (C) 2014 Digia Plc
Marek Rosa
Multiaxis support...
r2093 ** All rights reserved.
Titta Heikkala
Updated license headers...
r2740 ** For any questions to Digia, please use contact form at http://qt.io
Marek Rosa
Multiaxis support...
r2093 **
Titta Heikkala
Updated license headers...
r2740 ** This file is part of the Qt Charts module.
Marek Rosa
Multiaxis support...
r2093 **
Titta Heikkala
Updated license headers...
r2740 ** Licensees holding valid commercial license for Qt may use this file in
** accordance with the Qt License Agreement provided with the Software
** or, alternatively, in accordance with the terms contained in a written
** agreement between you and Digia.
Marek Rosa
Multiaxis support...
r2093 **
** If you have questions regarding the use of this file, please use
Titta Heikkala
Updated license headers...
r2740 ** contact form at http://qt.io
Marek Rosa
Multiaxis support...
r2093 **
****************************************************************************/
Titta Heikkala
Fix include syntax...
r2714 #include <QtWidgets/QApplication>
#include <QtWidgets/QMainWindow>
#include <QtCharts/QChartView>
#include <QtCharts/QLineSeries>
#include <QtCharts/QSplineSeries>
#include <QtCharts/QValueAxis>
#include <QtCharts/QCategoryAxis>
Marek Rosa
Multiaxis support...
r2093
Titta Heikkala
Qt Charts project file structure change...
r2712 QT_CHARTS_USE_NAMESPACE
Marek Rosa
Multiaxis support...
r2093
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
//![1]
Titta Heikkala
Qt Charts project file structure change...
r2712 QChart *chart = new QChart();
Marek Rosa
logvalueaxis and multiaxis examples documented
r2374 chart->legend()->hide();
chart->setTitle("Multiaxis chart example");
//![1]
//![2]
Marek Rosa
Logvalueaxis and multiaxis examples updated
r2371 QValueAxis *axisX = new QValueAxis;
axisX->setTickCount(10);
Marek Rosa
logvalueaxis and multiaxis examples documented
r2374 chart->addAxis(axisX, Qt::AlignBottom);
//![2]
Marek Rosa
Logvalueaxis and multiaxis examples updated
r2371
Marek Rosa
logvalueaxis and multiaxis examples documented
r2374 //![3]
Marek Rosa
Logvalueaxis and multiaxis examples updated
r2371 QSplineSeries *series = new QSplineSeries;
*series << QPointF(1, 5) << QPointF(3.5, 18) << QPointF(4.8, 7.5) << QPointF(10, 2.5);
chart->addSeries(series);
QValueAxis *axisY = new QValueAxis;
axisY->setLinePenColor(series->pen().color());
chart->addAxis(axisY, Qt::AlignLeft);
series->attachAxis(axisX);
series->attachAxis(axisY);
Marek Rosa
logvalueaxis and multiaxis examples documented
r2374 //![3]
Marek Rosa
Logvalueaxis and multiaxis examples updated
r2371
Marek Rosa
logvalueaxis and multiaxis examples documented
r2374 //![4]
Marek Rosa
Logvalueaxis and multiaxis examples updated
r2371 series = new QSplineSeries;
*series << QPointF(1, 0.5) << QPointF(1.5, 4.5) << QPointF(2.4, 2.5) << QPointF(4.3, 12.5)
<< QPointF(5.2, 3.5) << QPointF(7.4, 16.5) << QPointF(8.3, 7.5) << QPointF(10, 17);
chart->addSeries(series);
QCategoryAxis *axisY3 = new QCategoryAxis;
axisY3->append("Low", 5);
axisY3->append("Medium", 12);
axisY3->append("High", 17);
axisY3->setLinePenColor(series->pen().color());
axisY3->setGridLinePen((series->pen()));
chart->addAxis(axisY3, Qt::AlignRight);
series->attachAxis(axisX);
series->attachAxis(axisY3);
Marek Rosa
Multiaxis support...
r2093 //![4]
Marek Rosa
logvalueaxis and multiaxis examples documented
r2374
//![5]
Jani Honkonen
more coding style fixes for examples...
r2102 QChartView *chartView = new QChartView(chart);
Marek Rosa
Multiaxis support...
r2093 chartView->setRenderHint(QPainter::Antialiasing);
//![5]
Marek Rosa
logvalueaxis and multiaxis examples documented
r2374
//![6]
Marek Rosa
Multiaxis support...
r2093 QMainWindow window;
window.setCentralWidget(chartView);
window.resize(800, 600);
window.show();
Marek Rosa
logvalueaxis and multiaxis examples documented
r2374 //![6]
Marek Rosa
Multiaxis support...
r2093
return a.exec();
}
Marek Rosa
Logvalueaxis and multiaxis examples updated
r2371