Results 1 to 8 of 8

Thread: Slow GUI Update with 80 plus spinboxes and leds

  1. #1
    Join Date
    Mar 2017
    Posts
    9
    Qt products
    Qt5
    Platforms
    Windows

    Default Slow GUI Update with 80 plus spinboxes and leds

    Hello,

    I am currently using Qt 5.8 with visual studio 2015. I am currently running in debug mode

    I am using a timer to kick off an updateGUI function call with all my GUI update calls. If I remove all the gui updates I can hit a gui refresh rate of like 500 fps.

    As I add the spinboxes, led and lineseries into the mix I can get around 5-8 fps.

    I have been reading and it seems all the gui updates need to be done in the main thread. All the data processing has already been pushed off to worker threads.

    Are there any suggestions to getting all these updates done quickly? I'd like to at least hit 30 fps.

  2. #2
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    507
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Slow GUI Update with 80 plus spinboxes and leds

    Hi, maybe QWidget::updatesEnabled-prop helps.

    Ginsengelf

  3. #3
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Slow GUI Update with 80 plus spinboxes and leds

    This type of a question is very hard to answer without knowing the actual code.
    However, your statement:
    I am using a timer to kick off an updateGUI function call with all my GUI update calls.
    is very suspicious.
    What is suspicious is the fact you need it, or that you think you need it - odds are this is a symptom of a design problem, again, what the problem actually may be is really impossible to tell with out knowing the code or at least having more information about it.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  4. #4
    Join Date
    Mar 2017
    Posts
    9
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Slow GUI Update with 80 plus spinboxes and leds

    Below is an example of my code structure.

    I tried at first putting a 10 ms delay in the timer, but my device can generate 1000s of data packets each second. So, I just grab the latest one and display when I do a get.

    Qt Code:
    1. CommGUI::CommGUI(Comm *drwg, QWidget *parent)
    2. : QMainWindow(parent)
    3. {
    4. ui.setupUi(this);
    5.  
    6. QTimer *refreshTimer = new QTimer(this);
    7. refreshTimer->start(0);
    8.  
    9. QObject::connect(refreshTimer, SIGNAL(timeout()), this, SLOT(UpdateGUI()));
    10. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. void CommGUI::UpdateGUI()
    2. {
    3. // Get Message from device
    4. // put data into map
    5. // this runs fast and is running in a separate thread
    6.  
    7. // example spinbox update
    8. // 80 of these
    9. ui.spinbox->setValue(map.value);
    10.  
    11. return;
    12. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by CodeSlapper; 30th March 2017 at 03:09.

  5. #5
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Slow GUI Update with 80 plus spinboxes and leds

    Refreshing / updating ~ 80 widgets (like spinbox / led) should be fairly quick.

    Here are couple of things you can consider to check/explore.

    1. Make sure you each widget is updated only once in a cycle.
    2. It would be better to get the changed data map, rather than all data map from worker thread.
    3. It would be better not to connect any slots to value changed signals of spinbox directly.
    4. Measure the time spent inside UpdateGUI() and measure the time to get the data from back ground thread separately, this could give you some surprising numbers.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  6. #6
    Join Date
    Mar 2017
    Posts
    9
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Slow GUI Update with 80 plus spinboxes and leds

    Santosh Reddy
    Re: Slow GUI Update with 80 plus spinboxes and leds

    Refreshing / updating ~ 80 widgets (like spinbox / led) should be fairly quick.

    Here are couple of things you can consider to check/explore.

    1. Make sure you each widget is updated only once in a cycle.
    2. It would be better to get the changed data map, rather than all data map from worker thread.
    3. It would be better not to connect any slots to value changed signals of spinbox directly.
    4. Measure the time spent inside UpdateGUI() and measure the time to get the data from back ground thread separately, this could give you some surprising numbers.
    I did find that I had some widgets being updated twice. That slowed it up some for sure.

    I timed the data grabs and they were very quick in vs, under a 1ms. I plan to make this faster in the future and have the work thread already populate a map and not do a data grab. I have reasons to do this other than speed.

    I don't have any slots directly to the spinboxes.

    But, now I added back in a lineseries->replace call and it has also caused a slow up. It is much better than when I was using the append function.

    Is there a fast way to plot a lineseries or is there a better library to use. I do have a video card an nvidia card with opengl available too.

    Thanks you so much for the help so far.

  7. #7
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Slow GUI Update with 80 plus spinboxes and leds

    Did you follow on anda's suggestion Nr.4?
    I too would start with that.
    Then you'd know where you lose your time - if its primarily in getting the data or the UI update and then you can look for the best strategy how to fix the issue - or may be even first to try and understand why it is happening.
    How does the "put data into map" code looks like?
    That too could be a good candidate for being slow if done inefficient.
    You did write this part is happening fast, but I wonder still.

    One thing could also be the very fact you are using a thread (or how you use it).
    If you are using mutexes when writing/reading the data to the map, depending on how you implement it and the interplay of frequency between writing/reading data to/from the map both by the worker thread and the UI they might be stepping on each others toes.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  8. #8
    Join Date
    Mar 2017
    Posts
    9
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Slow GUI Update with 80 plus spinboxes and leds

    I got 60 fps now in release mode even with a 10 ms timer for my timer.

    I ended up using some bits and pieces from the example, OpenGL Accelerated Series Example. I mainly used the opengl flag and using the replace call.

Similar Threads

  1. QTableWidget with many cellwidgets update very slow!
    By linxs in forum Qt Programming
    Replies: 4
    Last Post: 19th November 2012, 07:01
  2. Replies: 2
    Last Post: 29th September 2010, 17:44
  3. Slow update in QAbstractTableModel in setData
    By cevou in forum Qt Programming
    Replies: 2
    Last Post: 20th May 2010, 14:04
  4. SQL slow query - table update
    By lasher in forum Newbie
    Replies: 4
    Last Post: 21st October 2009, 23:12
  5. QTableWidget Update - slow
    By DPinLV in forum Qt Programming
    Replies: 16
    Last Post: 18th August 2006, 21:09

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.