@@ -5,6 +5,7 int main(int argc, char *argv[]) | |||||
5 | { |
|
5 | { | |
6 | QApplication a(argc, argv); |
|
6 | QApplication a(argc, argv); | |
7 | MainWindow w; |
|
7 | MainWindow w; | |
|
8 | w.resize(400, 300); | |||
8 | w.show(); |
|
9 | w.show(); | |
9 |
|
10 | |||
10 | return a.exec(); |
|
11 | return a.exec(); |
@@ -8,17 +8,14 QTCOMMERCIALCHART_USE_NAMESPACE | |||||
8 | MainWindow::MainWindow(QWidget *parent) |
|
8 | MainWindow::MainWindow(QWidget *parent) | |
9 | : QMainWindow(parent) |
|
9 | : QMainWindow(parent) | |
10 | { |
|
10 | { | |
11 | resize(400, 300); |
|
|||
12 | setWindowFlags(Qt::FramelessWindowHint); |
|
|||
13 |
|
||||
14 | QChartView *chartView = new QChartView(this); |
|
11 | QChartView *chartView = new QChartView(this); | |
15 | chartView->setChartTitle("Click to play with points"); |
|
12 | chartView->setChartTitle("Click to play with points"); | |
16 | chartView->setRenderHint(QPainter::Antialiasing); |
|
13 | chartView->setRenderHint(QPainter::Antialiasing); | |
17 | setCentralWidget(chartView); |
|
14 | setCentralWidget(chartView); | |
18 |
|
15 | |||
19 | m_scatter = new QScatterSeries(); |
|
16 | m_scatter = new QScatterSeries(); | |
20 |
for(qreal x(0.5); x <= |
|
17 | for(qreal x(0.5); x <= 4.0; x += 0.5) { | |
21 |
for(qreal y(0.5); y <= |
|
18 | for(qreal y(0.5); y <= 4.0; y += 0.5) { | |
22 | *m_scatter << QPointF(x, y); |
|
19 | *m_scatter << QPointF(x, y); | |
23 | } |
|
20 | } | |
24 | } |
|
21 | } |
@@ -6,6 +6,12 | |||||
6 |
|
6 | |||
7 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
7 | QTCOMMERCIALCHART_BEGIN_NAMESPACE | |
8 |
|
8 | |||
|
9 | ||||
|
10 | ||||
|
11 | ||||
|
12 | ||||
|
13 | ||||
|
14 | ||||
9 | ScatterChartItem::ScatterChartItem(QScatterSeries *series, QGraphicsItem *parent) : |
|
15 | ScatterChartItem::ScatterChartItem(QScatterSeries *series, QGraphicsItem *parent) : | |
10 | XYChartItem(series,parent), |
|
16 | XYChartItem(series,parent), | |
11 | m_series(series), |
|
17 | m_series(series), | |
@@ -113,7 +119,8 void ScatterChartItem::setGeometry(QVector<QPointF>& points) | |||||
113 | for(int i=0; i< points.size();i++) { |
|
119 | for(int i=0; i< points.size();i++) { | |
114 | QGraphicsItem* item = items.at(i); |
|
120 | QGraphicsItem* item = items.at(i); | |
115 | const QPointF& point = points.at(i); |
|
121 | const QPointF& point = points.at(i); | |
116 | item->setPos(point.x()-1,point.y()-1); |
|
122 | const QRectF& rect = item->boundingRect(); | |
|
123 | item->setPos(point.x()-rect.width()/2,point.y()-rect.height()/2); | |||
117 | if(!clipRect().contains(point)) { |
|
124 | if(!clipRect().contains(point)) { | |
118 | item->setVisible(false); |
|
125 | item->setVisible(false); | |
119 | } |
|
126 | } |
@@ -3,7 +3,7 | |||||
3 |
|
3 | |||
4 | #include "qchartglobal.h" |
|
4 | #include "qchartglobal.h" | |
5 | #include "xychartitem_p.h" |
|
5 | #include "xychartitem_p.h" | |
6 | #include <QGraphicsItem> |
|
6 | #include <QGraphicsEllipseItem> | |
7 | #include <QPen> |
|
7 | #include <QPen> | |
8 |
|
8 | |||
9 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
|
9 | QTCOMMERCIALCHART_BEGIN_NAMESPACE |
General Comments 0
You need to be logged in to leave comments.
Login now