Solved 3D scatter how to update new points and remove old one
-
Hello,
I am using the 3D scatter plot to plot 3D points, I can add new points to this plot but then the old ones stay and I want them to be removed when the new points are added. My code looks like this:scatter.setFlags(scatter.flags() ^Qt::FramelessWindowHint); QScatter3DSeries *series = new QScatter3DSeries; //here I add the points to the 3Dscatterarray data << QVector3D(o.x, o.y, o.z); scatter.removeSeries(prevseries); series->dataProxy()->addItems(data); scatter.addSeries(series); data.clear(); prevseries = series;
I tried as seen in the code to remove the previous series but that doesn't work. I also looked at the scatter example but that didn't help/work.
Hope someone can help me with this problem. -
Hi
I wonder if you can call
void QScatterDataProxy::resetArray(QScatterDataArray *newArray)
with NULL
and then use additem.
https://doc.qt.io/qt-5.10/qscatterdataproxy.html#resetArray -
Hello,
Thanks for your response. I tried it out and it didn't work, it still didn't remove the points out of the scatter. The only thing it did was refreshing the window which made it spring a bit around.
I think it clears the array but not the scatter plot, do you know if there's a way to clear the scatter plot I haven't been able to find it. -
@Vera
Im sure i understand why
scatter.removeSeries(prevseries); do not remove the data ? -
@mrjj
I got it working. So the removeSeries works i did it like this now:scatter.removeSeries(prevseries); series->dataProxy()->addItems(data); scatter.addSeries(series); data.clear(); prevseries = series;
this works now it deletes the previous data, I also set the program to 1fps haven't tried putting it faster but it works now. Thanks for your help