I build a three-dimensional graph using QtDataVisualization .
Q3DScatter *scatter = new Q3DScatter; QScatterDataProxy *proxy = new QScatterDataProxy; QScatter3DSeries *series = new QScatter3DSeries(proxy); //... void addItem(double x, double y, double z){ QScatterDataItem item; item.setX(x); item.setY(y); item.setZ(z); proxy->addItem(item); } The problem is that the addItem method addItem called quite often in a parallel thread. And every time the scatter updated. With a large number of points (thousands), "friezes" begin. While only one solution comes to mind, accumulate points and add hundreds at once:
void addItem(double x, double y, double z){ static QScatterDataArray items; QScatterDataItem item; item.setX(x); item.setY(y); item.setZ(z); items.append(item); if(items.size() >= 100){ proxy->addItems(items); } } As for me it is a crutch. Can someone know any option or event with which you can do something so that the schedule is not updated entirely for the sake of each new point?
UPD:
Based on the answer @ alexis031182, it will not work "nicely". I do something like this:
class Scatter : public QWidget{ QScatterDataProxy *_proxy; QScatterDataArray _items; int _timerId; //... public: Scatter(): _timer(startTimer(100)) {} //... protected: void timerEvent(QTimerEvent *event){ if(event->timerId() != _timerId){ return; } event->accept(); if(_items.empty()){ return; } _proxy->addItems(_items); _items.clear(); } };