Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Custom Item controlling LineSeries
Forum Updated to NodeBB v4.3 + New Features

Custom Item controlling LineSeries

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 1 Posters 244 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    St.Stanislav
    wrote on last edited by St.Stanislav
    #1

    Hello all! I am wondering how could I correctly create my own ChartView drawer. What I mean: let suppose that we have some Item with ChartView with the following structure:

    Item {
        ChartView {
             MyCustomItem {
                 LineSeries {}    
                 LineSeries {}    
                 ScatterSeries {}    
                 function plot() {}
             }
         }
    }
    

    I want to implement item with several series to be plotted on the parent's ChartView. In this was it is not working, looks like Series should be created inside ChartView. Moreover, if I understand correctly, Series don't have parents, so I could not change parent. In documentation I have not found how to attach already created Series to the ChartView. Is there some not so long way to do so, or should I redefine ChartView module?

    I can create series dynamically in MyCustomItem:

    Component.onCompleted: {
        if (parent instanceof ChartView) {
             scatterPoint = parent.createSeries(ChartView.SeriesTypeScatter, "scatter series", parent.axisX, parent.axisY);
        }
    }
    

    Then I could use this scatterPoint as pointer and control this series. But can I connect this line properties dynamically with MyCustomItem properties?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      St.Stanislav
      wrote on last edited by
      #2

      Some workaround that I have found for my question: in c++ code I have implemented method:

      void BaseChartView::setMainSeries(QAbstractSeries *abstractSeries)
      {
          if (abstractSeries == Q_NULLPTR) return;
          if (abstractSeries->type() == QtCharts::QAbstractBarSeries::SeriesTypeLine) m_mainSeries = static_cast<QLineSeries*>(abstractSeries);
          m_chart = m_mainSeries->chart();
      }
      

      Then I have created LineSeries on ChartView in qml code and used this method to receive pointer to QChart that I can successfully process later.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved