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. QWidget::repaint: Recursive repaint detected
Forum Update on Monday, May 27th 2025

QWidget::repaint: Recursive repaint detected

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 3 Posters 4.3k 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.
  • Mostafa WasatM Offline
    Mostafa WasatM Offline
    Mostafa Wasat
    wrote on last edited by
    #1

    Where can I learn more about this error ? any online documentation ? How can I debug this error ?

    1 Reply Last reply
    0
    • jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Did you override the paintEvent?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • Mostafa WasatM Offline
        Mostafa WasatM Offline
        Mostafa Wasat
        wrote on last edited by
        #3

        @jsulm yes, declared as
        void paintEvent(QPaintEvent *e) Q_DECL_OVERRIDE;

        1 Reply Last reply
        0
        • jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Can you post its content?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          Mostafa WasatM 1 Reply Last reply
          0
          • jsulmJ jsulm

            Can you post its content?

            Mostafa WasatM Offline
            Mostafa WasatM Offline
            Mostafa Wasat
            wrote on last edited by
            #5

            @jsulm

            void OpenGLWidget::paintEvent(QPaintEvent *e){
                QPainter p;
            
               // updateGL();
            
                p.begin(this);
                p.setPen(Qt::white);
                p.drawText(QPointF(50,50),"Test");
                p.end();
            }
            
            1 Reply Last reply
            0
            • Mostafa WasatM Offline
              Mostafa WasatM Offline
              Mostafa Wasat
              wrote on last edited by
              #6

              could it be that the QOpenGLWidget is initialized before menubar() in the MainWindow.h , thus making a conflict ?

              1 Reply Last reply
              0
              • Chris KawaC Offline
                Chris KawaC Offline
                Chris Kawa
                Lifetime Qt Champion
                wrote on last edited by
                #7

                updateGL causes a paintEvent which calls updateGL, which causes paintEvent which...
                Yes, this is recursive.

                Mostafa WasatM 1 Reply Last reply
                0
                • Chris KawaC Chris Kawa

                  updateGL causes a paintEvent which calls updateGL, which causes paintEvent which...
                  Yes, this is recursive.

                  Mostafa WasatM Offline
                  Mostafa WasatM Offline
                  Mostafa Wasat
                  wrote on last edited by
                  #8

                  @Chris-Kawa in case you didnt notice, the call to updateGL() is commented out.

                  1 Reply Last reply
                  0
                  • Chris KawaC Offline
                    Chris KawaC Offline
                    Chris Kawa
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    Ah, ok. I thought it was commented out because it caused the error.

                    You can always put a breakpoint in the line printing the error and look at the call stack to see where is it coming from. It could be a repaint called from non-ui thread or a direct call to paintEvent from somewhere.

                    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