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. [SOLVED] QWidget::repaint: Recursive repaint detected
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] QWidget::repaint: Recursive repaint detected

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 26.1k 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.
  • C Offline
    C Offline
    Code_ReaQtor
    wrote on last edited by
    #1

    I have a project which has multiple threads. Each thread has a "worker class" which updates a single progress bar located in the main thread (MainWindow).
    The progress bar's pointer is passed to the "worker class" at at the time it was instantiated. I didn't subclass QThread but instead, I used QObject::moveToThread() to pass the worker class to a thread.

    @
    QThread1 ---> QProgressBar1
    QThread2 ---> QProgressBar2
    QThread3 ---> QProgressBar3
    ....
    @

    when there are multiple threads/worker class created, "QWidget::repaint: Recursive repaint detected" error comes out.
    I am thinking that it was caused by passing the pointer of the progress bar to another thread.
    What is the solution for this? Thanks

    Please visit my open-source projects at https://github.com/Code-ReaQtor.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      You can not (directly) update widgets from within threads.

      I suspect you're using methods like setValue on the progress bar from within the threads, right? Don't do that. Instead, use a signal-slot connection. The setValue method is already a slot, so there is very little code overhead. The signal-slot mechanism will take care of making this updating thread save.

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Code_ReaQtor
        wrote on last edited by
        #3

        [quote author="Andre" date="1361176505"]You can not (directly) update widgets from within threads.

        I suspect you're using methods like setValue on the progress bar from within the threads, right? Don't do that. Instead, use a signal-slot connection. The setValue method is already a slot, so there is very little code overhead. The signal-slot mechanism will take care of making this updating thread save.[/quote]

        Yes, you are right. I will try to rewrite the code. Thanks.

        Please visit my open-source projects at https://github.com/Code-ReaQtor.

        D 1 Reply Last reply
        0
        • C Code_ReaQtor

          [quote author="Andre" date="1361176505"]You can not (directly) update widgets from within threads.

          I suspect you're using methods like setValue on the progress bar from within the threads, right? Don't do that. Instead, use a signal-slot connection. The setValue method is already a slot, so there is very little code overhead. The signal-slot mechanism will take care of making this updating thread save.[/quote]

          Yes, you are right. I will try to rewrite the code. Thanks.

          D Offline
          D Offline
          DeSa
          wrote on last edited by
          #4

          @Code_ReaQtor, and andre,

          that is exactly the issue I had for the last 2 hours of debugging. Thanks a lot for the solution I found here 10 years later

          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