Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. GUI events slow down long computations

GUI events slow down long computations

Scheduled Pinned Locked Moved Unsolved General and Desktop
24 Posts 4 Posters 4.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • JonBJ JonB

    @engsml
    300k points-odd is still a lot of points, though having no experience I don't know what to expect. I don't suppose your average end-user will notice each one of those. If you only add 1 in 10 of them you call processEvents() 10 times fewer for the same responsiveness. So if you have a lot of points you could sample or average and it would all be a lot quicker. Though that's probably very naughty :)

    E Offline
    E Offline
    engsml
    wrote on last edited by
    #21

    @JonB That's definitely a good point. I'll have to play around with the UX when I get everything working properly in the end :)

    JonBJ 1 Reply Last reply
    0
    • E engsml

      @JonB That's definitely a good point. I'll have to play around with the UX when I get everything working properly in the end :)

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by JonB
      #22

      @engsml
      I see there is a https://doc.qt.io/qt-5.9/qxyseries.html#append-2 which takes a QList<QPointF>. It may or may not be more efficient than you adding points one-at-a-time. Might be worth a try?

      E 1 Reply Last reply
      0
      • JonBJ JonB

        @engsml
        Hang on a minute. Let's look at your code, please:

        int arrSize = 4096; //for incrementing in intervals
        for(int i = 0; i < arr.size(); i += arrSize) //Plots in increments of 4096
            plot(arr, (i + 4096));
        

        This passes first 0+4096, then 4096+4096, then 8192+4096, then....

        void myClass::plot(QVector<QPointF> arr, int size)
            for(int i = begin; i < size; i++){
        

        arr is always the original array. I presume (I'm not C++) begin is always 0. size is bigger (by 4096) every time plot is called.

        Aren't you (re-)plotting more & more points --- specifically, all points from 0 up to where you have progressed to --- every time you call plot() in your batches?? Or am I going loopy?

        SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #23

        Hi,

        @JonB said in GUI events slow down long computations:

        void myClass::plot(QVector<QPointF> arr, int size)
        for(int i = begin; i < size; i++){

        arr is always the original array. I presume (I'm not C++) begin is always 0. size is bigger (by 4096) every time plot is called.

        Nope, it's a copy, if you want to avoid useless copies, pass const references i.e. void myClass::plot(const QVector<QPointF> &arr).

        In the case you only want to process items between two elements of the vector then pass the start and end iterator within your arrays.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        6
        • JonBJ JonB

          @engsml
          I see there is a https://doc.qt.io/qt-5.9/qxyseries.html#append-2 which takes a QList<QPointF>. It may or may not be more efficient than you adding points one-at-a-time. Might be worth a try?

          E Offline
          E Offline
          engsml
          wrote on last edited by
          #24

          @JonB I tried that, but it still caused the GUI to become unresponsive. I also tried a similar approach where I passed a QVector<QPointF> and did series->replace(); and that was also too slow for the function to handle. It seems the data is just too large for these functions. I considered passing the array in intervals instead of all at once for these functions, but ultimately decided it was already very similar to the function I already have.

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved