'second QScatterSeries added through a slot method not showing, why?
In a QDockWidget, I create a QChartView, a Chart and a QScatterSeries, in which I append QPointFs in a for loop:
self.fkChart = QChart()
self.fkPoints = QScatterSeries()
for specie in GrayScottModel.species.keys():
feed = GrayScottModel.species[specie][2]
kill = GrayScottModel.species[specie][3]
symbol = GrayScottModel.species[specie][5]
fkPoint = FkPoint(kill, feed, specie, symbol)
self.fkPoints.append(fkPoint)
self.fkChart.addSeries(self.fkPoints)
self.fkChart.legend().hide()
self.fkChart.createDefaultAxes()
axisX = self.fkChart.axes(orientation=Qt.Horizontal)[0]
axisX.setTickInterval(0.01)
axisX.setTickCount(6)
axisX.setRange(0.03,0.08)
axisY = self.fkChart.axes(orientation=Qt.Vertical)[0]
axisY.setTickInterval(0.02)
axisY.setTickCount(7)
axisY.setRange(0.0,0.12)
self.fkChartView = QChartView(self.fkChart)
topLayout.addWidget(self.fkChartView)
All is ok, my dock panel appears and I have the chart with the points plotted in it.
then in a Slot method, I would like to have one of the points highlighted. I choose to add a second ScatterSeries to the chart:
if len(self.fkChart.series()) > 1:
self.fkChart.removeSeries(self.fkCurrentPoint)
# print(self.fkChart.series()[0].points())
self.fkCurrentPoint = QScatterSeries()
self.fkCurrentPoint.setColor(QColor('r'))
self.fkCurrentPoint.setMarkerSize(50)
self.fkCurrentPoint.append(self.canvas.grayScottModel.program["params"][3], self.canvas.grayScottModel.program["params"][2])
self.fkChart.addSeries(self.fkCurrentPoint)
But this point never appears in the chart, which stays exactly the same. I did printed out the series in the chart, and had two, one having always the same address, the second one changing (obviously, I remove it and recreate it, to 'highlight another point).
What do I forget to do, or is there a better way to do it? I don't have the index of the point, I just know the content of a string, being the name of something related to the point. Hence the FkPoint being a subclass of QPointF holding more than just x and y. But that's for later...
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
