Results 1 to 3 of 3

Thread: [SOLVED]QLineSeries extremely slow

  1. #1
    Join Date
    May 2018
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default [SOLVED]QLineSeries extremely slow

    Hi everybody!

    Im having some trouble using QtCharts.

    My application needs to plot some linear graphs. I have the data contained on an Array.
    I need to plot between 100 and 20000 points or so.


    On my .h
    Qt Code:
    1. QChart *Chart;
    2. QLineSeries *Serie;
    3. QChartView *View;
    To copy to clipboard, switch view to plain text mode 

    How I Initialize everything

    Qt Code:
    1. void Initialize(void)
    2. {
    3. Serie=new QLineSeries();
    4. Chart=new QChart();
    5. Chart->legend()->hide();
    6. Chart->addSeries(Serie);
    7. Chart->createDefaultAxes();
    8. View= new QChartView(Chart);
    9. View->setRenderHint(QPainter::Antialiasing);
    10. }
    To copy to clipboard, switch view to plain text mode 


    Now lets assume I want to plot 10000 points (I dont care about the value)

    Qt Code:
    1. void Plot(void)
    2. {
    3. //------------Reset-------------------
    4. Serie->clear();
    5. //---------------------------------------
    6.  
    7. for(long int i=0;i<10000;i++)
    8. {
    9. QApplication::processEvents();
    10. Serie->append(i,i+10);//Right now I dont care about the value
    11. }
    12. Chart->removeSeries(Serie);
    13. Chart->addSeries(Serie);
    14. }
    To copy to clipboard, switch view to plain text mode 

    That "for" loops takes like 20 seconds to complete. Freezing all of my program.
    Im not doing anything weird, just calling the append method of a QLineSeries.

    Am i doing something wrong?
    Is there a way to append 10K points and not having to wait so much?


    The final Chart looks exactly as i want it to look. Its just that I wait that much each time I need to plot some data

    Any ideas?

    Thanks in advance


    Added after 21 minutes:


    UPDATE:

    I have read that you can call the setUseOpenGL() method of the LineSeries to make it faster.
    On my example, it has the opposite effect. If i activate the OpenGL, the for will take even longer to finish.


    Added after 14 minutes:


    Another Update:

    In order to understand why it takes So long to plot. I placed a progressbar which increases as the for loop advances.
    The results where quite strange.

    The time it takes to complete that for is not Linear!
    What do i mean?

    The beggining of the for is done extremely fast. As "i" advences, each time the append operation takes more time.

    Lets make a basic example. If on my computer takes 20 seconds to complete that for sequence...
    After 5 seconds: 50 % of the Graph plotted
    After 10 seconds: 80% of the Graph plotted
    After 15 seconds:n 95% of the Graph plotted

    Why does this happen?
    The insertion time of a list is always the same, It doesnt matter how much nodes that list has...
    Last edited by NicolasCasime; 23rd May 2018 at 16:07.

  2. #2
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    463
    Thanks
    10
    Thanked 61 Times in 59 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QLineSeries extremely slow

    Hi, maybe it helps to add the QLineSeries to the QChart after you have filled it? Also I think calling processEvents() after each value is a bit much.

    Ginsengelf

  3. #3
    Join Date
    May 2018
    Posts
    2
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QLineSeries extremely slow

    Creating the series first, and adding it to the Chart after all of the appends solved the problem

    Each append if the seires is already on the QChart triggers an update. It gets re-drawn.

    Thats why as i got higher, each append took more time.

    Thanks for the help

Similar Threads

  1. Cmake Qt5 Windows EXTREMELY SLOW moc.exe
    By pip010 in forum Installation and Deployment
    Replies: 0
    Last Post: 8th February 2016, 10:48
  2. Qt Creator Debugging extremely slow
    By GMouzon in forum Qt Tools
    Replies: 4
    Last Post: 28th September 2015, 23:15
  3. QtWebEngine is extremely slow
    By GimpMaster in forum Qt Programming
    Replies: 7
    Last Post: 19th June 2015, 05:26
  4. QtCreator extremely slow with many includepaths
    By rybka007 in forum Qt Tools
    Replies: 2
    Last Post: 10th January 2014, 08:50
  5. Showing QGraphicsEllipseItems extremely slow
    By kalos80 in forum Qt Programming
    Replies: 5
    Last Post: 13th January 2010, 09:11

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.