Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. [PyQt5] graphyview setdata() doesn't work after recieving a mount of data
Forum Updated to NodeBB v4.3 + New Features

[PyQt5] graphyview setdata() doesn't work after recieving a mount of data

Scheduled Pinned Locked Moved Solved Qt for Python
6 Posts 2 Posters 488 Views 1 Watching
  • 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.
  • U Offline
    U Offline
    ugly_curry_garlic
    wrote on last edited by
    #1

    Sorry about my poor English
    I designed UI with UIdesigner, and I wrote four threads to handle the interface, serial port, calculation and drawing(all create by Qthread).
    微信图片_20231121190929.png

    The window I draw on is upgraded through UIdesigner's Graphyview.
    There is no problem when receiving data within an uncertain period of time, such as within about 1 minute, the serial port receives row data and passes it to the interface for display and calculation. After calculation, The new data is loaded into the list and used for drawing, the drawing function is used by [.setdata(list)]
    微信图片_20231121192824.png
    you can see the lastest data is used as the label too. but few moment later, 1st painting stuck and then 2nd painting stuck ten seconds later,after a while, it will get stuck one after another but interface and label still work. Most of them are stuck in sequence, sometimes in disorder.
    after drawing stuck, I also clicked the button of [.setdata(zero*200_list)] to no avail.The faster the receiving serial port frequency is, the faster the image will be stuck.
    Add one more, Super fast data also makes my interface freeze until I click any button.So I controlled the sending speed of the slave computer.

    what I have tryed:
    ①Delete oldest data which in the interface to reduce memory.(doesn't work)
    ②Carefully screen the received data, and incorrect data will not be use for [.setdata()].(doesn't work)
    ③I once thought that the drawing thread was too busy with calculations, so I added a fourth thread: calculation. Computing without threads also has this problem.(doesn't work)
    ④I didn't do long-term testing at first.Rolling my code back to the earliest version, accepting data and drawing directly also has this problem.(doesn't work)
    ⑤Use [.repaint()] or [.replot()] when stuck.(doesn't work, may be worng object?)
    ⑥I used redefinition for the escape key.The drawing will be updated when cancel the exit or switch to other software pages, it breaks me down.
    ⑦I remove the other code and just keep the loop drawing which also causes the stuck, I think Frequent [.setdata()] will cause stuck maybe.

    My question:
    ①why doesn't [.setdata()] work?
    ②I only update all the graphs once I receive the data once, why are they stuck one by one?
    ③The most important ,how to fix it?

    Sorry to bother you, thank you very much for watching

    JonBJ 1 Reply Last reply
    0
    • U ugly_curry_garlic

      Sorry about my poor English
      I designed UI with UIdesigner, and I wrote four threads to handle the interface, serial port, calculation and drawing(all create by Qthread).
      微信图片_20231121190929.png

      The window I draw on is upgraded through UIdesigner's Graphyview.
      There is no problem when receiving data within an uncertain period of time, such as within about 1 minute, the serial port receives row data and passes it to the interface for display and calculation. After calculation, The new data is loaded into the list and used for drawing, the drawing function is used by [.setdata(list)]
      微信图片_20231121192824.png
      you can see the lastest data is used as the label too. but few moment later, 1st painting stuck and then 2nd painting stuck ten seconds later,after a while, it will get stuck one after another but interface and label still work. Most of them are stuck in sequence, sometimes in disorder.
      after drawing stuck, I also clicked the button of [.setdata(zero*200_list)] to no avail.The faster the receiving serial port frequency is, the faster the image will be stuck.
      Add one more, Super fast data also makes my interface freeze until I click any button.So I controlled the sending speed of the slave computer.

      what I have tryed:
      ①Delete oldest data which in the interface to reduce memory.(doesn't work)
      ②Carefully screen the received data, and incorrect data will not be use for [.setdata()].(doesn't work)
      ③I once thought that the drawing thread was too busy with calculations, so I added a fourth thread: calculation. Computing without threads also has this problem.(doesn't work)
      ④I didn't do long-term testing at first.Rolling my code back to the earliest version, accepting data and drawing directly also has this problem.(doesn't work)
      ⑤Use [.repaint()] or [.replot()] when stuck.(doesn't work, may be worng object?)
      ⑥I used redefinition for the escape key.The drawing will be updated when cancel the exit or switch to other software pages, it breaks me down.
      ⑦I remove the other code and just keep the loop drawing which also causes the stuck, I think Frequent [.setdata()] will cause stuck maybe.

      My question:
      ①why doesn't [.setdata()] work?
      ②I only update all the graphs once I receive the data once, why are they stuck one by one?
      ③The most important ,how to fix it?

      Sorry to bother you, thank you very much for watching

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @ugly_curry_garlic said in [PyQt5] graphyview setdata() doesn't work after recieving a mount of data:

      UIdesigner's Graphyview

      Don't know what "Graphyview" is?

      I wrote four threads to handle the interface, serial port, calculation and drawing(all create by Qthread).

      If you mean you have a secondary thread handling "drawing to the UI". This is not allowed. Depends exactly what it is/does. But Qt requires the UI only be updated by the main thread. Secondary thread may appear to work, but is not reliable.

      U 2 Replies Last reply
      3
      • JonBJ JonB

        @ugly_curry_garlic said in [PyQt5] graphyview setdata() doesn't work after recieving a mount of data:

        UIdesigner's Graphyview

        Don't know what "Graphyview" is?

        I wrote four threads to handle the interface, serial port, calculation and drawing(all create by Qthread).

        If you mean you have a secondary thread handling "drawing to the UI". This is not allowed. Depends exactly what it is/does. But Qt requires the UI only be updated by the main thread. Secondary thread may appear to work, but is not reliable.

        U Offline
        U Offline
        ugly_curry_garlic
        wrote on last edited by
        #3

        @JonB
        I'm sorry, I typed wrongly “Graphyview”. It should be "Graphics View", one of Display Widget in Qtdesigner1700618208309.jpg

        Thank for your solution!Hope this workaround works, my utmost gratitude

        1 Reply Last reply
        0
        • JonBJ JonB

          @ugly_curry_garlic said in [PyQt5] graphyview setdata() doesn't work after recieving a mount of data:

          UIdesigner's Graphyview

          Don't know what "Graphyview" is?

          I wrote four threads to handle the interface, serial port, calculation and drawing(all create by Qthread).

          If you mean you have a secondary thread handling "drawing to the UI". This is not allowed. Depends exactly what it is/does. But Qt requires the UI only be updated by the main thread. Secondary thread may appear to work, but is not reliable.

          U Offline
          U Offline
          ugly_curry_garlic
          wrote on last edited by
          #4

          @JonB Super awesome! The probability of it getting stuck is greatly reduced. Even under high frequency conditions, one or two will occasionally get stuck after ten minutes, and not one after another, it probably work!!!👍👍👍👍👍👍👍👍👍

          1 Reply Last reply
          0
          • U ugly_curry_garlic has marked this topic as solved on
          • U Offline
            U Offline
            ugly_curry_garlic
            wrote on last edited by
            #5

            But I'm still hoping someone can tell me how I can permanently fix this stuck situation❤️❤️❤️

            JonBJ 1 Reply Last reply
            0
            • U ugly_curry_garlic

              But I'm still hoping someone can tell me how I can permanently fix this stuck situation❤️❤️❤️

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by
              #6

              @ugly_curry_garlic
              You would have to debug your code. See if you can discover where it "gets stuck". If you are using threads there is always a chance there will be a fault in your code.

              1 Reply Last reply
              0

              • Login

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