Append Model to VXYModelMapper
Hi,
I use "VXYModelMapper" and "QStandardItemModel" in plot chart. I use following code but append model to VXYModelMapper is very slow. QElapsedTimer shows the delay in the last line.
I consume 123045 milliseconds if I do it after showing the window, if I do it before it consumes 0 millisecond :O. Well, I need the user to select a chart from the list to display it. So the code runs after after showing the window.
version of Qt: Qt 5.11.2
Code:
VXYModelMapper {
model: myChartClass.newMyChartModel
series: lineSeries
xColumn: 0
yColumn: 1
}
{
newMyChartModel= model;
emit myChartModelChanged(model);
}
foreach(const QJsonValue & val, npcArray){
double xVal=val.toObject().value("x").toDouble();
double yVal=val.toObject().value("y").toDouble();
lineModel->setItem(i, 0, item1);
lineModel->setItem(i, 1, item2);
i+=1;
}
//To this line everything is very good and fast
QElapsedTimer timer;
timer.start();
myChartClass->setMyChartModel(lineModel);
qDebug() << "The slow operation took" << timer.elapsed() << "millisecond";
Output:
Code:
The slow operation took 123045 millisecond.
Total point count: 5188
It is very slow :(
Please guide me.