Results 1 to 1 of 1

Thread: Append Model to VXYModelMapper

  1. #1
    Join Date
    Jan 2016
    Posts
    81
    Thanks
    31
    Qt products
    Qt5
    Platforms
    Windows

    Default 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
    Qt Code:
    1. VXYModelMapper {
    2. model: myChartClass.newMyChartModel
    3. series: lineSeries
    4. xColumn: 0
    5. yColumn: 1
    6. }
    7. void MyChartClass::setMyChartModel(QStandardItemModel *model)
    8. {
    9. newMyChartModel= model;
    10. emit myChartModelChanged(model);
    11. }
    12.  
    13. QStandardItemModel* lineModel=new QStandardItemModel(npcArray.size(), 2);
    14. foreach(const QJsonValue & val, npcArray){
    15. double xVal=val.toObject().value("x").toDouble();
    16. double yVal=val.toObject().value("y").toDouble();
    17.  
    18. QStandardItem *item1 = new QStandardItem(QString::number(xVal));
    19. lineModel->setItem(i, 0, item1);
    20.  
    21. QStandardItem *item2 = new QStandardItem(QString::number(yVal));
    22. lineModel->setItem(i, 1, item2);
    23. i+=1;
    24. }
    25.  
    26. //To this line everything is very good and fast
    27.  
    28. QElapsedTimer timer;
    29. timer.start();
    30. myChartClass->setMyChartModel(lineModel);
    31. qDebug() << "The slow operation took" << timer.elapsed() << "millisecond";
    To copy to clipboard, switch view to plain text mode 

    Output:
    Qt Code:
    1. The slow operation took 123045 millisecond.
    2. Total point count: 5188
    To copy to clipboard, switch view to plain text mode 

    It is very slow
    Please guide me.
    Last edited by neda; 2nd December 2018 at 06:25.

Similar Threads

  1. How do I append and int to my QString?
    By seink in forum Newbie
    Replies: 3
    Last Post: 31st May 2015, 22:45
  2. Replies: 1
    Last Post: 29th August 2013, 06:41
  3. Can't see any text append in UI?
    By SamT in forum Qt Programming
    Replies: 3
    Last Post: 9th April 2011, 13:27
  4. Append file
    By mvbhavsar in forum Newbie
    Replies: 3
    Last Post: 10th February 2011, 09:38
  5. Cannot append to QFile using QIODevice::Append
    By philwinder in forum Qt Programming
    Replies: 4
    Last Post: 17th November 2008, 10:09

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.