QML, create LineSeries at runtime
-
My goal is to have a QML
ChartViewwith a variable number ofLineSeriesadded to it during runtime. It is unknown how manyLineSerieswill need to be added until a user selects and loads a file with the data in it.I tried to create all of the
LineSeriesinside aRepeater, with no luck. I suspect it's becauseChartViewdoesn't know what to do with a bunch ofItem's. It's not possible to have theRepeatercreateLineSeriesdirectly since aRepeaterdoesn'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
LineSeriesis hard-coded--once for each line in theChartView--and not useful to me.