QML, create LineSeries at runtime
Unsolved
QML and Qt Quick
-
My goal is to have a QML
ChartView
with a variable number ofLineSeries
added to it during runtime. It is unknown how manyLineSeries
will need to be added until a user selects and loads a file with the data in it.I tried to create all of the
LineSeries
inside aRepeater
, with no luck. I suspect it's becauseChartView
doesn't know what to do with a bunch ofItem
's. It's not possible to have theRepeater
createLineSeries
directly since aRepeater
doesn't work onQObject
's:ChartView { ...... Repeater { model: numberOfColumnsInModel / 2 delegate: Item { LineSeries { id: lineSeries axisX: xAxis axisY: yAxis VXYModelMapper { id: modelMapper model: lineChart.model //Reimplemented QAbstractTableModel xColumn: index * 2 yColumn: index * 2 + 1 } onHovered: { console.log("Do something..."); } } } } }
In the examples I see online, each
LineSeries
is hard-coded--once for each line in theChartView
--and not useful to me.