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. Is it possible to freeze QWidget during QPropertyAnimation works
QtWS25 Last Chance

Is it possible to freeze QWidget during QPropertyAnimation works

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 2 Posters 3.0k 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.
  • R Offline
    R Offline
    Romaniy173
    wrote on last edited by
    #1

    Hi.

    There is the next issue: I have two widgets witch I have added to SlidingStackWidget that was inherited from QStackWidget. The main idea make smooth animation while switching between two widgets from QStackWidget.
    The main problem: one of child widget is having a very heavy paintEvent, so when animation is working it looks ugly when this QWidget with huge paintEvent logic moving. I am not sure if that an issue in that case. But if it is, if there way how I could change paintEvent just before animation to denied draw again and again logic with many conditions, but just freeze widget as it is in moment of animation starting and just move freeze rectangle?
    I just wondering is there something like QObject::installEventFilter where I need to set up this logic and change it from custom to freeze?

    Thanks in advance

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

      Hi
      There is
      setUpdatesEnabled(false);

      1 Reply Last reply
      1
      • R Offline
        R Offline
        Romaniy173
        wrote on last edited by
        #3

        @mrjj said in Is it possible to freeze QWidget during QPropertyAnimation works:

        setUpdatesEnabled(false);

        Thanks.
        Unfortunately, it does not solve my problem. The thing is, in this case I disable paintEvent() at all, so there is no animation between sliding.

        mrjjM 1 Reply Last reply
        0
        • R Offline
          R Offline
          Romaniy173
          wrote on last edited by Romaniy173
          #4

          I mean I need something like save current view of widget without further updating till animation finished and draw this snapshot again and again during animation, which probably less heavy action then use custom paintEvent...

          1 Reply Last reply
          0
          • R Romaniy173

            @mrjj said in Is it possible to freeze QWidget during QPropertyAnimation works:

            setUpdatesEnabled(false);

            Thanks.
            Unfortunately, it does not solve my problem. The thing is, in this case I disable paintEvent() at all, so there is no animation between sliding.

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by mrjj
            #5

            @Romaniy173
            But did you disable painting only for the heavy widget ??
            widget->setUpdatesEnabled(false);

            not for all of stackedwidget

            1 Reply Last reply
            0
            • R Offline
              R Offline
              Romaniy173
              wrote on last edited by
              #6

              I have disabled for all widgets(only two there). I did like that because I want to change widgets by sliding side by side like that:

              	pNext->move(pNext->x() - OffsetX, pNext->y() - OffsetY);
              	pNext->show();
              	pNext->raise();
              
              	auto *pCurrent = currentWidget();
              	auto *pAnimationCurrent = new QPropertyAnimation(pCurrent, "pos");
              	pAnimationCurrent->setDuration(mp_Duration);
              	pAnimationCurrent->setStartValue(QPoint(pCurrent->x(), pCurrent->y()));
              	pAnimationCurrent->setEndValue(QPoint(pCurrent->x() + OffsetX, pCurrent->y() + OffsetY));
              
              	auto *pAnimationNext = new QPropertyAnimation(pNext, "pos");
              	pAnimationNext->setDuration(mp_Duration);
              	pAnimationNext->setStartValue(QPoint(pNext->x(), pNext->y()));
              	pAnimationNext->setEndValue(QPoint(pNext->x() + OffsetX, pNext->y() + OffsetY));
              
              	auto *pAnimationGroup = new QParallelAnimationGroup(this);
              	pAnimationGroup->addAnimation(pAnimationCurrent);
              	pAnimationGroup->addAnimation(pAnimationNext);
              
              1 Reply Last reply
              0
              • mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #7

                hi
                Ahh you are not animating the stacked widget pages but the widgets them self ?

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

                  Yes, exactly

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

                    @mrjj I am sorry, what do you mean when said pages? Could you provide a web page where I could read about it?

                    mrjjM 1 Reply Last reply
                    0
                    • R Romaniy173

                      @mrjj I am sorry, what do you mean when said pages? Could you provide a web page where I could read about it?

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @Romaniy173

                      Hi,
                      Ok i though you animated some widgets inside the QStackedWidget.
                      Then disable painting will also disable seeing the sliding.

                      The QStackWidget has multiple widgets. I call these pages but its actually more
                      correct to say widgets as it do not have to contain other widgets.

                      Anyway, you could use event filer to steal the paint event and then draw rect yourself.
                      Alternatively use the Render function fo reach widget and draw images of the widget.

                      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