QPropertyAnimation Crash



  • I would like to help from you. I have a widget in which widgets, i want to animate this widget. I tried as much as possible, but i can't solve problem.

    When i want to animate widget with QPropertyAnimation i've got following error: QPainter::begin: A paint device can only be painted by one painter at a time. But when i add widget that not "abstract widget", for example Label or Scrollbar, it works. If i simply added uzenetWidget to QPropertyanimation in MainWindow, it was crash.

    So i write the class called by "AnimationManager class",and i add widget manually to parallelanimationgroup.

    By the way i want to opacity animation. What is the correct way to animate widget? Because i think the problem possible solve easier than mine.

    In Mainwindow: uzenetWidget

    In uzenetWidget: scrollWidget and ChooserWidget

    Codes(works perfectly but i think not the best solution):

    AnimationManager:

    AnimationManager::AnimationManager(QWidget *parent):QObject(parent){
       this->szulo = parent;
       this->AnimItems = new QVector<QWidget*>;
       this->AnimGroup = new QParallelAnimationGroup;
       qDebug() << "Konstuktor vége.";
    }
    
    void AnimationManager::addWidget(QWidget * widget,animType tipus){
       QGraphicsOpacityEffect *effect2= new QGraphicsOpacityEffect(this);
       widget->setGraphicsEffect(effect2);
       effect2->setOpacity(0.0);
       QPropertyAnimation *b = new QPropertyAnimation(effect2,"opacity");
       b->setDuration(600);
       b->setStartValue(0.0);
       b->setEndValue(1.0);
       b->setEasingCurve(QEasingCurve::InBack);
       this->AnimGroup->addAnimation(b);
    }
    
    
    void AnimationManager::startAnimation(){
       connect(AnimGroup,SIGNAL(finished()),szulo,SLOT(animVege()));
       this->AnimGroup->start();
    

    uzenetWidget("Base class"):

    uzenetWidget::uzenetWidget(QWidget *parent) :
        QWidget(parent),
        ui(new Ui::uzenetWidget)
    {
        ui->setupUi(this);
    
        this->setBackground();
        this->setWindowOpacity(0.0);
        chooser = new ChooserWidget(this);
        chooser->setWidgetSize(OS::kijelzoSzelesseg,20);
        chooser->setGeometry(65,90,chooser->width(),chooser->height());
        chooser->setRectSize(60,3);
        chooser->setChooserPositions(0,100,200);
        chooser->setVisible(true);
    
    
        scroller = new scrollWidget(this);
        scroller->setGeometry(40,110,scroller->width(),scroller->height());
        scroller->addNewData("name","tesztüzitesztüzi","06304231822","2012.01.21");
        scroller->addNewData("Jani","Text","06304242222","2012.04.21");
        scroller->setUp();
        scroller->setVisible(true);
    
        scroller->setObjectName("scrollerWidget");
        chooser->setObjectName("chooserWidget");
    }
    
    void uzenetWidget::animationConfig(){
        AnimationManager::animType anitipus = AnimationManager::animType::fadein;
        aniManager->addWidget(this->chooser->getChooser(),anitipus);
        aniManager->addWidget(this->scroller->getGrid()->itemAt(0)->widget(),anitipus);
        this->scroller->getGrid()->itemAt(0)->widget()->graphicsEffect()->setEnabled(true);
        aniManager->addWidget(this->scroller->getGrid()->itemAt(1)->widget(),anitipus);
        aniManager->addWidget(this->scroller->getGrid()->itemAt(2)->widget(),anitipus);
        aniManager->addWidget(this->scroller->getGrid()->itemAt(3)->widget(),anitipus);
        aniManager->addWidget(this->scroller->getGrid()->itemAt(4)->widget(),anitipus);
        aniManager->addWidget(this->scroller->getGrid()->itemAt(5)->widget(),anitipus);
        aniManager->addWidget(this->scroller->getGrid()->itemAt(6)->widget(),anitipus);
        aniManager->addWidget(this->scroller->getGrid()->itemAt(7)->widget(),anitipus);
    }
    
    
    void uzenetWidget::animationStart(){
        aniManager = new AnimationManager(this);
        animationConfig();
        this->aniManager->startAnimation();
    }
    
    void uzenetWidget::animVege(){
        scroller->setEffect(scroller->uzenetek[0]);
        scroller->setEffect(scroller->uzenetek[1]);
        scroller->setEffect(scroller->uzenetek[2]);
        scroller->setEffect(scroller->uzenetek[3]);
        scroller->uzenetek[0].effect->setEnabled(true);
        delete aniManager;
    }
    

    I really hope you can help me.


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Can you post a minimal compilable example that reproduce the crash you were experiencing ?




  • Lifetime Qt Champion

    The thing is, with a video I can't test nor analyse what could go wrong.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.