In my QT / QML application the following C++ class works perfectly and draws a simple polygon formed by six elements in a QML view.
Now, I want an interpolated polygon; in other words, I don't want a series of lines with edges but a continuous line without any edge. How can I transform my class in order to do that?
Important: I don't use a chart but a normal graph figure; due to this reason, I think that the QTSpline series I already found in some forum are not the solution. But I am obviously opened to any way.
Edit: in order to explain better what I need, I attach an image at the end of this post.
#include "mydiagram.h"
#include <QPainter>
#include <string>
#include <iostream>
#include <QtCharts>
#include <QSplineSeries>
#include <QPoint>
using namespace QtCharts;
MyDiagram::MyDiagram(QQuickItem *parent): QQuickPaintedItem(parent)
{
}
void MyDiagram::paint(QPainter *painterMyDiagram) {
QBrush myBrush(QColor("transparent"));
QPen myPen(QColor("grey"), 3, Qt::DashDotLine);
painterMyDiagram->setBrush(myBrush);
painterMyDiagram->setPen(myPen);
painterMyDiagram->setRenderHint(QPainter::Antialiasing);
static const QPointF points[6] = {
QPointF(10.0, 80.0),
QPointF(20.0, 10.0),
QPointF(200.0, 30.0),
QPointF(300.0, 160.0),
QPointF(250.0, 250.0),
QPointF(10.0, 80.0)
};
painterMyDiagram->drawPolyline(points, 6);
}