Get name of QML LineSeries when the LineSeries is hovered over - (LineSeries created dynamically)
-
I am trying to get a reference to a dynamically created LineSeries when hovered over. After the LinesSeries is created I attach a signal handler to the hovered event.
The problem is:
From the simplified example below, when I hover over the LineSeries it prints out the name of the last LineSeries that was added. When It should print the name of the series of each LineSeries added.
For example if 3 LineSeries were created with names ["Line A", "Line B", "Line C" ], when hovering over each it should print each corresponding name, but instead it printing, "Line C", for all 3 LineSeries hovered event handlers. What am I doing
wrong?//dataset is a dictionary(QVariant) of items where each item is the name of the line series for(var name in dataset) { var series = chart.createSeries(ChartView.SeriesTypeLine, name, xAxis, yAxis); series.name = name; series.hovered.connect( function (point,state){ if (state){ console.log(">>>"+ name); // <- should print the name of each series } });
I have a feeling it has something to do with binding the current value of the name variable to the onhovered event handler but I am not sure how to do this. I know in regular JS they do something like
functionName.bind( { ... code ... }, this );
Thanks for your help.
--E
-
@Edwin-F. said in Get name of QML LineSeries when the LineSeries is hovered over - (LineSeries created dynamically):
I have a feeling it has something to do with binding the current value of the name variable to the onhovered event handler but I am not sure how to do this. I know in regular JS they do something like
functionName.bind( { ... code ... }, this );
Thanks for your help.
--Eposted on SO maybe ill get an answer there