title: Add c++ QAbstractSeries to QML chartview
body: <p>I am having a hard time to work with c++ in combination with qml and QtCharts/Chartview. If there is any advice at any point, I am happy to here it!</p>
  
  <p>Question: I would like to add a QLineSeries defined in c++ to Chartview in QML.
  My main problem is to connect my c++class <code>setLineSeries()</code> to my qml <code>Chartview{}</code>Object.</p>
  
  <p>I tried to do this by creating a new series with </p>
  
  <pre><code>var series = diabBig.createSeries(ChartView.SeriesTypeLine, "Test", diabBig.axisX(lineseries), diabBig.axisY(lineseries));
  </code></pre>
  
  <p>and than change this series object to my c++QLineSeriesObject </p>
  
  <pre><code>series = diabetesView.setLineSeries();
  </code></pre>
  
  <p>Is it even possible to do it like this or how would be the intended way to use my QLineSeries(QAbstractSeries) from c++?</p>
  
  <p>EDIT: "If it's not possible what I am trying to do, this would be an acceptable answer even though it wouldn't be the one I wish to read!" </p>
  
  <p>Here is my short, snippy example code:</p>
  
  <p><strong>diabChart.h</strong></p>
  
  <pre><code>#ifndef DIABCHART_H
  #define DIABCHART_H
  
  #include &lt;QtCharts/QChartView&gt;
  #include &lt;QtCharts/QLineSeries&gt;
  #include &lt;QtCharts/QDateTimeAxis&gt;
  #include &lt;QtCharts/QCategoryAxis&gt;
  #include &lt;QDateTime&gt;
  #include &lt;QtQuick/QQuickPaintedItem&gt;
  #include &lt;QColor&gt;
  #include &lt;QObject&gt;
  
  QT_CHARTS_USE_NAMESPACE
  
  class DiabChart : public QObject
  {
      Q_OBJECT
  
  public:
      explicit DiabChart(QObject *parent = 0);
  
      Q_INVOKABLE QAbstractSeries* setLineSeries();
  
  };
  
  #endif // DIABCHART_H
  </code></pre>
  
  <p><strong>diabChart.cpp</strong></p>
  
  <pre><code>#include "diabchart.h"
  #include &lt;QtCharts/QChartView&gt;
  
  QT_CHARTS_USE_NAMESPACE
  
  Q_DECLARE_METATYPE(QAbstractSeries *)
  Q_DECLARE_METATYPE(QAbstractAxis *)
  
  DiabChart::DiabChart(QObject *parent)
      : QObject(parent)
  {
      qRegisterMetaType&lt;QAbstractSeries*&gt;();
      qRegisterMetaType&lt;QAbstractAxis*&gt;();
  }
  
  QAbstractSeries* DiabChart::setLineSeries()
  {
      QLineSeries *bloodSugarSeries = new QLineSeries();
  
      QPen penBloodSugar;
      penBloodSugar.setColor(QColor(34, 102, 102));
      penBloodSugar.setWidth(5);
      QDateTime xValue;
      xValue.setDate(QDate(2016,7,3));
      xValue.setTime(QTime(0,0));
      bloodSugarSeries-&gt;append(xValue.toMSecsSinceEpoch(), 192.6);
      xValue.setTime(QTime(7,0));
      bloodSugarSeries-&gt;append(xValue.toMSecsSinceEpoch(), 89);
      xValue.setTime(QTime(9,0));
      bloodSugarSeries-&gt;append(xValue.toMSecsSinceEpoch(), 100);
      xValue.setTime(QTime(12,0));
      bloodSugarSeries-&gt;append(xValue.toMSecsSinceEpoch(), 50);
      xValue.setTime(QTime(14,0));
      bloodSugarSeries-&gt;append(xValue.toMSecsSinceEpoch(), 250);
      xValue.setTime(QTime(18,0));
      bloodSugarSeries-&gt;append(xValue.toMSecsSinceEpoch(), 140);
      xValue.setTime(QTime(21,0));
      bloodSugarSeries-&gt;append(xValue.toMSecsSinceEpoch(), 80);
      xValue.setTime(QTime(23,30));
      bloodSugarSeries-&gt;append(xValue.toMSecsSinceEpoch(), 200);
      xValue.setDate(QDate(2016,7,4));
      xValue.setTime(QTime(0,0));
      bloodSugarSeries-&gt;append(xValue.toMSecsSinceEpoch(), 192.6);
      bloodSugarSeries-&gt;setPen(penBloodSugar);
  
  
      return bloodSugarSeries;
  }
  </code></pre>
  
  <p><strong>main.cpp</strong></p>
  
  <pre><code>#include &lt;QQmlApplicationEngine&gt;
  #include &lt;QtWidgets/QApplication&gt;
  #include &lt;QtCharts/QChartView&gt;
  #include &lt;QtWidgets/QMainWindow&gt;
  #include &lt;QtQuick/QQuickView&gt;
  #include &lt;QApplication&gt;
  
  #include "diabchart.h"
  
  QT_CHARTS_USE_NAMESPACE
  
  int main(int argc, char *argv[])
  {
  
      QApplication app(argc, argv);
  
      qmlRegisterType&lt;DiabChart&gt;("DiabChart", 1, 0, "DiabChart");
  
  
      QQmlApplicationEngine engine;
      engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
  
      return app.exec();
  }
  </code></pre>
  
  <p><strong>main.qml</strong></p>
  
  <pre><code>import QtQuick 2.5
  import QtQuick.Controls 1.4
  import QtCharts 2.0
  import DiabChart 1.0
  
  ApplicationWindow {
      id: windowwindow
      visible: true
      width: 640
      height: 480
      title: qsTr("Hello World")
  
  
      DiabChart{
          id: diabetesView
      }
  
      function addseries()
      {
          // var xyz = diabetesView.setLineSeries();
  
          var series = diabBig.createSeries(ChartView.SeriesTypeLine, "Test", diabBig.axisX(lineseries), diabBig.axisY(lineseries));
          series.append(0,50);
          series.append(4,130);
  
          series = diabetesView.setLineSeries();
  
          diabBig.update();
      }
      Column{
          Rectangle{
              id: infoArea1
              color: "green"
              width: windowwindow.width
              height: windowwindow.height *0.25
  
              MouseArea{
                  anchors.fill: parent
                  onClicked: addseries()
              }
          }
          ChartView{
              id: diabBig
              width: windowwindow.width
              height: windowwindow.height *0.75
              title: "Line"
  
              antialiasing: true
  
              ValueAxis{
                  id: vlaueAxisX
                  min: 0
                  max: 24
                  tickCount: 12
                  labelFormat: "%2.0f:00"
              }
              ValueAxis{
                  id: valueAxisY
                  min:0
                  max: 500
                  tickCount: 50
              }
  
              LineSeries {
                  id: lineseries
                  axisX: vlaueAxisX
                  axisY: valueAxisY
                  name: "LineSeries"
                  XYPoint { id: zero; x: 0; y: 192.6}
                  XYPoint { id: first; x: 7; y: 89 }
                  XYPoint { x: 9; y: 80 }
                  XYPoint { x: 12; y: 30 }
                  XYPoint { x: 14; y: 150 }
                  XYPoint { x: 18; y: 40 }
                  XYPoint { x: 21; y: 280 }
                  XYPoint { id: last; x: 23.5; y: 200 }
                  XYPoint { id: twentyfour; x: 24; y: 192.6}
              }
          }
      }
  }
  </code></pre>
  
  <p><strong>test.pro</strong></p>
  
  <pre><code>TEMPLATE = app
  
  QT += charts qml quick
  
  CONFIG += c++11
  
  SOURCES += main.cpp \
      diabchart.cpp
  
  RESOURCES += qml.qrc
  
  # Additional import path used to resolve QML modules in Qt Creator's code model
  QML_IMPORT_PATH = #../Diabetes
  
  # Default rules for deployment.
  include(deployment.pri)
  
  DISTFILES +=
  
  HEADERS += diabchart.h
  </code></pre>