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. Qt Animation: "A paint device can only be painted by one painter at a time."
Qt 6.11 is out! See what's new in the release blog

Qt Animation: "A paint device can only be painted by one painter at a time."

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 3 Posters 3.8k Views 2 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #2

    Hi and welcome to devnet,

    Since you do not keep the animation, I would use the parameter of the start method to let it be destroyed appropriately. See if that improves the situation.

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

    R 1 Reply Last reply
    2
    • SGaistS SGaist

      Hi and welcome to devnet,

      Since you do not keep the animation, I would use the parameter of the start method to let it be destroyed appropriately. See if that improves the situation.

      R Offline
      R Offline
      RyanAR
      wrote on last edited by
      #3

      @SGaist Thanks for the response!

      I replaced all the start() functions with start(QAbstractAnimation::DeleteWhenStopped), but I'm still getting the same warnings whenever I click the navigation buttons.

      Is it a requirement to use the save/restore functions for this type of animation, as I get the odd message about unbalanced save/restore? This is the qDebug+Warning output from a single button click:

      MainWindow::on_buttonHomeAll_clicked: D to All.
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::worldTransform: Painter not active
      QWidgetEffectSourcePrivate::pixmap: Painter not active
      QPainter::save: Painter not active
      QPainter::setOpacity: Painter not active
      QPainter::setWorldTransform: Painter not active
      QPainter::restore: Unbalanced save/restore
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::worldTransform: Painter not active
      QWidgetEffectSourcePrivate::pixmap: Painter not active
      QPainter::save: Painter not active
      QPainter::setOpacity: Painter not active
      QPainter::setWorldTransform: Painter not active
      QPainter::restore: Unbalanced save/restore
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::worldTransform: Painter not active
      QWidgetEffectSourcePrivate::pixmap: Painter not active
      QPainter::save: Painter not active
      QPainter::setOpacity: Painter not active
      QPainter::setWorldTransform: Painter not active
      QPainter::restore: Unbalanced save/restore
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::worldTransform: Painter not active
      QWidgetEffectSourcePrivate::pixmap: Painter not active
      QPainter::save: Painter not active
      QPainter::setOpacity: Painter not active
      QPainter::setWorldTransform: Painter not active
      QPainter::restore: Unbalanced save/restore
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::worldTransform: Painter not active
      QWidgetEffectSourcePrivate::pixmap: Painter not active
      QPainter::save: Painter not active
      QPainter::setOpacity: Painter not active
      QPainter::setWorldTransform: Painter not active
      QPainter::restore: Unbalanced save/restore
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::worldTransform: Painter not active
      QWidgetEffectSourcePrivate::pixmap: Painter not active
      QPainter::save: Painter not active
      QPainter::setOpacity: Painter not active
      QPainter::setWorldTransform: Painter not active
      QPainter::restore: Unbalanced save/restore
      QPainter::begin: A paint device can only be painted by one painter at a time.
      QPainter::translate: Painter not active
      QPainter::worldTransform: Painter not active
      QWidgetEffectSourcePrivate::pixmap: Painter not active
      QPainter::save: Painter not active
      QPainter::setOpacity: Painter not active
      QPainter::setWorldTransform: Painter not active
      QPainter::restore: Unbalanced save/restore
      

      Updated implementation of same button click

      qDebug() << "MainWindow::on_buttonHomeAll_clicked: D to All.";
              // Button Movement
              QPropertyAnimation *animation5 = new QPropertyAnimation(ui->buttonFuel7, "geometry");
              animation5->setDuration(300);
              animation5->setStartValue(ui->buttonFuel7->geometry());
              animation5->setEndValue(QRect(80, 930, 290, 290));
              animation5->start(QAbstractAnimation::DeleteWhenStopped);
              // / Button Movement
      
              // Button Movement
              QPropertyAnimation *animation3 = new QPropertyAnimation(ui->buttonFuel8, "geometry");
              animation3->setDuration(300);
              animation3->setStartValue(ui->buttonFuel8->geometry());
              animation3->setEndValue(QRect(395, 930, 290, 290));
              animation3->start(QAbstractAnimation::DeleteWhenStopped);
              // / Button Movement
      
              // Button Movement
              QPropertyAnimation *animation4 = new QPropertyAnimation(ui->buttonFuel9, "geometry");
              animation4->setDuration(300);
              animation4->setStartValue(ui->buttonFuel9->geometry());
              animation4->setEndValue(QRect(710, 930, 290, 290));
              animation4->start(QAbstractAnimation::DeleteWhenStopped);
              // / Button Movement
      
      
      
              // Fade In
              QGraphicsOpacityEffect *fadeInEffect1 = new QGraphicsOpacityEffect(this);
              ui->buttonFuel1->setGraphicsEffect(fadeInEffect1);
              QPropertyAnimation *animationFaceIn = new QPropertyAnimation(fadeInEffect1,"opacity");
              animationFaceIn->setDuration(300);
              animationFaceIn->setStartValue(0);
              animationFaceIn->setEndValue(1);
              animationFaceIn->setEasingCurve(QEasingCurve::InBack);
              animationFaceIn->start(QAbstractAnimation::DeleteWhenStopped);
      
              connect(animationFaceIn,&QPropertyAnimation::finished,[=](){fadeInEffect1->deleteLater(); ui->buttonFuel1->setVisible(1); });
              // / Fade In
      
              // Fade In
              QGraphicsOpacityEffect *fadeInEffect2 = new QGraphicsOpacityEffect(this);
              ui->buttonFuel2->setGraphicsEffect(fadeInEffect2);
              QPropertyAnimation *animationFaceIn2 = new QPropertyAnimation(fadeInEffect2,"opacity");
              animationFaceIn2->setDuration(300);
              animationFaceIn2->setStartValue(0);
              animationFaceIn2->setEndValue(1);
              animationFaceIn2->setEasingCurve(QEasingCurve::InBack);
              animationFaceIn2->start(QAbstractAnimation::DeleteWhenStopped);
      
              connect(animationFaceIn2,&QPropertyAnimation::finished,[=](){fadeInEffect2->deleteLater(); ui->buttonFuel2->setVisible(1); });
              // / Fade In
      
              // Fade In
              QGraphicsOpacityEffect *fadeInEffect3 = new QGraphicsOpacityEffect(this);
              ui->buttonFuel3->setGraphicsEffect(fadeInEffect3);
              QPropertyAnimation *animationFaceIn3 = new QPropertyAnimation(fadeInEffect3,"opacity");
              animationFaceIn3->setDuration(300);
              animationFaceIn3->setStartValue(0);
              animationFaceIn3->setEndValue(1);
              animationFaceIn3->setEasingCurve(QEasingCurve::InBack);
              animationFaceIn3->start(QAbstractAnimation::DeleteWhenStopped);
      
              connect(animationFaceIn3,&QPropertyAnimation::finished,[=](){fadeInEffect3->deleteLater(); ui->buttonFuel3->setVisible(1); });
              // / Fade In
      
              // Fade In
              QGraphicsOpacityEffect *fadeInEffect4 = new QGraphicsOpacityEffect(this);
              ui->buttonFuel4->setGraphicsEffect(fadeInEffect4);
              QPropertyAnimation *animationFaceIn4 = new QPropertyAnimation(fadeInEffect4,"opacity");
              animationFaceIn4->setDuration(300);
              animationFaceIn4->setStartValue(0);
              animationFaceIn4->setEndValue(1);
              animationFaceIn4->setEasingCurve(QEasingCurve::InBack);
              animationFaceIn4->start(QAbstractAnimation::DeleteWhenStopped);
      
              connect(animationFaceIn4,&QPropertyAnimation::finished,[=](){fadeInEffect4->deleteLater(); ui->buttonFuel4->setVisible(1); });
              // / Fade In
      
              // Fade In
              QGraphicsOpacityEffect *fadeInEffect5 = new QGraphicsOpacityEffect(this);
              ui->buttonFuel5->setGraphicsEffect(fadeInEffect5);
              QPropertyAnimation *animationFaceIn5 = new QPropertyAnimation(fadeInEffect5,"opacity");
              animationFaceIn5->setDuration(300);
              animationFaceIn5->setStartValue(0);
              animationFaceIn5->setEndValue(1);
              animationFaceIn5->setEasingCurve(QEasingCurve::InBack);
              animationFaceIn5->start(QAbstractAnimation::DeleteWhenStopped);
      
              connect(animationFaceIn5,&QPropertyAnimation::finished,[=](){fadeInEffect5->deleteLater(); ui->buttonFuel5->setVisible(1); });
              // / Fade In
      
              // Fade In
              QGraphicsOpacityEffect *fadeInEffect6 = new QGraphicsOpacityEffect(this);
              ui->buttonFuel6->setGraphicsEffect(fadeInEffect6);
              QPropertyAnimation *animationFaceIn6 = new QPropertyAnimation(fadeInEffect6,"opacity");
              animationFaceIn6->setDuration(300);
              animationFaceIn6->setStartValue(0);
              animationFaceIn6->setEndValue(1);
              animationFaceIn6->setEasingCurve(QEasingCurve::InBack);
              animationFaceIn6->start(QAbstractAnimation::DeleteWhenStopped);
      
              connect(animationFaceIn6,&QPropertyAnimation::finished,[=](){fadeInEffect6->deleteLater(); ui->buttonFuel6->setVisible(1); });
              // / Fade In
      
              // Fade In
              QGraphicsOpacityEffect *fadeInEffect7 = new QGraphicsOpacityEffect(this);
              ui->buttonFuel10->setGraphicsEffect(fadeInEffect7);
              QPropertyAnimation *animationFaceIn7 = new QPropertyAnimation(fadeInEffect7,"opacity");
              animationFaceIn7->setDuration(300);
              animationFaceIn7->setStartValue(0);
              animationFaceIn7->setEndValue(1);
              animationFaceIn7->setEasingCurve(QEasingCurve::InBack);
              animationFaceIn7->start(QAbstractAnimation::DeleteWhenStopped);
      
              connect(animationFaceIn7,&QPropertyAnimation::finished,[=](){fadeInEffect7->deleteLater(); ui->buttonFuel10->setVisible(1); });
              // / Fade In
      
      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #4

        Can you provide a minimal compilable example that reproduces this ?

        Did you try with 6.2 since was released yesterday ?

        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
        0
        • R Offline
          R Offline
          RyanAR
          wrote on last edited by RyanAR
          #5

          @SGaist

          Thanks for taking the time! I have tried with the following compilers, all issuing the same warnings;

          Qt 6.1.2 MinGW & MSVC 2019 64-bit
          Qt 5.12.11 MinGW 64-bit & 32-bit
          Qt 5.12.11 MSVC 2017 64-bit
          Edit: Qt 6.2 MingGW 64-bit

          I have cleaned up the code and made a GitHub Gist as I kept hitting the character limit for the forums. If you would like it in another format, please feel free to let me know.

          Project Link.

          1 Reply Last reply
          1
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #6

            Works for me on macOS with Qt 5.15.2.

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

            R 1 Reply Last reply
            1
            • SGaistS SGaist

              Works for me on macOS with Qt 5.15.2.

              R Offline
              R Offline
              RyanAR
              wrote on last edited by
              #7

              @SGaist

              Very strange! It is worth mentioning that I only get the warnings when I click one of the main navigation bars, then one of the filters.

              For example; click Supply, then Home (no warnings), then Filter 2 (warnings spam).

              1 Reply Last reply
              0
              • R Offline
                R Offline
                RyanAR
                wrote on last edited by
                #8

                If anyone else is able to trigger the warnings by clicking Supply, Home, then the Filters, please let me know what versions you're running!

                Thanks,
                Ryan

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  RyanAR
                  wrote on last edited by
                  #9

                  I ended up requesting support with Qt Enterprise and they gave instructions on how to fix it.

                  For anyone else having this issue, I had to setGraphicsEffect to nullptr after the animation has finished: "ui->buttonItem10->setGraphicsEffect(nullptr);".

                  connect(animationFadeIn7,&QPropertyAnimation::finished,[=](){effectFadeOut7->deleteLater(); ui->buttonItem10->setVisible(0); ui->buttonItem10->setGraphicsEffect(nullptr); });
                  
                  1 Reply Last reply
                  1
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #10

                    Thanks for the feedback and solution !

                    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
                    0
                    • D Offline
                      D Offline
                      Dawn_of_Time
                      wrote on last edited by
                      #11

                      It's nice to find out after a few years. My understanding of this error is that qt does not allow qgraphicseffect in parent-child controls to work at the same time. Therefore, a good practice is to turn qgraphicseffect on when you need to use it, using effect->setEnabled(ture), and turn it off when you don't need it.
                      In addition, because my English is not good, the above content is translated from the translation software. Please forgive me.

                      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